Crate arb_precompiles

Crate arb_precompiles 

Source
Expand description

Arbitrum precompile contracts.

Implements the system contracts at addresses 0x64+ that provide on-chain access to ArbOS state, gas pricing, retryable tickets, Stylus WASM management, and node interface queries.

Re-exports§

pub use arbsys::ARBSYS_ADDRESS;
pub use arbsys::create_arbsys_precompile;

Modules§

arbsys

Enums§

ArbPrecompileError
Errors raised by Arbitrum precompiles.

Constants§

ARBADDRESSTABLE_ADDRESS
ArbAddressTable precompile address (0x66).
ARBAGGREGATOR_ADDRESS
ArbAggregator precompile address (0x6d).
ARBBLS_ADDRESS
ArbBLS precompile address (0x67).
ARBDEBUG_ADDRESS
ArbDebug precompile address (0xff).
ARBFILTEREDTXMANAGER_ADDRESS
ArbFilteredTransactionsManager precompile address (0x74).
ARBFUNCTIONTABLE_ADDRESS
ArbFunctionTable precompile address (0x68).
ARBGASINFO_ADDRESS
ArbGasInfo precompile address (0x6c).
ARBINFO_ADDRESS
ArbInfo precompile address (0x65).
ARBNATIVETOKENMANAGER_ADDRESS
ArbNativeTokenManager precompile address (0x73).
ARBOSACTS_ADDRESS
ArbosActs precompile address (0xa4b05).
ARBOSTEST_ADDRESS
ArbosTest precompile address (0x69). Burns arbitrary amounts of L2 gas.
ARBOWNERPUBLIC_ADDRESS
ArbOwnerPublic precompile address (0x6b).
ARBOWNER_ADDRESS
ArbOwner precompile address (0x70).
ARBRETRYABLETX_ADDRESS
ArbRetryableTx precompile address (0x6e).
ARBSTATISTICS_ADDRESS
ArbStatistics precompile address (0x6f).
ARBWASMCACHE_ADDRESS
ArbWasmCache precompile address (0x72).
ARBWASM_ADDRESS
ArbWasm precompile address (0x71).
NODE_INTERFACE_ADDRESS
NodeInterface virtual contract address (0xc8).
NODE_INTERFACE_DEBUG_ADDRESS
NodeInterfaceDebug virtual contract address (0xc9).
P256VERIFY_ADDRESS
RIP-7212 P256VERIFY precompile address (ArbOS v30+).

Functions§

build_fake_tx_bytes
Build the EIP-2718 envelope of a fake EIP-1559 tx used to size the calldata payload for gas estimation (hard-coded random nonce/tip/feeCap/gas/sig fields).
charge_computation
Charge precompile gas attributed to pure computation: constant per-method work, the framework resultCost for encoding return data, and any other non-resource-bound costs. Mirrors the reference framework’s Burn(Computation, ...) calls.
charge_history_growth
Charge precompile gas for emitting a log, recording it as HistoryGrowth.
charge_l2_calldata
Charge precompile gas for calldata processing (the framework argsCost and any per-call copy fees on caller-supplied data), recording it as L2Calldata. The single-gas total is unchanged; only the resource breakdown is recorded.
charge_params_read
Charge the warm StylusParams read. The params slot is read frequently and billed to Computation, not as a storage read; centralized so every reader attributes it to the same resource.
charge_precompile_gas
charge_storage_read
Charge precompile gas for an ArbOS state read, recording it as StorageAccessRead for the v60 multi-dimensional pricing backlog (mirrors the reference, which dimensions every state Get as a storage read). The single-gas total is unchanged; only the resource breakdown is recorded.
charge_storage_write
Charge precompile gas for an ArbOS state write, recording it as StorageAccessWrite. See charge_storage_read.
compute_l1_gas_for_estimate
L1 gas estimate: brotli-compress a fake EIP-1559 tx, pad units by (units + 256) * 1.01, multiply by pricePerUnit, pad posterCost by 1.10, then divide by max(basefee * 7/8, minBaseFee).
create_arbaddresstable_precompile
create_arbaggregator_precompile
create_arbbls_precompile
create_arbdebug_precompile
create_arbfilteredtxmanager_precompile
create_arbfunctiontable_precompile
create_arbgasinfo_precompile
create_arbinfo_precompile
create_arbnativetokenmanager_precompile
create_arbosacts_precompile
create_arbostest_precompile
create_arbowner_precompile
create_arbownerpublic_precompile
create_arbretryabletx_precompile
create_arbstatistics_precompile
create_arbwasm_precompile
create_arbwasmcache_precompile
create_nodeinterface_debug_precompile
create_nodeinterface_precompile
decode_estimate_args
Decode gasEstimateComponents(address,bool,bytes) calldata into (to, contractCreation, data).
init_precompile_gas
Initialize gas tracking for a precompile call: charge argsCost as L2Calldata and the OpenArbosState read (1 SLOAD = 800) as StorageAccessRead, mirroring the reference framework’s per-call dimensioned framework gas.
init_precompile_gas_pure
Initialize gas tracking for a pure precompile method: like init_precompile_gas but skips the OpenArbosState SLOAD, matching the reference framework’s pure-method path which does not open ArbOS state.
redeem_scheduled_topic
register_arb_precompiles
Registers Arbitrum precompiles into map and applies the per-ArbOS-version adjustments to the standard Ethereum precompile set.
reject_delegate_nonpure
Reject a non-pure method invoked via DELEGATECALL, reverting and consuming all forwarded gas. is_delegate is true when acting as an address other than the precompile; pure lists the stateless selectors.
reject_nonpayable_value
Reject call value sent to a non-payable method, reverting and consuming all forwarded gas. payable lists the selectors that may receive value. Call only once the precompile is active for the current ArbOS version.
reject_static_unless_read
Like reject_static_write but for a mostly-writing precompile: under read-only, reject every method except the listed read-only (view/pure) selectors.
reject_static_write
Reject a state-modifying method invoked under STATICCALL, reverting and consuming all forwarded gas. write lists the state-modifying selectors.
sol_error_revert
Emit a pre-encoded Solidity custom-error payload (selector + ABI args) as a revert. Adds the copy cost for the payload to the accumulated gas, attributed to Computation to mirror the reference framework’s resultCost burn.
ticket_created_topic