reth icon indicating copy to clipboard operation
reth copied to clipboard

Add intrinsic gas check to txpool validator

Open mattsse opened this issue 2 years ago • 1 comments

Describe the feature

we're lacking an intrisic gas heck here:

https://github.com/paradigmxyz/reth/blob/1049202f0fbb3da4a57817c73d14a5ae56b58c75/crates/transaction-pool/src/validate.rs#L161-L165

revm initial gas: https://github.com/bluealloy/revm/blob/5ca4741d69c508f41fd1aae780f5dcdf6e5f34a6/crates/interpreter/src/gas/calc.rs#L333

TODO

  • add missing validation check

Additional context

ref https://github.com/ethereum/go-ethereum/blob/a8482127091edbcf3de4b515fd97ce904ac2acb8/core/txpool/validation.go#L97-L102

mattsse avatar Jun 19 '23 13:06 mattsse

fyi @tcoratger maybe this is interesting

mattsse avatar Jun 19 '23 22:06 mattsse

@mattsse I would like to work upon this as far as i understood we use Gas module from revm and the implementation will be something like this.

     // Calculate intrinsic gas
    let intrinsic_gas = initial_tx_gas(
        &transaction.data,
        transaction.to.is_none(),
        &transaction.access_list,
    );

    // Compare transaction gas with intrinsic gas
    if transaction.gas < intrinsic_gas {
        // Raise an error indicating insufficient gas
        return TransactionValidationOutcome::Err(core::ErrIntrinsicGas(format!(
            "needed {}, allowed {}",
            intrinsic_gas, transaction.gas
        )));
    }

Anything you would like to add.

startup-dreamer avatar Jun 23 '23 09:06 startup-dreamer

this looks right!

fyi: there's a pending PR that will introduce conflicts here #3358

mattsse avatar Jun 23 '23 16:06 mattsse

Ok I will wait till the branch is merged.

startup-dreamer avatar Jun 23 '23 18:06 startup-dreamer

This issue is stale because it has been open for 14 days with no activity.

github-actions[bot] avatar Jul 08 '23 02:07 github-actions[bot]

Still relevant

onbjerg avatar Jul 11 '23 00:07 onbjerg

@startup-dreamer are u working on this one?

supernovahs avatar Jul 17 '23 15:07 supernovahs

I don't think so, assigning you!

mattsse avatar Jul 17 '23 15:07 mattsse

Sorry for the delay(was in paris). The calc module is private in revm . So I can't import the initial_tx_gas function. https://github.com/bluealloy/revm/blob/5ca4741d69c508f41fd1aae780f5dcdf6e5f34a6/crates/interpreter/src/gas/calc.rs

Thx

supernovahs avatar Jul 26 '23 07:07 supernovahs

cc @mattsse

supernovahs avatar Jul 27 '23 07:07 supernovahs

calc is now public, but we are not using the latest commit of revm , hence I'll wait for it

supernovahs avatar Aug 03 '23 12:08 supernovahs

cool, thanks for this!

there'll be a new revm update within the next two weeks or so

mattsse avatar Aug 03 '23 12:08 mattsse

closing in favor of #4504

mattsse avatar Sep 15 '23 11:09 mattsse