Skip to content

feat(generator): support fuzzing max_priority_fee_per_gas#580

Open
op-will wants to merge 3 commits into
flashbots:mainfrom
op-will:addPriorityFeeFuzzing
Open

feat(generator): support fuzzing max_priority_fee_per_gas#580
op-will wants to merge 3 commits into
flashbots:mainfrom
op-will:addPriorityFeeFuzzing

Conversation

@op-will
Copy link
Copy Markdown

@op-will op-will commented May 9, 2026

Motivation

The generator currently lets you fuzz function-call arguments and the tx value, but there is no way to set or fuzz max_priority_fee_per_gas per tx — every tx falls back to the global gas_price / 10 default.

Solution

  • FunctionCallDefinition::max_priority_fee_per_gas: Option<String> — new field on the user-facing scenario definition, plumbed through FunctionCallDefinitionStrict and the templater so it lands on the TransactionRequest. Accepts raw wei, hex ("0x..."), or unit strings ("10 gwei", "0.001 eth") via the shared parse_value / deserialize_value_opt helpers. Misparses surface as a new TemplaterError::ParsePriorityFeeFailed at scenario load time rather than silently becoming None.
  • FuzzParam::max_priority_fee_per_gas: Option<bool> — a flag that mirrors the existing FuzzParam::value flag, opting the priority-fee field into fuzzing for that entry. Mutually exclusive with param and value; the conflict is caught at scenario load time in parse_map_key. FuzzParam::min and FuzzParam::max also accept the same wei/hex/unit-string forms.
  • TestScenario now honors a per-tx priority fee if one is set (statically or via the fuzz path), falling back to the existing gas_price / 10 default otherwise.
  • complete_tx_request raises max_fee_per_gas to match max_priority_fee_per_gas when the priority fee exceeds the sampled cap, preserving the max_fee_per_gas >= max_priority_fee_per_gas invariant. Without this, a high fuzzed tip on a low-fee chain would produce an invalid tx.
  • Gas estimation lifts max_fee_per_gas to the priority fee on its working copy when a priority fee is set, since estimate_gas enforces the same EIP-1559 invariant and runs before complete_tx_request applies the real fee cap.

Example

[spam.tx]
to = "{SpamMe2}"
from_pool = "redpool"
signature = "consumeGas(uint256 gasAmount)"
args = ["3000000"]
fuzz = [
    { param = "gasAmount", min = "1000000", max = "3000000" },
    { max_priority_fee_per_gas = true, min = "10 gwei", max = "20 gwei" },
]

Or pin a static priority fee:

max_priority_fee_per_gas = "10 gwei"   # also accepts "10000000000" or "0x2540be400"

See docs/creating_scenarios.md for the full documentation.

Breaking changes

Minor breaking change for downstream library users that construct FuzzParam or FunctionCallDefinitionStrict via struct literal:

  • FuzzParam gains a max_priority_fee_per_gas: Option<bool> field.
  • FunctionCallDefinitionStrict gains a max_priority_fee_per_gas: Option<String> field.

FunctionCallDefinition is unaffected for builder-style users (FunctionCallDefinition::new(..).with_*(..)); the new field has a default in the builder constructor.

New error variant TemplaterError::ParsePriorityFeeFailed — additive for match arms that already use a wildcard, breaking for exhaustive matches against TemplaterError.

Tests

  • function_def.rs: parses static max_priority_fee_per_gas, parses the fuzz flag, confirms the param+max_priority_fee_per_gas combination parses (so the runtime check in parse_map_key has a chance to run), and the format tests sweep all accepted literal forms (decimal wei, hex, unit strings).
  • trait.rs: parse_map_key routes param/value/max_priority_fee_per_gas to the correct fuzz-map keys and rejects every conflicting combination.
  • templater.rs: covers the static priority-fee parse path across all literal forms, placeholder resolution into a unit string, and the malformed-input error surfacing as ParsePriorityFeeFailed.
  • util.rs: complete_tx_request uses gas_price when the priority fee is lower, raises max_fee_per_gas when it's higher, handles the equal case, and the Eip4844 path inherits the same invariant.
  • test_scenario.rs: end-to-end test asserting the EIP-1559 invariant holds through gas estimation when a spam tx sets max_priority_fee_per_gas above the chain's gas price.

PR Checklist

  • Added Tests
  • Added Documentation (docs/creating_scenarios.md)
  • Ran cargo +nightly clippy --workspace --lib --examples --tests --benches --all-features --locked (-D warnings clean)
  • Ran cargo +nightly fmt --all
  • Note breaking changes in PR description, if applicable — see "Breaking changes" above
  • crates/core/CHANGELOG.md updated under ## [Unreleased]

