Skip to content

Commit 2979199

Browse files
committed
revert(b20-mock): drop isAnnouncementActive view and transient flag
The previous commit added an isAnnouncementActive() view backed by an EIP-1153 transient flag, aiming for parity with the Rust precompile's is_announcement_active runtime flag. On review the check is unnecessary: inner-call dispatch in announce(...) is self-delegatecall only, so there is no reentrancy surface for an external contract to want to detect a bracket-in-progress against. Removes the view from IB20Asset, the flag and its set/clear from MockB20Asset.announce, and the boundary tests.
1 parent ea1b5b0 commit 2979199

3 files changed

Lines changed: 0 additions & 105 deletions

File tree

src/interfaces/IB20Asset.sol

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,6 @@ interface IB20Asset is IB20 {
109109
/// @return Whether `id` is used.
110110
function isAnnouncementIdUsed(string calldata id) external view returns (bool);
111111

112-
/// @notice Whether an announcement bracket is currently open on this token. True from the
113-
/// start of `announce` through the dispatch of every entry in `internalCalls` and
114-
/// until `EndAnnouncement` fires; false at all other times, including before the
115-
/// first `announce` call and after the bracket closes. Resets per transaction:
116-
/// a revert anywhere in the bracket leaves no observable side effect on this view.
117-
///
118-
/// @dev Intended for inner-call contracts dispatched via `internalCalls` (or other
119-
/// contracts they reach) to detect they are executing inside an announcement
120-
/// bracket — useful for issuance, multiplier, and metadata flows whose policy
121-
/// differs when run as part of a disclosed corp action vs. ad-hoc.
122-
///
123-
/// @return Whether an announcement is currently active.
124-
function isAnnouncementActive() external view returns (bool);
125-
126112
/*//////////////////////////////////////////////////////////////
127113
MULTIPLIER
128114
//////////////////////////////////////////////////////////////*/

test/lib/mocks/MockB20Asset.sol

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,6 @@ contract MockB20Asset is MockB20, IB20Asset {
6464
/// by this before dividing.
6565
uint256 public constant WAD_PRECISION = 1e18;
6666

67-
// ============================================================
68-
// ANNOUNCEMENT-ACTIVE FLAG
69-
// ============================================================
70-
71-
/// @dev Per-transaction flag set true at the start of `announce`
72-
/// and false at the end, surfaced via `isAnnouncementActive()`.
73-
/// Lives in transient storage (EIP-1153) because the value is
74-
/// meaningful only within the bracket's call frame and MUST
75-
/// reset between transactions; transient storage also means
76-
/// the slot is reclaimed automatically on a revert anywhere in
77-
/// the bracket, so the flag never gets stuck `true`.
78-
///
79-
/// Declared as a contract-level state variable (not an
80-
/// ERC-7201 namespaced struct field) because transient storage
81-
/// lives in its own opcode-distinct address space — slot
82-
/// indices here can't collide with the regular-storage layout
83-
/// written by the factory bootstrap. The Rust precompile
84-
/// exposes the same value via a runtime context flag rather
85-
/// than a storage slot, so there is no persistent layout the
86-
/// Rust impl needs to mirror.
87-
bool internal transient _announcementActive;
88-
8967
// ============================================================
9068
// DECIMALS
9169
// ============================================================
@@ -119,13 +97,6 @@ contract MockB20Asset is MockB20, IB20Asset {
11997
// selector check were ever weakened.
12098
$.usedAnnouncementIds[id] = true;
12199

122-
// Open the bracket — flip the transient flag BEFORE emitting
123-
// `Announcement` and before dispatching any inner call, so any
124-
// contract reached transitively through `internalCalls` sees
125-
// `isAnnouncementActive() == true` for the full lifetime of the
126-
// bracket.
127-
_announcementActive = true;
128-
129100
emit Announcement(msg.sender, id, description, uri);
130101

131102
for (uint256 i = 0; i < internalCalls.length; i++) {
@@ -135,21 +106,12 @@ contract MockB20Asset is MockB20, IB20Asset {
135106
}
136107

137108
emit EndAnnouncement(id);
138-
139-
// Close the bracket. A revert above leaves transient storage
140-
// untouched at tx end (per EIP-1153), so an aborted bracket
141-
// also resets the flag implicitly.
142-
_announcementActive = false;
143109
}
144110

145111
function isAnnouncementIdUsed(string calldata id) external view returns (bool) {
146112
return MockB20AssetStorage.layout().usedAnnouncementIds[id];
147113
}
148114

149-
function isAnnouncementActive() external view returns (bool) {
150-
return _announcementActive;
151-
}
152-
153115
// ============================================================
154116
// MULTIPLIER
155117
// ============================================================

test/unit/B20Asset/announcement/isAnnouncementActive.t.sol

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)