revm icon indicating copy to clipboard operation
revm copied to clipboard

Accessing call value and sender in precompiles

Open JamesHinshelwood opened this issue 1 year ago • 4 comments

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)?

JamesHinshelwood avatar Aug 05 '24 17:08 JamesHinshelwood

That makes sense. Do you want to add it?

rakita avatar Aug 08 '24 10:08 rakita

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

jsvisa avatar Sep 10 '24 04:09 jsvisa

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.

rakita avatar Sep 10 '24 09:09 rakita

Hey, I have the same need. Would it be fine to transmit the complete CallInputs to precompiles? I am trying to draft the changes, it would mean that (all different) precompiles types

pub type StandardPrecompileFn = fn(&CallInputs, u64) -> PrecompileResult;

become

pub type StandardPrecompileFn = fn(&CallInputs) -> PrecompileResult;

Does this seem reasonable or should it transmit only a subset of CallInputs?

vch9 avatar Oct 24 '24 10:10 vch9

With new PrecompileProvider we now have access to full Context

rakita avatar Mar 13 '25 17:03 rakita