Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement eth_simulateV1 #8281

Open
mattsse opened this issue May 15, 2024 · 7 comments
Open

Implement eth_simulateV1 #8281

mattsse opened this issue May 15, 2024 · 7 comments
Assignees
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented May 15, 2024

Describe the feature

ref ethereum/execution-apis#484

this should be similar to eth_callMany

/// Simulate arbitrary number of transactions at an arbitrary blockchain index, with the
/// optionality of state overrides
pub async fn call_many(

and/or trace_callMany

/// Performs multiple call traces on top of the same block. i.e. transaction n will be executed
/// on top of a pending block with all n-1 transactions applied (traced) first.
///
/// Note: Allows tracing dependent transactions, hence all transactions are traced in sequence
pub async fn trace_call_many(

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started A-rpc Related to the RPC implementation labels May 15, 2024
@dhruvmalik007
Copy link

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

@mattsse
Copy link
Collaborator Author

mattsse commented May 16, 2024

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
Copy link
Contributor

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
Copy link

dhruvmalik007 commented May 19, 2024

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
Copy link
Contributor

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
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Todo
Development

No branches or pull requests

4 participants