@op-will op-will force-pushed the addPriorityFeeFuzzing branch from c4aa6b6 to ce92122 Compare May 9, 2026 14:36
@op-will op-will marked this pull request as ready for review May 9, 2026 14:41
@op-will op-will requested a review from zeroXbrock as a code owner May 9, 2026 14:41
Copy link
Copy Markdown
Member

@zeroXbrock zeroXbrock left a comment

Choose a reason for hiding this comment

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

This is a good idea, and this code is a good start, but the feature doesn't really work without being able to set max_fee_per_gas as well. If max_priority_fee_per_gas > max_fee_per_gas, the tx won't (shouldn't) be accepted by the RPC, and it'll cause a fatal error in contender.

We could just adjust max_fee_per_gas when max_priority_fee_per_gas is set, so that this condition is guaranteed not to occur.

Also, sort of unrelated, but would be nice to be able to use strings "10 gwei" in the fuzz args for gas params. Hex and decimal integers (representing wei) should also be supported, but the UX would be much better with human-readable gas params. We have a function contender_core::generator::util::parse_value that can handle this.

@op-will
Copy link
Copy Markdown
Author

op-will commented May 12, 2026

@zeroXbrock thank you for reviewing!

We could just adjust max_fee_per_gas when max_priority_fee_per_gas is set, so that this condition is guaranteed not to occur.

This is exactly the approach that the code takes, no?

From the PR description:

complete_tx_request raises max_fee_per_gas to match
max_priority_fee_per_gas when the priority fee exceeds the sampled
cap, preserving the max_fee_per_gas >= max_priority_fee_per_gas
invariant. Without this, a high fuzzed tip on a low-fee chain would
produce an invalid tx.

contender/crates/core/src/generator/util.rs updates:

            // EIP-1559 requires max_fee_per_gas >= max_priority_fee_per_gas.
            // If a fuzzed/explicit priority fee is higher than the sampled
            // base+tip cap, raise the cap to keep the tx well-formed.
            let max_fee = gas_price.max(priority_fee);
            tx_req.max_fee_per_gas = Some(max_fee);

Also, sort of unrelated, but would be nice to be able to use strings "10 gwei" in the fuzz args for gas params. Hex and decimal integers (representing wei) should also be supported, but the UX would be much better with human-readable gas params. We have a function contender_core::generator::util::parse_value that can handle this.

Will update!

@zeroXbrock
Copy link
Copy Markdown
Member

@op-will odd, that looks right, but I'm getting this error when trying to test it locally:

Error:   × core error
  ├─▶ rpc error
  ╰─▶ server returned an error response: error code -32602: Invalid input: `max_priority_fee_per_gas` greater than `max_fee_per_gas`

This is the scenario file I'm using to test:

[[create]]
name = "SpamMe5"
# source: https://github.com/zeroXbrock/high-volume-contract/blob/main/src/SpamMe.sol
bytecode = "0x608060405234801561000f575f5ffd5b5060405180602001604052805f8152505f908161002c91906102c9565b5060405160200161003c906103ec565b604051602081830303815290604052805190602001205f1c6001819055506040516020016100699061044a565b604051602081830303815290604052600290816100869190610468565b50610537565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061010757607f821691505b60208210810361011a576101196100c3565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f6008830261017c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610141565b6101868683610141565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f6101ca6101c56101c08461019e565b6101a7565b61019e565b9050919050565b5f819050919050565b6101e3836101b0565b6101f76101ef826101d1565b84845461014d565b825550505050565b5f5f905090565b61020e6101ff565b6102198184846101da565b505050565b5b8181101561023c576102315f82610206565b60018101905061021f565b5050565b601f8211156102815761025281610120565b61025b84610132565b8101602085101561026a578190505b61027e61027685610132565b83018261021e565b50505b505050565b5f82821c905092915050565b5f6102a15f1984600802610286565b1980831691505092915050565b5f6102b98383610292565b9150826002028217905092915050565b6102d28261008c565b67ffffffffffffffff8111156102eb576102ea610096565b5b6102f582546100f0565b610300828285610240565b5f60209050601f831160018114610331575f841561031f578287015190505b61032985826102ae565b865550610390565b601f19841661033f86610120565b5f5b8281101561036657848901518255600182019150602085019450602081019050610341565b86831015610383578489015161037f601f891682610292565b8355505b6001600288020188555050505b505050505050565b5f81905092915050565b7f666f757274792d74776f000000000000000000000000000000000000000000005f82015250565b5f6103d6600a83610398565b91506103e1826103a2565b600a82019050919050565b5f6103f6826103ca565b9150819050919050565b7f48656c6c6f2c20576f726c6421000000000000000000000000000000000000005f82015250565b5f610434600d83610398565b915061043f82610400565b600d82019050919050565b5f61045482610428565b9150819050919050565b5f81519050919050565b6104718261045e565b67ffffffffffffffff81111561048a57610489610096565b5b61049482546100f0565b61049f828285610240565b5f60209050601f8311600181146104d0575f84156104be578287015190505b6104c885826102ae565b86555061052f565b601f1984166104de86610120565b5f5b82811015610505578489015182556001820191506020850194506020810190506104e0565b86831015610522578489015161051e601f891682610292565b8355505b6001600288020188555050505b505050505050565b612ddf806105445f395ff3fe60806040526004361061007a575f3560e01c8063a329e8de1161004d578063a329e8de1461010c578063c5eeaf1714610134578063e30709d01461013e578063fb0e722b146101545761007a565b806369f86ec81461007e5780637ad42e50146100945780638199ba20146100bc5780639402c004146100e4575b5f5ffd5b348015610089575f5ffd5b5061009261017e565b005b34801561009f575f5ffd5b506100ba60048036038101906100b59190611baa565b610189565b005b3480156100c7575f5ffd5b506100e260048036038101906100dd9190611baa565b610878565b005b3480156100ef575f5ffd5b5061010a60048036038101906101059190611ca2565b610e00565b005b348015610117575f5ffd5b50610132600480360381019061012d9190611ce9565b610e33565b005b61013c610ec0565b005b348015610149575f5ffd5b50610152610f06565b005b34801561015f575f5ffd5b50610168610f7a565b6040516101759190611d74565b60405180910390f35b5b60325a1161017f57565b6101d16040518060400160405280600b81526020017f686173685f7368613235360000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610202575f5f90505b818110156101fc576101ee60015461105d565b5080806001019150506101db565b50610874565b61024a6040518060400160405280600e81526020017f686173685f726970656d643136300000000000000000000000000000000000008152508361100590919063ffffffff16565b1561027b575f5f90505b8181101561027557610267600154611144565b508080600101915050610254565b50610873565b6102c36040518060400160405280600881526020017f6964656e746974790000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b1561037a575f5f90505b8181101561037457610366600280546102e590611dc1565b80601f016020809104026020016040519081016040528092919081815260200182805461031190611dc1565b801561035c5780601f106103335761010080835404028352916020019161035c565b820191905f5260205f20905b81548152906001019060200180831161033f57829003601f168201915b505050505061122f565b5080806001019150506102cd565b50610872565b6103c26040518060400160405280600681526020017f6d6f6465787000000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b156103f6575f5f90505b818110156103f0576103e2600a6004600e611304565b5080806001019150506103cc565b50610871565b61043e6040518060400160405280600581526020017f65634164640000000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610473575f5f90505b8181101561046d5761045e600160025f5f6113f9565b50508080600101915050610448565b50610870565b6104bb6040518060400160405280600581526020017f65634d756c0000000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b156104f0575f5f90505b818110156104ea576104db6001600260016114f6565b505080806001019150506104c5565b5061086f565b6105386040518060400160405280600981526020017f656350616972696e6700000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610582575f5f90505b8181101561057c5761056e604051806101a001604052806101808152602001612c2a61018091396115f0565b508080600101915050610542565b5061086e565b6105ca6040518060400160405280600781526020017f626c616b653266000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b156105f7576105f160405180610100016040528060d58152602001612b5560d591396116c8565b5061086d565b61063f6040518060400160405280600b81526020017f626c616b6532665f616c740000000000000000000000000000000000000000008152508361100590919063ffffffff16565b1561086c575f600c90506106516119c4565b7f48c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa55f1b815f6002811061068757610686611df1565b5b6020020181815250507fd182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b5f1b816001600281106106c7576106c6611df1565b5b6020020181815250506106d86119e6565b7f61626300000000000000000000000000000000000000000000000000000000005f1b815f6004811061070e5761070d611df1565b5b6020020181815250505f5f1b8160016004811061072e5761072d611df1565b5b6020020181815250505f5f1b8160026004811061074e5761074d611df1565b5b6020020181815250505f5f1b8160036004811061076e5761076d611df1565b5b60200201818152505061077f611a08565b67030000000000000060c01b815f6002811061079e5761079d611df1565b5b602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250505f60c01b816001600281106107f7576107f6611df1565b5b602002019077ffffffffffffffffffffffffffffffffffffffffffffffff1916908177ffffffffffffffffffffffffffffffffffffffffffffffff1916815250505f600190505f5f90505b868110156108655761085786868686866117c2565b508080600101915050610842565b5050505050505b5b5b5b5b5b5b5b5b5050565b6108c06040518060400160405280600681526020017f7373746f726500000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b156108ed575f5f90505b818110156108e7576108da6118e8565b80806001019150506108ca565b50610dfc565b6109356040518060400160405280600581526020017f736c6f61640000000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610962575f5f90505b8181101561095c5761094f6118ed565b808060010191505061093f565b50610dfb565b6109aa6040518060400160405280600681526020017f6d73746f726500000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b156109d7575f5f90505b818110156109d1576109c46118ef565b80806001019150506109b4565b50610dfa565b610a1f6040518060400160405280600581526020017f6d6c6f61640000000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610a4c575f5f90505b81811015610a4657610a396118f4565b8080600101915050610a29565b50610df9565b610a946040518060400160405280600381526020017f61646400000000000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610ac1575f5f90505b81811015610abb57610aae6118f9565b8080600101915050610a9e565b50610df8565b610b096040518060400160405280600381526020017f73756200000000000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610b36575f5f90505b81811015610b3057610b236118fb565b8080600101915050610b13565b50610df7565b610b7e6040518060400160405280600381526020017f6d756c00000000000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610bab575f5f90505b81811015610ba557610b986118fd565b8080600101915050610b88565b50610df6565b610bf36040518060400160405280600381526020017f64697600000000000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610c20575f5f90505b81811015610c1a57610c0d6118ff565b8080600101915050610bfd565b50610df5565b610c686040518060400160405280600981526020017f65637265636f76657200000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610c96575f5f90505b81811015610c9057610c82611901565b508080600101915050610c72565b50610df4565b610cde6040518060400160405280600981526020017f6b656363616b32353600000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610d0b575f5f90505b81811015610d0557610cf86119b4565b8080600101915050610ce8565b50610df3565b610d536040518060400160405280600781526020017f62616c616e6365000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610d80575f5f90505b81811015610d7a57610d6d6119bb565b8080600101915050610d5d565b50610df2565b610dc86040518060400160405280600681526020017f63616c6c657200000000000000000000000000000000000000000000000000008152508361100590919063ffffffff16565b15610df1575f5f90505b81811015610def57610de26119c2565b8080600101915050610dd2565b505b5b5b5b5b5b5b5b5b5b5b5b5050565b5f81604051602001610e13929190611eea565b6040516020818303038152906040525f9081610e2f919061209b565b5050565b5f8111610e75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6c906121c4565b60405180910390fd5b5f6095610a2883610e86919061220f565b610e90919061226f565b90505f8103610e9e57600190505b5f5f90505b81811015610ebb575f5f558080600101915050610ea3565b505050565b4173ffffffffffffffffffffffffffffffffffffffff166108fc3490811502906040515f60405180830381858888f19350505050158015610f03573d5f5f3e3d5ffd5b50565b5f600242610f14919061229f565b14610f54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4b9061233f565b60405180910390fd5b5f5f90505b6064811015610f7757610f6a6118f4565b8080600101915050610f59565b50565b5f8054610f8690611dc1565b80601f0160208091040260200160405190810160405280929190818152602001828054610fb290611dc1565b8015610ffd5780601f10610fd457610100808354040283529160200191610ffd565b820191905f5260205f20905b815481529060010190602001808311610fe057829003601f168201915b505050505081565b5f8160405160200161101791906123a1565b604051602081830303815290604052805190602001208360405160200161103e91906123a1565b6040516020818303038152906040528051906020012014905092915050565b5f5f5f600273ffffffffffffffffffffffffffffffffffffffff168460405160200161108991906123c6565b6040516020818303038152906040526040516110a591906123df565b5f60405180830381855afa9150503d805f81146110dd576040519150601f19603f3d011682016040523d82523d5f602084013e6110e2565b606091505b509150915081611127576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111e9061243f565b60405180910390fd5b8080602001905181019061113b9190612490565b92505050919050565b5f5f5f600373ffffffffffffffffffffffffffffffffffffffff168460405160200161117091906123c6565b60405160208183030381529060405260405161118c91906123df565b5f60405180830381855afa9150503d805f81146111c4576040519150601f19603f3d011682016040523d82523d5f602084013e6111c9565b606091505b50915091508161120e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112059061243f565b60405180910390fd5b6060818060200190518101906112249190612490565b901b92505050919050565b60605f5f600473ffffffffffffffffffffffffffffffffffffffff168460405160200161125c9190611d74565b60405160208183030381529060405260405161127891906123df565b5f60405180830381855afa9150503d805f81146112b0576040519150601f19603f3d011682016040523d82523d5f602084013e6112b5565b606091505b5091509150816112fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f19061243f565b60405180910390fd5b8092505050919050565b5f5f5f600573ffffffffffffffffffffffffffffffffffffffff16602080602089898960405160200161133c96959493929190612500565b60405160208183030381529060405260405161135891906123df565b5f60405180830381855afa9150503d805f8114611390576040519150601f19603f3d011682016040523d82523d5f602084013e611395565b606091505b5091509150816113da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d19061243f565b60405180910390fd5b808060200190518101906113ee9190612573565b925050509392505050565b5f5f5f8686868660405160200161141394939291906125be565b60405160208183030381529060405290505f5f600673ffffffffffffffffffffffffffffffffffffffff168360405161144c91906123df565b5f60405180830381855afa9150503d805f8114611484576040519150601f19603f3d011682016040523d82523d5f602084013e611489565b606091505b5091509150816114ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c590612655565b60405180910390fd5b808060200190518101906114e29190612673565b809550819650505050505094509492505050565b5f5f5f85858560405160200161150e939291906126b1565b60405160208183030381529060405290505f5f600773ffffffffffffffffffffffffffffffffffffffff168360405161154791906123df565b5f60405180830381855afa9150503d805f811461157f576040519150601f19603f3d011682016040523d82523d5f602084013e611584565b606091505b5091509150816115c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c09061275d565b60405180910390fd5b808060200190518101906115dd9190612673565b8095508196505050505050935093915050565b5f5f5f600873ffffffffffffffffffffffffffffffffffffffff168460405161161991906123df565b5f60405180830381855afa9150503d805f8114611651576040519150601f19603f3d011682016040523d82523d5f602084013e611656565b606091505b50915091508161169b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116929061243f565b60405180910390fd5b602081511480156116bf57505f818060200190518101906116bc9190612573565b14155b92505050919050565b606060d582511461170e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611705906127eb565b60405180910390fd5b5f5f600973ffffffffffffffffffffffffffffffffffffffff168460405161173691906123df565b5f60405180830381855afa9150503d805f811461176e576040519150601f19603f3d011682016040523d82523d5f602084013e611773565b606091505b5091509150816117b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117af90612853565b60405180910390fd5b8092505050919050565b6117ca6119c4565b6117d26119c4565b5f87875f600281106117e7576117e6611df1565b5b602002015188600160028110611800576117ff611df1565b5b6020020151885f6004811061181857611817611df1565b5b60200201518960016004811061183157611830611df1565b5b60200201518a60026004811061184a57611849611df1565b5b60200201518b60036004811061186357611862611df1565b5b60200201518b5f6002811061187b5761187a611df1565b5b60200201518c60016002811061189457611893611df1565b5b60200201518c6040516020016118b39a9998979695949392919061296f565b604051602081830303815290604052905060408260d56020840160095f19fa6118da575f5ffd5b819250505095945050505050565b5f5f55565b565b5f5f52565b5f5150565b565b565b565b565b5f60017f84b9e10435e0bc5ea883d65dcc978b7d415228d21e4617775048722ef01a97e7601c7f7f05b09e99332068f90b5aa7233b53b9191ced11229aafe97f1a8d6e52af5dc57f049979df9965db093de9cac6c4224bd5bce586510fae94edcc513f12328b06856040515f81526020016040526040516119859493929190612b11565b6020604051602081039080840390855afa1580156119a5573d5f5f3e3d5ffd5b50505060206040510351905090565b60205f2050565b5f33905050565b565b6040518060400160405280600290602082028036833780820191505090505090565b6040518060800160405280600490602082028036833780820191505090505090565b6040518060400160405280600290602082028036833780820191505090505090565b5f604051905090565b5f5ffd5b5f5ffd5b5f5ffd5b5f5ffd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b611a8982611a43565b810181811067ffffffffffffffff82111715611aa857611aa7611a53565b5b80604052505050565b5f611aba611a2a565b9050611ac68282611a80565b919050565b5f67ffffffffffffffff821115611ae557611ae4611a53565b5b611aee82611a43565b9050602081019050919050565b828183375f83830152505050565b5f611b1b611b1684611acb565b611ab1565b905082815260208101848484011115611b3757611b36611a3f565b5b611b42848285611afb565b509392505050565b5f82601f830112611b5e57611b5d611a3b565b5b8135611b6e848260208601611b09565b91505092915050565b5f819050919050565b611b8981611b77565b8114611b93575f5ffd5b50565b5f81359050611ba481611b80565b92915050565b5f5f60408385031215611bc057611bbf611a33565b5b5f83013567ffffffffffffffff811115611bdd57611bdc611a37565b5b611be985828601611b4a565b9250506020611bfa85828601611b96565b9150509250929050565b5f67ffffffffffffffff821115611c1e57611c1d611a53565b5b611c2782611a43565b9050602081019050919050565b5f611c46611c4184611c04565b611ab1565b905082815260208101848484011115611c6257611c61611a3f565b5b611c6d848285611afb565b509392505050565b5f82601f830112611c8957611c88611a3b565b5b8135611c99848260208601611c34565b91505092915050565b5f60208284031215611cb757611cb6611a33565b5b5f82013567ffffffffffffffff811115611cd457611cd3611a37565b5b611ce084828501611c75565b91505092915050565b5f60208284031215611cfe57611cfd611a33565b5b5f611d0b84828501611b96565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f611d4682611d14565b611d508185611d1e565b9350611d60818560208601611d2e565b611d6981611a43565b840191505092915050565b5f6020820190508181035f830152611d8c8184611d3c565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680611dd857607f821691505b602082108103611deb57611dea611d94565b5b50919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f81905092915050565b5f819050815f5260205f209050919050565b5f8154611e4681611dc1565b611e508186611e1e565b9450600182165f8114611e6a5760018114611e7f57611eb1565b60ff1983168652811515820286019350611eb1565b611e8885611e28565b5f5b83811015611ea957815481890152600182019150602081019050611e8a565b838801955050505b50505092915050565b5f611ec482611d14565b611ece8185611e1e565b9350611ede818560208601611d2e565b80840191505092915050565b5f611ef58285611e3a565b9150611f018284611eba565b91508190509392505050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302611f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82611f1c565b611f618683611f1c565b95508019841693508086168417925050509392505050565b5f819050919050565b5f611f9c611f97611f9284611b77565b611f79565b611b77565b9050919050565b5f819050919050565b611fb583611f82565b611fc9611fc182611fa3565b848454611f28565b825550505050565b5f5f905090565b611fe0611fd1565b611feb818484611fac565b505050565b5b8181101561200e576120035f82611fd8565b600181019050611ff1565b5050565b601f8211156120535761202481611e28565b61202d84611f0d565b8101602085101561203c578190505b61205061204885611f0d565b830182611ff0565b50505b505050565b5f82821c905092915050565b5f6120735f1984600802612058565b1980831691505092915050565b5f61208b8383612064565b9150826002028217905092915050565b6120a482611d14565b67ffffffffffffffff8111156120bd576120bc611a53565b5b6120c78254611dc1565b6120d2828285612012565b5f60209050601f831160018114612103575f84156120f1578287015190505b6120fb8582612080565b865550612162565b601f19841661211186611e28565b5f5b8281101561213857848901518255600182019150602085019450602081019050612113565b868310156121555784890151612151601f891682612064565b8355505b6001600288020188555050505b505050505050565b5f82825260208201905092915050565b7f476173206d7573742062652067726561746572207468616e20300000000000005f82015250565b5f6121ae601a8361216a565b91506121b98261217a565b602082019050919050565b5f6020820190508181035f8301526121db816121a2565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61221982611b77565b915061222483611b77565b925082820390508181111561223c5761223b6121e2565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f61227982611b77565b915061228483611b77565b92508261229457612293612242565b5b828204905092915050565b5f6122a982611b77565b91506122b483611b77565b9250826122c4576122c3612242565b5b828206905092915050565b7f626c6f636b20776173206f64642c20616e64204920646f6e2774206c696b65205f8201527f7468617400000000000000000000000000000000000000000000000000000000602082015250565b5f61232960248361216a565b9150612334826122cf565b604082019050919050565b5f6020820190508181035f8301526123568161231d565b9050919050565b5f81519050919050565b5f81905092915050565b5f61237b8261235d565b6123858185612367565b9350612395818560208601611d2e565b80840191505092915050565b5f6123ac8284612371565b915081905092915050565b6123c081611b77565b82525050565b5f6020820190506123d95f8301846123b7565b92915050565b5f6123ea8284611eba565b915081905092915050565b7f6661696c656400000000000000000000000000000000000000000000000000005f82015250565b5f61242960068361216a565b9150612434826123f5565b602082019050919050565b5f6020820190508181035f8301526124568161241d565b9050919050565b5f819050919050565b61246f8161245d565b8114612479575f5ffd5b50565b5f8151905061248a81612466565b92915050565b5f602082840312156124a5576124a4611a33565b5b5f6124b28482850161247c565b91505092915050565b5f819050919050565b5f60ff82169050919050565b5f6124ea6124e56124e0846124bb565b611f79565b6124c4565b9050919050565b6124fa816124d0565b82525050565b5f60c0820190506125135f8301896124f1565b61252060208301886124f1565b61252d60408301876124f1565b61253a60608301866123b7565b61254760808301856123b7565b61255460a08301846123b7565b979650505050505050565b5f8151905061256d81611b80565b92915050565b5f6020828403121561258857612587611a33565b5b5f6125958482850161255f565b91505092915050565b5f819050919050565b6125b86125b382611b77565b61259e565b82525050565b5f6125c982876125a7565b6020820191506125d982866125a7565b6020820191506125e982856125a7565b6020820191506125f982846125a7565b60208201915081905095945050505050565b7f456c6c6970746963206375727665206164646974696f6e206661696c656400005f82015250565b5f61263f601e8361216a565b915061264a8261260b565b602082019050919050565b5f6020820190508181035f83015261266c81612633565b9050919050565b5f5f6040838503121561268957612688611a33565b5b5f6126968582860161255f565b92505060206126a78582860161255f565b9150509250929050565b5f6126bc82866125a7565b6020820191506126cc82856125a7565b6020820191506126dc82846125a7565b602082019150819050949350505050565b7f456c6c6970746963206375727665206d756c7469706c69636174696f6e2066615f8201527f696c656400000000000000000000000000000000000000000000000000000000602082015250565b5f61274760248361216a565b9150612752826126ed565b604082019050919050565b5f6020820190508181035f8301526127748161273b565b9050919050565b7f696e707574206c656e677468206d7573742062652065786163746c79203231335f8201527f2062797465730000000000000000000000000000000000000000000000000000602082015250565b5f6127d560268361216a565b91506127e08261277b565b604082019050919050565b5f6020820190508181035f830152612802816127c9565b9050919050565b7f426c616b65326620707265636f6d70696c65206661696c6564000000000000005f82015250565b5f61283d60198361216a565b915061284882612809565b602082019050919050565b5f6020820190508181035f83015261286a81612831565b9050919050565b5f63ffffffff82169050919050565b5f8160e01b9050919050565b5f61289682612880565b9050919050565b6128ae6128a982612871565b61288c565b82525050565b5f819050919050565b6128ce6128c98261245d565b6128b4565b82525050565b5f7fffffffffffffffff00000000000000000000000000000000000000000000000082169050919050565b5f819050919050565b612919612914826128d4565b6128ff565b82525050565b5f8115159050919050565b5f8160f81b9050919050565b5f6129408261292a565b9050919050565b5f61295182612936565b9050919050565b6129696129648261291f565b612947565b82525050565b5f61297a828d61289d565b60048201915061298a828c6128bd565b60208201915061299a828b6128bd565b6020820191506129aa828a6128bd565b6020820191506129ba82896128bd565b6020820191506129ca82886128bd565b6020820191506129da82876128bd565b6020820191506129ea8286612908565b6008820191506129fa8285612908565b600882019150612a0a8284612958565b6001820191508190509b9a5050505050505050505050565b5f819050919050565b5f815f1b9050919050565b5f612a50612a4b612a4684612a22565b612a2b565b61245d565b9050919050565b612a6081612a36565b82525050565b5f819050919050565b5f612a89612a84612a7f84612a66565b611f79565b6124c4565b9050919050565b612a9981612a6f565b82525050565b5f819050919050565b5f612ac2612abd612ab884612a9f565b612a2b565b61245d565b9050919050565b612ad281612aa8565b82525050565b5f819050919050565b5f612afb612af6612af184612ad8565b612a2b565b61245d565b9050919050565b612b0b81612ae1565b82525050565b5f608082019050612b245f830187612a57565b612b316020830186612a90565b612b3e6040830185612ac9565b612b4b6060830184612b02565b9594505050505056fe0000000148c9bdf267e6096a3ba7ca8485ae67bb2bf894fe72f36e3cf1361d5f3af54fa5d182e6ad7f520e511f6c3e2b8c68059b6bbd41fbabd9831f79217e1319cde05b616263000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000011b6e4577cc71df5e856ed88d2d14a464343f140b07693e3b08308570b28fd55b24198aa6ee0f5bfec020ad2ff15729434439e4af7554fa0f7395ee20cb926346246b8e8c771c3db7226a8066537632923d7d5a542f8e0d600e7f0195240f1ec513cbe706f9ba436dd4a781fab85fa2e9d82854446cf91182dcfa66eb68c4b7e72533a60b837f9cf4838c4c38f4f9c8988fee10c9895753e7925a86330e925db702f47f10f7da957cfcc613361ab6aaeb67f14d22c06eec14e47e36988c4ee06705a596bd22bbb13dc898acfdd420c88893dd09f7fd4875e8b3fb65b54ad9643f2847ab3c7d853e89cfdf520de28e1092c1955b7e17d9cba5808f047a3d6898fd2f64f057deda8bbb646d5b9864d9789a696abf2a42218f7af28baae517f5e45723bd3952d332068086b2079260b285896cb84c73ece3647094fac90d8b1374c21eebb3f8ea3c3d9147fa09e4506bcff1c222a02ea8b4904fc6df3bca1cc0505e133d9a4794eb099e9bdf82a6fecdb2e2e29b0867bf0fe557475dc758d796714ea26469706673582212204fd746b5bf517cb8d8c8cc3229b6edfe0d245a9e97fbace28fb75b3d9c68de8c64736f6c634300081b0033"

[[spam]]
[spam.tx]
to = "{SpamMe5}"
signature = "callPrecompile(string memory method, uint256 iterations)"
args = ["ecMul", "5"]
max_priority_fee_per_gas = "10000000000"                               # 10 gwei

[[spam]]
[spam.tx]
to = "{SpamMe5}"
signature = "consumeGas(uint256)"
args = ["50000"]
fuzz = [
    { max_priority_fee_per_gas = true, min = "0x2540be400", max = "0x4a817c800" },
]

@op-will op-will requested a review from zeroXbrock May 13, 2026 05:10
@op-will
Copy link
Copy Markdown
Author

op-will commented May 13, 2026

@op-will odd, that looks right, but I'm getting this error when trying to test it locally...

@zeroXbrock Good find! Looks like the estimate gas path wasn't covered. Added a regression test that failed before updates with the error you got and now passes.

Also updated min / max to handle hex/decimal integers as well as unit strings.

op-will added 3 commits May 13, 2026 17:28
Adds a per-tx EIP-1559 priority fee that can be set statically or
fuzzed via the existing fuzz mechanism:

- new field FunctionCallDefinition::max_priority_fee_per_gas (Option<String>,
  may be a {placeholder}); plumbed through FunctionCallDefinitionStrict and
  the templater
- new FuzzParam::max_priority_fee_per_gas (Option<bool>), mirroring the
  existing FuzzParam::value flag; mutually exclusive with `param` and
  `value`, with the conflict caught at scenario load time in parse_map_key
- complete_tx_request now raises max_fee_per_gas to match the priority fee
  when the priority fee exceeds the sampled cap, preserving the EIP-1559
  invariant
- docs/creating_scenarios.md documents both the static and fuzzed forms
- crates/core/CHANGELOG.md updated under [0.11.0]
…fee set

estimate_gas enforces EIP-1559's max_fee_per_gas >= max_priority_fee_per_gas
invariant, but complete_tx_request runs after estimation. When a spam tx sets
max_priority_fee_per_gas (statically or via fuzz), the estimation call was
rejected. Lift max_fee_per_gas to the priority fee on the estimation copy so
gas estimation succeeds; the real fee cap is still set in complete_tx_request.

Adds a regression test asserting the EIP-1559 invariant holds end-to-end.
`max_priority_fee_per_gas` (static) and `FuzzParam::min` / `FuzzParam::max`
now parse raw wei, hex (`"0x..."`), and unit strings ("10 gwei", "0.001 eth")
via `parse_value` / `deserialize_value_opt`. Scenarios can express gas
parameters as "10 gwei" instead of error-prone literal wei.

Templater previously called `s.parse::<u128>()` on the static field, so a
misconfigured value silently became `None`. It now returns a new
`TemplaterError::ParsePriorityFeeFailed` so the issue surfaces at scenario
load time. `{placeholder}` resolution still runs first, so placeholders that
expand to any accepted format keep working.

Existing format tests are widened to sweep all accepted literal forms; new
templater tests cover the parse path, placeholder resolution into a unit
string, and the malformed-input error.
@op-will op-will force-pushed the addPriorityFeeFuzzing branch from 50ac46d to 5663986 Compare May 13, 2026 22:29
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.

2 participants