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

feat(rpc): add eth_multicallV1 #5596

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion crates/rpc/rpc-api/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ pub trait EthApi {
#[method(name = "protocolVersion")]
async fn protocol_version(&self) -> RpcResult<U64>;

/// Executes complex RPC calls to Ethereum nodes
#[method(name = "ethMulticallV1")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsonrpc method names are case sensitive and eth prefix is already specified on the trait

Suggested change
#[method(name = "ethMulticallV1")]
#[method(name = "multicallV1")]

async fn eth_multicall_v1(
&self,
multicall: Bundle,
state_context: Option<StateContext>,
state_override: Option<StateOverride>,
) -> RpcResult<Vec<EthCallResponse>>;

/// Returns an object with data about the sync status or false.
#[method(name = "syncing")]
fn syncing(&self) -> RpcResult<SyncStatus>;
Expand All @@ -42,7 +51,7 @@ pub trait EthApi {
#[method(name = "getBlockByHash")]
async fn block_by_hash(&self, hash: B256, full: bool) -> RpcResult<Option<RichBlock>>;

/// Returns information about a block by number.
/// Returns information about a block by number
#[method(name = "getBlockByNumber")]
async fn block_by_number(
&self,
Expand Down
10 changes: 10 additions & 0 deletions crates/rpc/rpc/src/eth/api/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ where
BlockReaderIdExt + ChainSpecProvider + StateProviderFactory + EvmEnvProvider + 'static,
Network: NetworkInfo + Send + Sync + 'static,
{
/// Executes complex RPC calls to Ethereum nodes

pub async fn eth_multicall_v1(
Comment on lines +43 to +45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Executes complex RPC calls to Ethereum nodes
pub async fn eth_multicall_v1(
/// Executes complex RPC calls to Ethereum nodes.
/// Ref: <https://github.com/ethereum/execution-apis/pull/484>
pub async fn eth_multicall_v1(

&self,
multicall_bundle: Bundle,
state_context: Option<StateContext>,
state_override: Option<StateOverride>,
) -> EthResult<Vec<EthCallResponse>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just the same as call_many?

so atm we don't need this function and can reuse call_many instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just the same as call_many?

so atm we don't need this function and can reuse call_many instead

hey ty for your review, you means i should directly call the function call_many inside this function ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, at least for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, at least for now

ty so much, very greatful from your part all these review. should be fine now

EthApi::call_many(self, multicall_bundle, state_context, state_override).await
}
/// Estimate gas needed for execution of the `request` at the [BlockId].
pub async fn estimate_gas_at(&self, request: CallRequest, at: BlockId) -> EthResult<U256> {
let (cfg, block_env, at) = self.evm_env_at(at).await?;
Expand Down
11 changes: 11 additions & 0 deletions crates/rpc/rpc/src/eth/api/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ where
EthApiSpec::protocol_version(self).await.to_rpc_result()
}

/// Handler for ! `eth_MultiCallV1`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Handler for ! `eth_MultiCallV1`
/// Handler for ! `eth_multicallV1`

async fn eth_multicall_v1(
&self,
multi_call: Bundle,
state_context: Option<StateContext>,
state_override: Option<StateOverride>,
) -> Result<Vec<EthCallResponse>> {
trace!(target: "rpc::eth", "Serving eth_multicall_v1 request");
Ok(EthApi::eth_multicall_v1(self, multi_call, state_context, state_override).await?)
}

/// Handler for: `eth_syncing`
fn syncing(&self) -> Result<SyncStatus> {
trace!(target: "rpc::eth", "Serving eth_syncing");
Expand Down
Loading