Repository navigation
[smr-moonshot#5339] Bound BlockMeta.blockPrologue's own gas and drop the block-metadata transaction's gas limit - #99
Merged
Conversation
…logue gas cap at the block-metadata transaction's gas limit blockPrologue calls each entry without copying its return data and logs at most MAX_LOGGED_RETURN_DATA (128) bytes of it in CallFailed, from the same memory for every entry, so that its own cost per entry does not depend on what a target returns. register, updateExecutionOrder and setBlockPrologueGasCap require the entries' gas limits, ENTRY_GAS_RESERVE (16,500) per entry and PROLOGUE_GAS_RESERVE (12,000) to fit in 63/64 * 63/64 of the cap: one 63/64 for the proxy's DELEGATECALL to the implementation and one for the CALL to each entry. With that bound every entry's call receives its whole gas limit and blockPrologue completes. maxRegistrableGasLimit() returns the largest gas limit a new entry can have, and InitializeCycleMonitoring checks against it. initialize and setBlockPrologueGasCap refuse a cap above MAX_BLOCK_PROLOGUE_GAS_CAP, 2^24, the gas limit the node executes the block-metadata transaction with. blockPrologue and the functions that change the entry list, the cap or the implementation are nonReentrant (transient storage), so that none of them changes while the loop runs. BlockMeta changes in place: it exists only on Devnet, which is re-genesised. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ETADATA_GAS_LIMIT BlockMetadata no longer carries a gas limit: Transaction::gas_limit returns DEFAULT_BLOCK_METADATA_GAS_LIMIT (2^24) for every block-metadata transaction, and the builder has no gas_limit setter. BlockMeta keeps its cap at or below that limit and bounds its own cost within the cap, so the limit changes no execution result. The field's removal changes the transaction's serde forms and so its hash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k's revm and measure its gas The ee-tests deploy BlockMeta from the genesis transactions and run blockPrologue as the node runs the block-metadata transaction, in ExecutionMode::System through run_system_call, under the Prague and Osaka gas schedules. With the entries' gas limits and reserves filling the budget at MAX_BLOCK_PROLOGUE_GAS_CAP, for 1, 2, 64 and the most entries the cap admits, and cold EIP-7702-delegated targets that spend their whole gas limit and revert with more return data than CallFailed logs, they check that blockPrologue succeeds, that every entry receives its whole gas limit, and that the gas spent outside the entries is within the reserves. Measured: 10,924 gas per entry and 7,866 outside the entries, for both the default and the production Foundry profile within 18 gas. ENTRY_GAS_RESERVE and PROLOGUE_GAS_RESERVE are those figures plus 50%, rounded up to a multiple of 500. AUTOMATION_REGISTRY_GAS_GUIDE.md describes the bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rom one helper register, updateExecutionOrder, setBlockPrologueGasCap and maxRegistrableGasLimit all read gasBudgetLeft, which returns whether the entries fit the cap's budget and the gas the budget leaves after them. register accepts a gas limit up to what the helper leaves for one more entry, the figure maxRegistrableGasLimit returns, so the two cannot disagree. A fuzz test registers maxRegistrableGasLimit and one gas more at random caps beside a first entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…red under BLOCK_PROLOGUE_GAS_MEASURED_SPECS (Prague and Osaka) names the EVM specs under which ENTRY_GAS_RESERVE and PROLOGUE_GAS_RESERVE were measured. The ee-test runs blockPrologue under every spec on it, so adding a spec to the list re-runs the measurement under it. smr-moonshot checks its supported spec codes against the list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ransaction's gas limit and remove the configurable cap BlockMeta no longer has a block prologue gas cap: the blockPrologueGasCap storage variable, setBlockPrologueGasCap, the cap argument of initialize, InvalidGasCap and BlockPrologueGasCapUpdated are removed. register and updateExecutionOrder budget against BLOCK_METADATA_GAS_LIMIT (2^24), the gas limit the node executes the block-metadata transaction with: the entries' gas limits, ENTRY_GAS_RESERVE per entry and PROLOGUE_GAS_RESERVE within 63/64 * 63/64 of it. The ee-test asserts that BLOCK_METADATA_GAS_LIMIT equals DEFAULT_BLOCK_METADATA_GAS_LIMIT. The genesis config loses block_prologue_gas_cap with its validation and tests, and the genesis transaction initializes BlockMeta with its owner only. BlockMeta changes in place: it exists only on Devnet, which is re-genesised. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 of 9 tasks
… and upgraded implementations The bound holds while the node's gas limit for the block-metadata transaction is at least BlockMeta.BLOCK_METADATA_GAS_LIMIT, and for an implementation whose blockPrologue the reserves were measured against. Document the order of a change to the limit and the measurement an upgraded implementation needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GovActions.t.sol keeps #100's digest tests and this branch's test_acceptsTheLargestLimitBlockMetaAccepts, which replaced test_acceptsALimitEqualToTheCallableShare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the fork side of Entropy-Foundation/smr-moonshot#5339 on the revm 43 sync branch. Entropy-Foundation/smr-moonshot#5357 pins this branch and removes what read or recorded the carried limit; it is stacked on smr-moonshot#5341, which pins
feature/revm-43-sync.What
BlockMeta.blockPrologue()completes within the block-metadata transaction's gas limit for every registrationBlockMetaaccepts and whatever its targets do, and theBlockMetadatatransaction no longer carries a gas limit.Changes
BlockMeta.sol(changed in place; no UUPS upgrade, sinceBlockMetaruns only on Devnet, which is re-genesised)blockPrologue()calls each entry in assembly with a zero-length output buffer, so no return data is copied.CallFailedlogs at most the firstMAX_LOGGED_RETURN_DATA= 128 bytes of the return data, built in memory past the free-memory pointer without advancing it, so every entry costs the same. The event signature is unchanged.registerandupdateExecutionOrderrequire the sum of the entries' gas limits plusENTRY_GAS_RESERVE(16,500) per entry plusPROLOGUE_GAS_RESERVE(12,000) to fit inBLOCK_METADATA_GAS_LIMIT× (63/64)², the square covering the proxy's DELEGATECALL and the CALL to each entry.BLOCK_METADATA_GAS_LIMIT= 2^24 is the gas limit the transaction executes with (DEFAULT_BLOCK_METADATA_GAS_LIMIT). One private helper,gasBudgetLeft, gives both those checks and the new viewmaxRegistrableGasLimit().blockPrologueGasCapstorage variable,setBlockPrologueGasCap, its event and error, and the cap argument ofinitialize(nowinitialize(address)). The owner that set it is the only party that registers entries, so it bounded nothing the owner did not already control.blockPrologue,register,deregister,deregisterAt,updateExecutionOrderand_authorizeUpgradearenonReentrant(OZReentrancyGuardTransient, no storage slot), so an entry cannot change the entry list or the implementation during the loop.GovActions.s.solInitializeCycleMonitoringchecks againstmaxRegistrableGasLimit().BlockMetadatatransaction (crates/supra-extension/src/transactions/block_metadata.rs)gas_limitfield and its builder setter are removed;Transaction::gas_limitreturnsDEFAULT_BLOCK_METADATA_GAS_LIMIT(2^24). The serialized forms change.BLOCK_PROLOGUE_GAS_MEASURED_SPECS(PRAGUE, OSAKA) lists the specs the reserves were measured under. smr-moonshot checks that every spec it supports is on the list.Measurement (
crates/ee-tests/src/block_prologue_gas.rs)BlockMetafrom the genesis transactions and runsblockPrologue()as the node does (ExecutionMode::System,validate_callerthenrun_system_call), under each measured spec, with 1, 2, 64, 980 and 984 entries (984 is the most the budget admits). Every target is a cold EIP-7702-delegated account that consumes its whole gas limit and reverts with as much return data as the rest pays for.CallFailedper entry carries the right 128-byte prefix, each entry receives exactly its gas limit, and the gas spent outside the entry calls is within the reserves.Genesis:
block_prologue_gas_capis removed fromGenesisTransactionGeneratorConfig, and the genesis transaction callsinitialize(owner).Other:
BlockMetagolden bytecode hash ingenerator.rs; Foundry tests for the budget boundaries, the per-entry reserve, the 128-byte prefix, reentrancy andmaxRegistrableGasLimitagainstregister(fuzzed);AUTOMATION_REGISTRY_GAS_GUIDE.md,README.mdand comments.Testing
cargo fmt --all --check,RUSTFLAGS=-Dwarnings cargo clippy --workspace --all-targets --all-features: clean.cargo test --workspace: 678 passed, 11 ignored.cargo test --workspace --all-features: 691 passed, 12 ignored.cargo test --release -p revm-ee-tests block_prologue_gas: 5 cases, each under PRAGUE and OSAKA, passed.forge test: 696 passed.check_event_indexing.sh: pass.forge build --sizes: BlockMeta 5,866 bytes (default), 6,348 bytes (production).🤖 Generated with Claude Code