reth icon indicating copy to clipboard operation
reth copied to clipboard

Implement eth_simulateV1

Open mattsse opened this issue 1 year ago • 6 comments
trafficstars

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

No response

mattsse avatar May 15 '24 12:05 mattsse

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

  • in terms of the specification regarding the transaction batching and merging the arbitrary blocks : do we need to maintain the sliding window in order to manage the state of the n blocks which are parsed .

  • also the use of the ExEx executors for composing the transactions as the offchain hooks is required in this case ?

Thanks

dhruvmalik007 avatar May 16 '24 06:05 dhruvmalik007

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

mattsse avatar May 16 '24 06:05 mattsse

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,
}

rupam-04 avatar May 19 '24 15:05 rupam-04

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.

dhruvmalik007 avatar May 19 '24 18:05 dhruvmalik007

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.

rupam-04 avatar May 19 '24 18:05 rupam-04

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

KillariDev avatar May 20 '24 18:05 KillariDev

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

dhruvmalik007 avatar May 21 '24 08:05 dhruvmalik007

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

Rjected avatar Jun 12 '24 21:06 Rjected

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 avatar Jun 13 '24 05:06 dhruvmalik007

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 .

dhruvmalik007 avatar Jul 16 '24 11:07 dhruvmalik007

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

Blaeaea avatar Jul 17 '24 15:07 Blaeaea

@dhruvmalik007 any progress on this?

0x-chad avatar Aug 18 '24 04:08 0x-chad

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.

dhruvmalik007 avatar Aug 18 '24 06:08 dhruvmalik007

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?

SkandaBhat avatar Aug 29 '24 10:08 SkandaBhat

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 ?

dhruvmalik007 avatar Aug 29 '24 11:08 dhruvmalik007

closing this and instead tracking in #11151

mattsse avatar Sep 28 '24 13:09 mattsse