Commit 3b04a40
authored
fix(sequencer): bounded sweep instead of event scan for governance proposal check (#22989)
## Motivation
`hasPayloadBeenProposed` (now `hasActiveProposalWithPayload`) used
`eth_getLogs` over the rollup's full L1 deployment range to find prior
`PayloadSubmitted` events. On long-lived rollups that range exceeds
typical RPC provider block-range caps and the call times out, silently
breaking the sequencer's "stop signaling for an already-proposed
payload" logic. The previous in-memory cache also permanently
blacklisted any payload it saw as proposed once, which is wrong: each
round on `EmpireBase` is independent and the same payload can
legitimately be re-signaled and re-submitted after a prior proposal
becomes Dropped/Rejected/Expired/Executed.
## Approach
Replace the log scan with a bounded view-call sweep over
`Governance.proposals`. The sweep walks newest -> oldest using
`proposalCount`, unwraps each proposal's `GSEPayload` via
`getOriginalPayload()`, and treats only
`Pending`/`Active`/`Queued`/`Executable` as "in an active proposal" --
terminal states allow re-signaling. The descent has a hard early-stop on
the protocol-wide proposal lifetime cap (`4 *
ConfigurationLib.TIME_UPPER = 360 days`), which is safe regardless of
per-proposal frozen configs because every config field is bounded by
`TIME_UPPER` on-chain. Two in-memory caches absorb the per-call cost
over time: terminal proposals (provably immutable on-chain) and wrapper
-> original payload unwraps (immutable bytecode).
## Changes
- **ethereum/contracts/governance**: New
`hasActiveProposalWithPayload(payload)` and `getProposalCount()` on
`ReadOnlyGovernanceContract`. Inlines a minimal `IProposerPayload` ABI
(just `getOriginalPayload`) to avoid generating a full artifact. Handles
`proposeWithLock`-style proposals (no GSEPayload wrapper) by catching
the unwrap revert and skipping.
- **ethereum/contracts/governance (types)**: Adds explicit types
(`Proposal`, `ProposalConfiguration`, `GovernanceConfiguration`,
`ProposeWithLockConfiguration`, `Ballot`) and maps the viem return
shapes of `getProposal` / `getConfiguration` onto them. `Proposal` now
carries both `cachedState` (raw stored) and `state` (live, time-derived
from `getProposalState`); `getProposal` issues both reads in parallel so
callers don't need a separate state RPC.
- **ethereum/contracts/governance (caching)**: Adds two memoization
layers on `ReadOnlyGovernanceContract`. Proposals are cached when
`state` is in any of the four terminal phases
(Executed/Rejected/Dropped/Expired) -- once terminal the entire struct
is provably immutable on-chain. Wrapper unwraps are keyed by wrapper
address and cached forever (deployed bytecode is immutable).
`GovernanceProposerContract` already memoizes its `getGovernance()`, so
the same `ReadOnlyGovernanceContract` instance (and its caches) is
reused across slots in the sequencer publisher.
- **ethereum/contracts/governance_proposer**: Drops the event-based
`hasPayloadBeenProposed`. Adds a memoized `getGovernance()` accessor and
a thin `hasActiveProposalWithPayload` delegate that resolves the
Governance address via the on-chain registry lookup.
- **ethereum/contracts/empire_base**: Removes `hasPayloadBeenProposed`
from `IEmpireBase` -- it's a Governance concern, not a generic empire
concern (slasher doesn't need it).
- **sequencer-client/publisher**: Removes the permanent
`payloadProposedCache` so the publisher re-checks every slot, allowing
re-signaling once a prior proposal is terminal. Switches the failure
mode from fail-closed to fail-open (a flaky L1 endpoint should not
silence governance participation; a duplicate signal is harmless).
Narrows the helper's `base` param from `IEmpireBase` to
`GovernanceProposerContract` since this code path is governance-only.
- **ethereum/contracts (tests)**: New `hasActiveProposalWithPayload`
describe block hitting a real anvil-deployed Governance. Impersonates
the `governanceProposer`, calls `Governance.propose` directly, and
etches hand-rolled mock wrapper bytecode at chosen addresses to drive
(wrapper, original) pairs. Covers: empty governance, live match, no
match, terminal state via warp, reverting wrapper
(proposeWithLock-style), descent past unrelated proposals,
case-insensitive match, and the 360-day hard cutoff via warp. Also adds
a sync-guard describe block that probes `Governance.updateConfiguration`
via impersonated `eth_call` to assert each of
`votingDelay`/`votingDuration`/`executionDelay`/`gracePeriod` accepts
`TIME_UPPER` and rejects `TIME_UPPER + 1` -- if those caps change
on-chain, this trips and `MAX_PROPOSAL_LIFETIME_SECONDS` must be
revisited.
- **sequencer-client/publisher (tests)**: Replaces the cache test with a
"re-checks each call so re-signaling resumes after terminal" test.
Updates the RPC-failure semantics test from fail-closed to fail-open.1 parent 8d06bdc commit 3b04a40
6 files changed
Lines changed: 626 additions & 110 deletions
File tree
- yarn-project
- ethereum/src/contracts
- sequencer-client/src/publisher
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
20 | 35 | | |
21 | 36 | | |
22 | 37 | | |
| |||
34 | 49 | | |
35 | 50 | | |
36 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
37 | 144 | | |
38 | 145 | | |
39 | 146 | | |
| |||
50 | 157 | | |
51 | 158 | | |
52 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
53 | 176 | | |
54 | 177 | | |
55 | 178 | | |
| |||
65 | 188 | | |
66 | 189 | | |
67 | 190 | | |
68 | | - | |
69 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
70 | 206 | | |
71 | 207 | | |
72 | | - | |
73 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
74 | 250 | | |
75 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
76 | 257 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
81 | 337 | | |
82 | | - | |
| 338 | + | |
| 339 | + | |
83 | 340 | | |
84 | 341 | | |
85 | 342 | | |
| |||
Lines changed: 22 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
117 | 134 | | |
118 | 135 | | |
119 | 136 | | |
| |||
0 commit comments