Repository navigation
Conversation
…lidate_env (M-M04) - Compute the exact ETH-space budget `floor(limit_token * price_ratio / scale)` in `U512` inside `gas_allowance_from_token_limit` (avoiding double-rounding the L1 fee in token space on tight 6-decimal token limits) and return `Ok(0)` rather than `InsufficientFundsForL1Fee` when `l1_fee == 0 && limit == 0`. - Switch `caller_gas_allowance_with_token` to `TokenRegistryEntry::load` + `ensure_usable` + `load_for_caller` using the block's `MorphEvmEnv` so call-mode tokens resolve `balanceOf(caller)` and cap by `min(balance, fee_limit)`, reject inactive/zero-config tokens before spinning up an EVM, propagate DB errors as `MorphEthApiError::Eth`, and normalize `gas_cap == 0` to `u64::MAX`. - Align `MorphEvmHandler::validate_env` MorphTx fee-cap validation with upstream revm's EIP-1559 branch (`is_base_fee_check_disabled()` and `is_priority_fee_check_disabled()`, independent of `is_fee_charge_disabled()`).
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
# Conflicts: # crates/rpc/src/eth/call.rs
…l.rs tests - Inline the single-caller MorphEthApi::caller_gas_allowance_with_token pass-through directly to load_caller_token_gas_allowance. - Simplify U512 clamping in token_amount_to_eth via saturating_to::<U256>(). - Factor repetitive load_caller_token_gas_allowance test invocations through local closures.
# Conflicts: # crates/rpc/src/eth/call.rs
…dit items - Sync finalized semantics of PRs #237, #238, #239, #240, #241, #244, #247, #248, and #249 natively on reth v2.11.0 + evm2: - Proofs ExEx revert retry state machine, zeroed-slot storage pruning, and Reference Index batch parent linkage & async RPC polling - Safe validation exemptions (is_safe + safe_blocks FIFO), tree_headers cache, pre/post-Jade next_l1_msg_index & unhashed header checks, synchronized pool eviction, and no_tx_pool forward skip - Delegate eth_simulateV1 to upstream with 65B placeholder-sig Curie L1 fee encoding (validation:true), zero L1 fee (validation:false), and normalize_simulate_call - Enforce --rpc.gascap (0 = unlimited) across eth_call/eth_callMany/eth_estimateGas and honor blockOverrides.gasLimit above header gas_limit ([MR-10], [MR-12]) - Close unfixed audit items: - [MR-03]: Reload live (token_address, balance_slot) from L2TokenRegistry during post-execution token fee reimbursement while keeping deduction-time rates - [MR-14]: Rewind orphaned safe block tag to canonical finalized (or genesis) on engine_newL2BlockV2 reorgs and warm BlockTagTracker on startup - TxPool Option A: Enforce U256 price bump uniformly on priority_fee_or_price() across Legacy and dynamic-fee replacements - Restore SP1 zkVM quanta-free dependency graph on morph-revm and morph-evm - Bump workspace version to 2.0.0, resolve RUSTSEC advisories, and clear CodeQL test false positives
Summary
Fixes M-M04 as a standalone PR targeting
main:Changes (
crates/rpc/src/eth/call.rs,crates/revm/src/{handler.rs,token_fee.rs},crates/revm/Cargo.toml)gas_allowance_from_token_limit(crates/rpc/src/eth/call.rs):max_eth = floor(limit_token * price_ratio / scale)inU512(saturating toU256::MAXviasaturating_to::<U256>()) — the exact mathematical inverse ofceil((l2_fee + l1_fee) * scale / price_ratio) <= limit_token— eliminating L1-fee double-rounding that previously caused falseInsufficientFundsForL1Feerejections on tight 6-decimal USDT/USDC limits.InsufficientFundsForL1Feewhenmax_eth < l1_feeor when a non-zero L1 fee leaves zero ETH for L2 execution gas, while returningOk(0)(oru64::MAXwhengas_price == 0) onl1_fee == 0 && limit == 0.balanceOf(caller)resolution & clean error handling (crates/rpc/src/eth/call.rs,crates/revm/src/token_fee.rs):TokenRegistryEntry::ensure_usablepub.Call::caller_gas_allowancedirectly toload_caller_token_gas_allowance:TokenRegistryEntry::load->ensure_usable->eth_balance < valuecheck ->entry.load_for_caller(using the block'sMorphEvmEnvviaEthApiDbAdapter), so call-mode tokens resolve realbalanceOf(caller)and cap byeffective_fee_limit, matchingmorph-geth'sDoEstimateGas.price_ratio/ zero-scaletokens fail fast withInvalidFeeTokenbefore invoking call-mode EVM execution.balanceOfpropagate asMorphEthApiError::Ethinstead of being swallowed asInvalidFeeToken.gas_cap == 0(unlimited) tou64::MAXwhile retaining themin(effective_gas_cap)bound in call mode.validate_envwith upstreamrevm(crates/revm/src/handler.rs,crates/revm/Cargo.toml):MorphEvmHandler::validate_envto gate base-fee checks oncfg.is_base_fee_check_disabled()and priority-fee checks oncfg.is_priority_fee_check_disabled(), independent ofcfg.is_fee_charge_disabled().optional_no_base_feeandoptional_priority_fee_checkincrates/revm/Cargo.toml[dev-dependencies]only for standalonecargo test -p morph-revm.Verification
cargo fmt --all -- --check: passedcargo clippy -p morph-revm -p morph-rpc -p morph-node --all-targets -- -D warnings: passed (0 warnings)cargo clippy -p morph-node --features test-utils --all-targets -- -D warnings: passed (0 warnings)cargo test -p morph-revm --lib: 145 passedcargo test -p morph-rpc --lib: 132 passedcargo test -p morph-node --features test-utils --test it -- rpc --test-threads=4: 27 passed