Skip to content

Evm automation feature implementation - #23

Draft
aregng wants to merge 668 commits into
mainfrom
feature/evm_automation
Draft

aregng wants to merge 668 commits into
mainfrom
feature/evm_automation

Conversation

@aregng

@aregng aregng commented May 7, 2026

Copy link
Copy Markdown

No description provided.

@aregng
aregng requested a review from sjoshisupra May 7, 2026 07:58

@isaacdoidge isaacdoidge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments and questions, most minor. I haven't spent much time with Solidity so haven't focused closely on the implementation of the contracts.

/// Transaction hash (32 bytes).
///
/// Note : Common field for all transactions.
fn tx_hash(&self) -> B256;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this field is derived then it would be useful to add a comment here explaining that. End users should not be able to set this field directly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not a derived field. It is set when application layer transaction is converted to execution layer transaction for execution. As long as revm/evm execution engine is highly generic, this Transaction abstraction is used to represent all supported transactions and properties in scope of evm execution engine context.

As long as we extended revm with a new precompile to retrieve the transaction hash in application layer, this abstraction has been extended to provide means to retrieve the information. and It is responsibility of application layer to specify it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved by #23 (comment)

/// The init-code of the default CREATE2 FACTORY widely used in community
/// Retrieved from https://github.com/Arachnid/deterministic-deployment-proxy
pub const CREATE2_FACTORY_CODE: &[u8] = &hex!(
"604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"

Comment thread Cargo.toml Outdated
Comment on lines +85 to +87
#forge = { git = "https://github.com/foundry-rs/foundry.git", tag="v1.4.1"}
#alloy-chains = { version = "0.2.13" }
#shlex = { version = "1.3.0" }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these still required?

@aregng aregng May 27, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, during development whenever an API in contracts is updated that is also utilized in scope of the node-runtime, generated rust bindings are regenerated. So these deps are kept to avoid need to add them every time.

Comment thread .gitmodules Resolved
import {LibUtils} from "./libraries/LibUtils.sol";
import {IBlockMeta} from "./interfaces/IBlockMeta.sol";

contract BlockMeta is OwnableUpgradeable, UUPSUpgradeable, IBlockMeta {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain a bit about what this contract does?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This contract is the target of the BlockMetadata transaction introduced as part of the revm extension.
The contract and BlockMetadata transaction have almost the same ideology as block.move and BlockMetadata transaction in move. To have the transaction executed for whenever committed block is executed.
And the contract provide means to register and execute actions that require execution in scope of every block unconditionally.


/// @notice Emitted when the full execution order is replaced.
/// @param executionOrder Updated array of packed execution entries.
event ExecutionOrderUpdated(uint256[] indexed executionOrder);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the execution order for? Will this affect the implementation of our parallel executor?

@aregng aregng May 27, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this has nothing to do with parallel executor. It relates to the registered targets which will be executed in scope of blockPrologue with the specified order. The parallel executor only should make sure that the BlockMetadata transaction is executed always as the first one.

Comment thread crates/supra-extension/Cargo.toml Outdated
Comment on lines +40 to +42
#forge = { workspace = true }
#clap = { workspace = true }
#shlex = { workspace = true }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need these?

github-actions Bot and others added 28 commits May 22, 2026 10:25
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Maintenance release. Patch-bump all crates affected by bluealloy#3704
(addition of is_fatal to DBErrorMarker).
* fixed disable automation logic

* - resolved PR comments
- added test cases
* feat: add state commit hook to State

* fix

---------

Co-authored-by: Arsenii Kulikov <klkvrr@gmail.com>
- this will help to reflect correct cycle duration info in the emitted
event
* Bake EIP-8037 CPSB into gas params

* Fix initial_tx_gas test calls

* refactor: dedupe initial tx gas via GasParams::initial_tx_gas_for_tx

* refactor: split validate_initial_tx_gas into spec-default and gas-params variants

* fmt

---------

Co-authored-by: rakita <dragan0rakita@gmail.com>
…lloy#3721)

Completes the release version bumps. release-plz only detected 7 crates
(revm-database + its dependents), but direct comparison against crates.io
showed 7 more crates had unpublished source changes still on their
published versions:

- revm-context-interface 19.0.2 -> 19.0.3 (bluealloy#3714)
- revm-interpreter        37.0.2 -> 37.0.3 (bluealloy#3714)
- revm-bytecode           11.0.0 -> 11.0.1 (bluealloy#3703)
- revm-database-interface 12.1.0 -> 12.1.1 (bluealloy#3710)
- revm-precompile         36.0.2 -> 36.0.3 (cascade)
- revm-primitives         24.0.0 -> 24.0.1 (bluealloy#3716, docs)
- revm-state              12.0.0 -> 12.0.1 (cascade)

All 14 crates now bumped, Cargo.lock synced, workspace builds.
Adds the consolidated v112 release entry to the root CHANGELOG.md,
summarizing the EIP-8037 CPSB gas-param work (bluealloy#3714), the new
OnStateHook for State<DB> (bluealloy#3710), RETURN/REVERT memory-modifying
fix (bluealloy#3703), and CPSB acronym docs (bluealloy#3716), along with the per-crate
version bumps.
Co-authored-by: Isaac Doidge <30425649+isaacdoidge@users.noreply.github.com>
* feat: Account::is_changed

* map_or_else
* perf: avoid realloc

* Wip

* wip

* fix ci feature propagation

---------

Co-authored-by: Derek <256792747+decofe@users.noreply.github.com>
* feat: add SSTORE gas-state policy hook (bluealloy#3731)

* feat: scaffolding

* feat: support gas state refund journal

* chore: integrate into `JournalEntryTr`

* fix: drop journal changes

* feat: extend SSTORE gas-state hook for TIP-1060 storage gas tokens (bluealloy#3733)

* feat: extend SSTORE gas-state hook for TIP-1060 storage gas tokens

Reworks the SSTORE gas-state policy hook to support TIP-1060 storage
gas tokens:

- Add `storage_gas_token_contract` to the `Cfg` trait, `CfgEnv`, and
  the `Host` trait (defaults to `None`, feature disabled). When set,
  it points to the protocol account holding per-account storage-gas-
  token counters.
- Add `LoadError`, `GasTokenResult`, `StorageCreationMode`,
  `StorageGasTokenState`, and `storage_gas_token_slot` to the host
  interface for decoding/encoding the packed gas-token state word.
- Move `GasStateTr`, `NoGasState`, and `GasStateOutcome` into the
  interpreter's `instruction_context`, reworking the trait to take an
  `InstructionContext` (and `InterpreterTypes`) so policies can drive
  full opcode-level gas accounting. `GasStateOutcome` now exposes
  `skip_refund`/`skip_state_gas`/`skip_regular_gas` toggles.
- Update the `sstore` instruction to honor the new outcome flags and
  thread the gas-state policy through the instruction table generics.

* refactor: inline cold_storage_additional_cost in sstore

* chore: drop hook-specific types

* chore: unify `skip_gas` flag

---------

Co-authored-by: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com>
Co-authored-by: 0xrusowsky <0xrusowsky@proton.me>
…lloy#3736)

* feat: wrap TransientStorage as AddressMap<StorageKeyMap<U256>>

Change TransientStorage from a flat `HashMap<(Address, StorageKey),
StorageValue>` type alias into a newtype wrapper over a nested
`AddressMap<StorageKeyMap<StorageValue>>`.

- Implement Deref/DerefMut to the inner map so existing map operations
  (clear, iter, etc.) keep working.
- Add get_value/insert_value/remove_value helpers for slot access
  without manually traversing the two levels of maps. remove_value also
  cleans up empty account slot maps.
- Update tload/tstore and the journal revert path to use the helpers.

* refactor: simplify TransientStorage::remove_value to only remove slot
…panic (bluealloy#3735)

* fix(interpreter): use IntoAddress in pop_address to avoid const-eval panic

`StackTr::pop_address` converted the popped word with
`Address::from(value.to_be_bytes())`. Since `Address: From<[u8; 20]>`, type
inference forces ruint's const-generic `Uint::<256, 4>::to_be_bytes::<20>()`,
whose `const { Self::assert_bytes(BYTES) }` requires `BYTES == Self::BYTES`
(32 for U256). That unreachable const block is only sometimes dead-code
eliminated; build profiles that actually evaluate it (cargo-fuzz coverage,
release codegen) hit `error[E0080]: BYTES must be equal to Self::BYTES`,
breaking downstream builds (bluealloy#3728).

Use the crate's existing `IntoAddress` converter (`value.into_address()`),
which does `Address::from_word(B256::from(value.to_be_bytes()))`. Its
`to_be_bytes()` infers the correct `[u8; 32]` size, so there is no fragile
const-generic instantiation, and `pop_address` now reuses the canonical
U256->Address conversion instead of inlining its own.

Add a regression test asserting `pop_address` truncates a full 32-byte word to
its low 20 bytes and returns `None` on an empty stack.

Closes bluealloy#3728

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test(interpreter): drop pop_address regression test per review

Remove `pop_address_truncates_to_low_20_bytes` as requested in review on
bluealloy#3735 — the truncation behaviour is covered by the shared `IntoAddress`
conversion path and the dedicated test is not needed.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…of TaskPredicate (#27)

Co-authored-by: Aregnaz Harutyunyan <>
- Now when transaction is executed in read-only mode, any identified state changes will be reported as errors

Co-authored-by: Aregnaz Harutyunyan <>
* Add MODEXP precompile benchmarks

* Reduce MODEXP benchmark cases

* Fix MODEXP benchmark clippy lints
…of transition state creation (#29)

Co-authored-by: Aregnaz Harutyunyan <>
Co-authored-by: Centaur AI <ai@centaur.local>
aregng and others added 30 commits November 18, 2026 13:39
… transition code (#91)

* [#4989] Serve CoreFacet's views from CoreViewFacet and trim LibCore's transition code

CoreFacet is deployed as one of the automation registry's diamond facets, and
any fix to it or to a library it inlines is redeployed as a fresh CoreFacet
(Entropy-Foundation/smr-moonshot#2772) that has to fit under EIP-170's
24,576-byte limit. At [profile.production]'s optimizer_runs = 800 it had
1,063 bytes of headroom.

CoreViewFacet now serves CoreFacet's seven views: getCycleInfo,
getCycleDuration, getTransitionInfo, isAutomationEnabled,
isAutomationReadyEnabled, getCycleStateDetails and getRecordMaxTaskCount.
ICoreViewFacet declares them; ICoreFacet keeps CoreFacet's events, errors
and five state-changing functions. The selectors are reached through the
diamond as before, so the node needs no change. This follows the
RegistryViewFacet layout (Entropy-Foundation/smr-moonshot#4101).

LibCore's transition path is reduced without changing behaviour:
- dropOrChargeTask drops a cancelled or expired task through
  dropWithWholeDeposit, the helper the other drop paths use.
- tryWithdrawTaskAutomationFee writes its outcome into the caller's
  TransitionResult. This keeps dropOrChargeTasks within the EVM stack limit,
  which it was one slot from exceeding.
- dropOrChargeTasks shortens removedBuffer in place to the removed count.

CoreFacet goes from 23,513 to 21,957 bytes (2,619 free); CoreViewFacet is
2,266 bytes. The unused EnumerableSet import is removed from CoreFacet.
CoreFacet's header records that a change to it can grow its bytecode, that a
new external function belongs in a facet of its own, and that moving
removeRegisteredTask into a separate facet is the next step if it nears the
limit.

Genesis wiring: CoreViewFacet gets a GenesisTransactionTags variant declared
and ranked right after CoreFacet, so the Diamond's genesis address moves by
one nonce. FacetsDeployment, the Diamond constructor's facet list,
LibDiamondUtils, the deploy and selector-check scripts and compile_config.toml
include it. The pinned bytecode hashes for CoreFacet, Diamond and
CoreViewFacet are regenerated from a --release build.

The record-sizing gas constants are now compiled into CoreViewFacet and
ConfigFacet, and LibCommon and AUTOMATION_REGISTRY_GAS_GUIDE.md say that an
upgrade changing them replaces those two facets. foundry.toml states the
measured headroom: CoreFacet is over the limit from 10,000 runs and
RegistryFacet from about 20,000.

Tests: DiamondInit.t.sol checks that every CoreFacet and CoreViewFacet
selector is served by its own facet, through a helper the RegistryFacet
routing test now shares. Callers in tests and scripts use ICoreViewFacet for
the moved views.

Verified: forge test passes under the default and production profiles,
check_facet_selectors.sh passes for all 8 facets, check_event_indexing.sh
passes, and cargo build, clippy and nextest --release pass for the
workspace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [#4989] Name CoreFacet in the gas-figure upgrade steps and state CoreFacet's size rule without figures

The record gas figures measure the transition code, which LibCore inlines
into CoreFacet, so an upgrade that re-derives them replaces CoreFacet as
well as CoreViewFacet and ConfigFacet. AUTOMATION_REGISTRY_GAS_GUIDE.md and
LibCommon's note on the constants now name all three facets.

CoreFacet's header states the size rule without measured byte counts, which
any change to the facet or its libraries would make stale, and points to
foundry.toml and the build's EIP-170 check instead. It describes
CoreViewFacet as the facet that serves the views.

GenesisTransactionTags' doc comment says a variant is declared next to the
contracts it belongs with until a genesis built with the enum is released,
and appended at the end after that.

Deployed bytecode is unchanged for every contract under the production
profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [#4989] Return each task's fee outcome from tryWithdrawTaskAutomationFee as a fresh struct

tryWithdrawTaskAutomationFee returns its outcome as a TransitionResult that
starts zeroed, and dropOrChargeTask assigns it on the UST path. The outcome
no longer depends on the caller passing a zero-initialised struct, and a
single struct return still keeps dropOrChargeTasks within the EVM stack
limit. On that path nothing writes the result before the call, so the
outcome for every task is unchanged.

CoreFacet goes from 21,957 to 21,857 bytes under the production profile;
its pinned bytecode hash is regenerated from a --release build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [#4989] Read the automation-enabled flag through one helper in CoreViewFacet

isAutomationEnabled and isAutomationReadyEnabled both report the flag
through a private automationEnabled helper, so the two views share one
definition of "automation is enabled". isAutomationEnabled stays external,
which keeps getSelectors listing it as CoreViewFacet.isAutomationEnabled.

The optimizer inlines the helper: CoreViewFacet's deployed bytecode is
unchanged under the production profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [#4989] State foundry.toml's size limits once, list hasActiveTaskOfType as node-relied, and match dropWithWholeDeposit's NatSpec to its callers

foundry.toml's production-profile comment states once which facets the
view splits keep under EIP-170's limit and the optimizer_runs values at
which CoreFacet and RegistryFacet go over it.

LibDiamond's list of selectors the node calls at runtime includes
RegistryViewFacet::hasActiveTaskOfType, which the node checks before each
automated transaction.

dropWithWholeDeposit's NatSpec covers both of its uses in dropOrChargeTask:
cancelled or expired tasks, and tasks the EVM gas configuration no longer
admits.

CoreFacet's header says a new external function belongs in another facet.

Deployed bytecode is unchanged for every contract under the production
profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Aregnaz Harutyunyan <>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…acity (#93)

* [#4920] Keep the registry's ordered task list bounded by the task capacity

monitorCycleEnd now compacts RegistryState.orderedTaskIds in every block
of a STARTED cycle whose end has not been reached: once at least a
quarter of the list is removed tasks it is rewritten to the ascending
live task IDs, and it is cleared when no task is live. The empty-registry
branches of a cycle end and of a suspension clear it as well, so every
cycle starts from the live list.

A task owner can cancel or stop a task from the block after its
registration; a removal in the registration block reverts with
TaskRemovalInRegistrationBlock. Removals by the registry owner and the
VM signer are unchanged. Together the two rules keep every scan of the
list below 7C/3 entries, C being taskCapacity + sysTaskCapacity.

At C = 200, monitorCycleEnd costs 14,972 gas in a block with no
compaction due, 1,887,464 for a compaction at the bound and 3,126,057
for a cycle end at the bound (MonitorCycleEndGas.t.sol churn tests). The
recommended selectorGasLimit for monitorCycleEnd at 200 tasks is now
4,000,000; the README, the gas guide and configs.rs state the new figures
and the capacity ceiling they imply. The CoreFacet genesis hash is
regenerated.

Tests: OrderedTaskIdsCompaction.t.sol covers the threshold, survivor
order, the empty-registry paths, transitions, per-block churn, a fuzzed
list invariant and the per-block registration bound; RegistryFacet.t.sol
covers the registration-block rule for UST, GST, batches and the registry
owner. Existing tests that removed a task in its registration block move
to the next block first; shared singleTask/uint64Array helpers live in
BaseDiamondTest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [#4920] Skip the cycle-end scan of an all-live task list and reuse the task's storage entry in the removal check

buildAliveOrderedTaskIds returns RegistryState.orderedTaskIds as stored
when its length equals the live task count: the list is strictly
ascending and holds every live ID, so a list of exactly the live count
holds no removed task, and the per-entry owner reads and the write-back
are not needed. A longer list is scanned as before.

cancelTask and stopTask pass the task's storage entry, already used for
toLW, to requireRegisteredBeforeThisBlock, so the mapping slot is not
derived again; registrationTime shares a slot with fields toLW reads.

Measured (MonitorCycleEndGas.t.sol, CycleTransitionGas.t.sol, before
refunds): monitorCycleEnd over 200 live tasks 1,372,245 (was 1,949,324),
over 400 tasks 2,624,455, disableAutomation about 1.40M; the cycle end at
the churn bound is unchanged at 3,126,085. An owner's cancel or stop
costs about 80-100 gas less per task. The gas guide's trigger rows and
grand totals, the configs.rs table and ceilings, and the README follow;
the boundary scan now fits 2,656 live tasks. CoreFacet and RegistryFacet
genesis hashes are regenerated.

Tests: a cycle end with no removal expects every registered task and
leaves the list as registered; a cycle end after removals kept below the
compaction threshold filters them out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [#4920] Refresh the automation registry gas guide from the current benchmarks

Re-runs CycleTransitionGas.t.sol (at 200 tasks, and at 400 for the
record sizes) and RegistrationGas.t.sol, and replaces every figure the
guide quotes from them: the six transition scenarios, the derived record
sizes, the record gas figure rationale and the registration tables. The
LibCommon NatSpec that justifies the record gas constants quotes the same
measurements and follows. The constants themselves still cover them:
the finalization premium is 8,782 per task at 400 tasks against 10,000,
and the costliest task 1,067,716 against 1,156,000.

The historical event-encoding comparison keeps its figures, now stated
as measured on that earlier code rather than tied to the current tables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [#4920] Refuse registration once the cycle end time is reached, and address the review of the ordered-task-list bound

- Registration reverts with the new CycleEndReached error from the
  current cycle's end time until monitorCycleEnd processes the end. The
  list then stays as it is after a monitorCycleEnd call that fails at
  the cycle end, and one successful call recovers
  (Entropy-Foundation/smr-moonshot#4920).
- TaskRemovalInRegistrationBlock's NatSpec says to retry in a block
  with a later timestamp, since block.timestamp is in whole seconds.
- compactOrderedTaskIdsIfSparse's NatSpec records why the compaction
  runs in monitorCycleEnd rather than in the owner removal paths or a
  separate prologue entry. The empty-registry branches of
  onCycleEndInternal and tryMoveToSuspendedState call it instead of
  deleting the list themselves.
- The cycle-end write-back of the compacted list is kept, with the
  measurement that justifies it at the call site: skipping it moves
  most of its cost into the final processTasks batch.
- OrderedTaskIdsCompaction.t.sol runs every block's prologue before its
  transactions, so the churn and fuzz tests remove earlier tasks after
  the prologue and register afterwards. New tests cover registration at
  the cycle end time.
- The gas guide, configs.rs, README and LibCommon NatSpec carry figures
  re-measured after the merge of the base branch. The gas guide says the
  churn tests' capacity constants have to be edited for another
  capacity. CoreFacet and RegistryFacet genesis hashes are regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Aregnaz Harutyunyan <>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…electors routable (#94)

Ownership of the automation registry Diamond now moves in two steps, as on
BlockMeta and MultisigBeacon: transferOwnership nominates a pending owner
(the zero address cancels the nomination) and the transfer completes when
that account calls acceptOwnership. Renouncing is not supported.
pendingOwner and acceptOwnership are declared in a new IOwnable2Step
interface, registered for ERC-165, so the IERC173 interface id stays the
standard 0x7f5828d0. DiamondStorage gains a pendingOwner field appended
after the existing ones.

A diamondCut Remove action naming an administration selector (diamondCut,
owner, transferOwnership, pendingOwner, acceptOwnership) reverts with
CannotRemoveProtectedFunction. A Replace action for them is accepted;
verifying the new facet is the owner's responsibility.

Genesis bytecode hashes are updated for Diamond, DiamondCutFacet,
DiamondInit and OwnershipFacet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in the fork PRs merged since the sync branch was cut at 271b6a4: #88, #91, #92, #93
and #94. The only conflict is the test module list in crates/ee-tests/src/lib.rs, which keeps
both sides. The new diamond_ownership tests build and pass against revm 43 unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ExecutionMode is a field-less enum, so it is Copy, and the .clone() calls on it are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merges upstream revm v120 (revm 43.0.3) into feature/revm-43-sync and ports the fork's changes to the upstream API. The spec stays OSAKA.
…cution, with no EIP-7623 floor

A transaction in an execution mode that charges no gas has no EIP-7623 calldata floor:
initial-gas validation treats EIP-7623 as disabled for it, so a gas limit that covers the
standard cost is accepted, and its result reports no floor.

Both run paths call post_execution in every mode. The refund cap applies to every mode, and
reimbursing the caller and rewarding the beneficiary are skipped when the transaction was
charged no fee, either because fee charging is disabled or because its execution mode charges
no gas. The inspector run path is upstream's again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onstructors

[#5005] Set the spec in the fork's tests with the setter that also sets the gas parameters
…est the new floor test covers

The documentation of ExecutionMode::charges_gas and of the fee helper states that the refund
cap applies to a transaction run through Handler::run, and that one run through
Handler::run_system_call skips post-execution and reports its uncapped refund.

The comment in the inspector's ReadOnly gas test states the current rule: validation sets
the floor of a mode that charges no gas to zero, so neither run path applies one.

gas_floor_is_not_reported_for_modes_that_charge_no_gas is removed; the assertions it made
are in gas_floor_does_not_limit_modes_that_charge_no_gas, at a gas limit below the floor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…asless-settlement

[#5002, #5004] Settle the gas of modes that charge no gas in post-execution, with no EIP-7623 floor
…ata transaction.

`BlockMetadata` gains `block_gas_limit` and `base_fee_per_gas` after
`gas_limit`, both serialized as quantities, and `BlockMetadataBuilder`
requires both.

The smr-moonshot executor reads the block's gas limit and base fee from
the block metadata transaction it executes. The transaction's hash covers
both fields. History segments export the transaction's body, so a
rebuild derives the archive's base fee and gas limit rows from it.

A test fixes the JSON and bincode forms of a fully populated transaction,
so that a dependency upgrade that changes its serde encoding shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pos check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d name the revm 43 sync by its issue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e, readable through accessors.

The fields of BlockMetadata, AutomatedTransaction and AutomationRegistryRecord
are private, so a transaction of each type is constructed by its builder or
deserialized. The gas limit, nonce, value, input, max fee per gas and access
list are read through the alloy Transaction impl. The types add read accessors
for the other fields that callers read:

- BlockMetadata: evm_chain_id, target, sender, height, block_hash, timestamp,
  block_gas_limit, base_fee_per_gas;
- AutomatedTransaction: block_height, sender, txn_type, predicate;
- AutomationRegistryRecord: evm_chain_id, target, sender, block_height.

evm_chain_id and target return the chain id and the call target that
Transaction::chain_id and Transaction::to report wrapped in Some.

The serialized forms are unchanged. The tests build their transactions with
the builders, except the record-decoding tests, whose malformed calldata no
builder produces; those build the record in the defining module's tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eir builders.

BlockMetadata and AutomationRegistryRecord no longer derive Default, so a
transaction of either type is constructed by its builder or deserialized.
Fields marked serde(default) keep that attribute, which needs only the
field type's Default.

AutomatedTransaction keeps its Default derive: AutomatedTransactionDetails,
which holds one, derives Default.

The test of BlockMetadata's Default is replaced by a test that a
transaction built from zero values carries the VM signer as its sender and
the blockPrologue() calldata. The record-decoding tests build their records
with every field set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ir builder.

AutomatedTransaction and AutomatedTransactionDetails no longer derive
Default, so an automated transaction is constructed by
AutomatedTransactionBuilder or deserialized. Fields marked serde(default)
keep that attribute, which needs only the field type's Default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…metadata-config

[#5246] Carry the block gas limit and the base fee in the block metadata transaction
…6795bba) into the revm 43 sync

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onst, as the sync's lint set requires

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Registry:
- withdrawFees is accepted while the cycle is STARTED or READY and reverts
  with the new IConfigFacet.CycleTransitionInProgress while a cycle
  transition is pending (FINISHED or SUSPENDED).
- NatSpec: a user task's priority is always its task index; only
  registerSystemTask applies _priority, and 0 selects the default.
- DiamondInit and LibCommon state that the gas-config precompile serves the
  published EVM gas parameters during genesis, and why DiamondInit does not
  depend on it.

Genesis generator (supra-extension):
- The configuration requires a positive cycle duration strictly below both
  task duration caps.
- The embedded Solidity bytecode is compiled from the project's
  foundry.toml alone: FOUNDRY_*/DAPP_* variables other than the allowed and
  bytecode-neutral ones are removed with a warning, and the global
  ~/.foundry/foundry.toml is not read. The build re-runs only for the
  variables that reach the compiler, and watches remappings.txt only when it
  exists, so an unchanged tree no longer re-runs the build script.

Operator scripts:
- Each governance action has digest(), and submit_governance_action.sh
  resumes a pending transaction only when the named action's digest equals
  the stored content hash.
- deploy_automation_registry.sh signs with a Foundry keystore account, has
  --help, reads .env as data (script/dotenv.sh) and resolves ETH_PASSWORD
  from the caller's directory.
- The scripts run under bash 3.2 and do not need realpath (macOS).

Tests: withdrawFees per cycle state, auxData total-length cap, system task
event trimming, fee multiplier exponent bound, AppStorage slot, Solidity
enum mirrors, GenesisTransaction fields, default fees, damaged-artifact
recompilation, Foundry configuration isolation, and the operator scripts
(run in CI against stub forge and cast).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… as foundry-config does

Review of #100:
- load_dotenv exports only the names the calling script documents and
  ignores any other name in .env with a message. GOV_TXN_INDEX and
  GOV_TXN_CONTENT_HASH are read from the environment only.
- The Foundry environment isolation matches names as foundry-config does
  (trimmed, prefix compared ignoring ASCII case), against allowed names
  too, and removes every variant of FOUNDRY_PROFILE before the build sets
  it.
- The stand-in home directory used while loading the Foundry configuration
  is a new directory with an unpredictable name, mode 0700, under OUT_DIR
  when set.
- Docs: the threading condition of load_project_config, what a relative
  ETH_PASSWORD is relative to, the operator-script test harness's
  environment, and the .env allow-list in the README.
- foundry_config_isolation builds on Unix only.
- CI runs the operator-script tests on macOS under /bin/bash 3.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[#4923] Fix the revm fork Low findings of the delta audit
…face (#101)

* [smr-moonshot#5381] Add crossingGasCost() to the EVM gas config interface.

The native-crossing precompile charges the epoch's crossingGasCost(), served by the gas-config
precompile as a third read. Add it to ISupraEvmGasConfig, LibEvmGasConfig, the Foundry mock and the
script stand-in (CHAIN_CROSSING_GAS_COST), and correct the Cost section of ISupraNativeCrossing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [smr-moonshot#5381] Default the crossing gas cost to the default v27 schedule's 3,188,432.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…the block-metadata transaction's gas limit (#99)

* [#5339] Bound BlockMeta.blockPrologue's own gas and cap the block prologue 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>

* [#5339] Execute every block-metadata transaction with DEFAULT_BLOCK_METADATA_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>

* [#5339] Run BlockMeta.blockPrologue at the largest cap under this fork'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>

* [#5339] Derive BlockMeta's budget checks and maxRegistrableGasLimit from 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>

* [#5339] Export the specs BlockMeta's prologue gas reserves were measured 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>

* [#5339] Budget BlockMeta's registrations against the block-metadata transaction'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>

* [#5339] State what BlockMeta's gas bound depends on: the node's limit 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>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… conditions on registered hooks, and monitorCycleEnd's measured capacity ceilings (#102)

* [#5366] Record the block-metadata gas limit's measured times, the conditions on registered hooks, and monitorCycleEnd's measured capacity ceilings

- DEFAULT_BLOCK_METADATA_GAS_LIMIT's doc records what a hook that spends
  the whole single-entry budget takes on mainnet-rpc-7: about 0.29 s
  when it computes or touches state it touches in every block, 0.76 s
  with the slowest precompile, 4.1 to 6.5 s when it reads state no
  recent block read; and that a 2 to 3 s slowdown per block while a
  misconfiguration is corrected is tolerated, so the limit stays 2^24.
- BlockMeta's header, register and updateExecutionOrder state the
  conditions on a registered hook: tested before registration, and its
  call reads only state the hook touches in every block. NatSpec only;
  the production deployed bytecode is unchanged.
- configs.rs and the gas guide replace the extrapolated ~1,070 with the
  measured ceilings for monitorCycleEnd as a BlockMeta entry registered
  with the whole single-entry budget: 1,056 at the scan bound and 2,528
  with only live tasks, and add its warm and cold execution times.

Entropy-Foundation/smr-moonshot#5366.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [#5366] State the hook time bound for any registered hook, and keep one execution time per registry shape in the gas guide

- DEFAULT_BLOCK_METADATA_GAS_LIMIT's doc states the bound for any hook
  that reads only state it touches in every block: at most about 0.76 s
  for the whole single-entry budget, whatever operations or precompiles
  it spends the gas on.
- The gas guide keeps monitorCycleEnd's execution time after a block
  that ran the same call, and drops the second column, whose method
  reopens the store and does not model a running or restarted node.

Entropy-Foundation/smr-moonshot#5366.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…es (#104)

Generate alloy `sol!` bindings for ISupraBlockTimestamp, ISupraRandomness,
ISupraNativeCrossing and ISupraEvmGasConfig from the JSON ABIs the build
script compiles, and export them as
`supra_contract_bindings::precompiles`, so the node that implements the
precompiles takes their selectors and event signatures from the Solidity
interfaces instead of its own transcription of them.

Tests pin every function selector, custom-error selector and event topic
to its `solc --hashes` value, the exact set each interface declares, the
indexed layout of each event and the return type of each entry point.

Co-authored-by: Aregnaz Harutyunyan <>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s bound functions

revm#101 added crossingGasCost() to ISupraEvmGasConfig on feature/evm_automation. The bindings
are generated from the compiled interface and include it; the binding test now lists it with its
selector and decodes its return value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge feature/evm_automation (revm#101) into feature/revm-43-sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.