paradigmxyz / reth

Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust
https://reth.rs/
Apache License 2.0
3.85k stars 1.1k forks source link

Implement eth_simulateV1 #8281

Closed mattsse closed 6 days ago

mattsse commented 4 months ago

Describe the feature

ref https://github.com/ethereum/execution-apis/pull/484

this should be similar to eth_callMany

https://github.com/paradigmxyz/reth/blob/79d505adb29a84674df6f293909fab2192af2431/crates/rpc/rpc/src/eth/api/call.rs#L81-L83

and/or trace_callMany

https://github.com/paradigmxyz/reth/blob/79d505adb29a84674df6f293909fab2192af2431/crates/rpc/rpc/src/trace.rs#L127-L131

Additional context

Was mostly implemented in https://github.com/paradigmxyz/reth/pull/10829

Still missing moving precompiles support. Seems that support for it needs to be added to all commands accepting state overrides, at this is how this was handled in geth

dhruvmalik007 commented 4 months ago

Hey, I am interested to try my luck creating PR on this issue . I wanted to understand various things :

Thanks

mattsse commented 4 months ago

great!

this doesn't require any offchain components, I think we can start with type bindings for the endpoint, then the trait function and then try to implement the described logic. the pr has a few test cases, we can use the objects to generate bindings: https://transform.tools/json-to-rust-serde

rupam-04 commented 4 months ago

great!

this doesn't require any offchain components, I think we can start with type bindings for the endpoint, then the trait function and then try to implement the described logic. the pr has a few test cases, we can use the objects to generate bindings: https://transform.tools/json-to-rust-serde

So do we end up with the following somewhere?

use serde_derive::Deserialize;
use serde_derive::Serialize;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Root {
    pub jsonrpc: String,
    pub id: i64,
    pub method: String,
    pub params: (Params, String),
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Params {
    pub block_state_calls: Vec<BlockStateCall>,
    pub trace_transfers: bool,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BlockStateCall {
    pub state_overrides: StateOverrides,
    pub calls: Vec<Call>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StateOverrides {
    #[serde(rename = "0xc000000000000000000000000000000000000000")]
    pub n0xc000000000000000000000000000000000000000: n0xc000000000000000000000000000000000000000,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct n0xc000000000000000000000000000000000000000 {
    pub balance: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Call {
    pub from: String,
    pub to: String,
    pub value: String,
}
dhruvmalik007 commented 4 months ago

Apologies for delay as I had issues running reth on limited specs laptop and thanks @rupam-04 for reaching out.

This is a correct description of traits although what I also added is to develop the traits while taking also the pre implemented types (i.e reth_trie::StateRoot , so as to have consistent API ). if possible we can have a joint PR for this one and I will work on the side of writing the structures for the parameters along with the API method.

rupam-04 commented 4 months ago

Apologies for delay and thanks @rupam-04 for reaching out.

This is a correct description of traits although what I also added is to develop the traits while taking also the pre implemented types (i.e reth_trie::StateRoot , so as to have consistent API ). if possible we can have a joint PR for this one and I will work on the side of writing the structures for the parameters along with the API method.

feel free to continue your work on this, I just subscribed to this issue as it looked interesting to me. I am looking forward to how you implement the whole thing.

KillariDev commented 4 months ago

hey, If you are interested in joining eth_simulatev1:s implementers call, we have a meeting every Monday. You can find the meeting in the Ethereum Protocol Calls calendar

dhruvmalik007 commented 4 months ago

Thanks @KillariDev I will be there to resolve my queries.

Rjected commented 3 months ago

Hey @dhruvmalik007 have you made any progress on this / do you have any questions?

dhruvmalik007 commented 3 months ago

Hey @dhruvmalik007 have you made any progress on this / do you have any questions?

Hi , I am kind of stuck in the progress due to personal workload last 3 weeks and was just able to define the traits on personal branch dhruvmalik007/simulate_v1 till now.

on the side of questions its fine as already the eth_multicall group has answered the call during one of the monday call. I can try to put effort from this week to finish the methods simulate_many or else I will let people know to either implement their version or use my code.

dhruvmalik007 commented 2 months ago

hi @mattsse , regarding the progress on this branch: i will start work on this once the pull : https://github.com/alloy-rs/alloy/pull/1042 is finished .

Blaeaea commented 2 months ago

hi @mattsse , regarding the progress on this branch: i will start work on this once the pull : alloy-rs/alloy#1042 is finished .

there is new tracking for this https://github.com/paradigmxyz/reth/issues/8844

0x-chad commented 1 month ago

@dhruvmalik007 any progress on this?

dhruvmalik007 commented 1 month ago

hi @0x-chad , yes I am currently finishing the fn call_many , adding various conditions regarding blockOverrides result and data serialisation . here you can follow the progress : https://github.com/dhruvmalik007/reth/commit/4dee218980c3a73bce07c0f86a7b959faea34aaf/ . I will create PR hopefully next week with tests.

SkandaBhat commented 1 month ago

hi @0x-chad , yes I am currently finishing the fn call_many , adding various conditions regarding blockOverrides result and data serialisation . here you can follow the progress : https://github.com/dhruvmalik007/reth/commit/4dee218980c3a73bce07c0f86a7b959faea34aaf/ . I will create PR hopefully next week with tests.

Does not seem like there have been much updates since this. Do you mind if I pick this up @mattsse @emhane?

dhruvmalik007 commented 1 month ago

hi @0x-chad , yes I am currently finishing the fn call_many , adding various conditions regarding blockOverrides result and data serialisation . here you can follow the progress : https://github.com/dhruvmalik007/reth/commit/4dee218980c3a73bce07c0f86a7b959faea34aaf/ . I will create PR hopefully next week with tests.

Does not seem like there have been much updates since this. Do you mind if I pick this up @mattsse?

Hey , sure you can take the lead from here as I dont have time commitment in the coming weeks. @mattsse you can assign this task to @SkandaBhat ?

mattsse commented 6 days ago

closing this and instead tracking in #11151