bluealloy / revm

Rust implementation of the Ethereum Virtual Machine.
https://bluealloy.github.io/revm/
MIT License
1.59k stars 518 forks source link

Accessing call value and sender in precompiles #1684

Open JamesHinshelwood opened 1 month ago

JamesHinshelwood commented 1 month ago

Currently only the call data is passed to precompiles: https://github.com/bluealloy/revm/blob/4d0feec0b5b850d9a1ce651d7c1655d829f48097/crates/revm/src/context/context_precompiles.rs#L212

We're working on some custom precompiles that need to know the msg.value and msg.sender too. Would there be any sympathy for adding these parameters to the precompile traits (Perhaps by passing &CallInputs instead)?

rakita commented 1 month ago

That makes sense. Do you want to add it?

jsvisa commented 5 days ago

just curious, the msg.sender and msg.value are already in the Env.tx? Don't hesitate to correct me if I'm misunderstood.

https://github.com/bluealloy/revm/blob/d38ff452714e1c4a17cf0fbdaa4913f6d61033c4/crates/revm/src/context/context_precompiles.rs#L199-L205

https://github.com/bluealloy/revm/blob/d38ff452714e1c4a17cf0fbdaa4913f6d61033c4/crates/primitives/src/env.rs#L535-L548

rakita commented 5 days ago

just curious, the msg.sender and msg.value are already in the Env.tx? Don't hesitate to correct me if I'm misunderstood.

What I understood is caller and value of a subcall.