mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Don't track deployment block in the Router
This technically has a TOCTOU where we sync an Epoch's metadata (signifying we did sync to that point), then check if the Router was deployed, yet at that very moment the node resets to genesis. By ensuring the Router is deployed, we avoid this (and don't need to track the deployment block in-contract). Also uses a JoinSet to sync the 32 blocks in parallel.
This commit is contained in:
@@ -11,7 +11,7 @@ use alloy_consensus::TxLegacy;
|
||||
|
||||
use alloy_sol_types::{SolValue, SolConstructor, SolCall, SolEvent};
|
||||
|
||||
use alloy_rpc_types_eth::{TransactionInput, TransactionRequest, Filter};
|
||||
use alloy_rpc_types_eth::Filter;
|
||||
use alloy_transport::{TransportErrorKind, RpcError};
|
||||
use alloy_simple_request_transport::SimpleRequest;
|
||||
use alloy_provider::{Provider, RootProvider};
|
||||
@@ -296,23 +296,6 @@ impl Router {
|
||||
self.1
|
||||
}
|
||||
|
||||
/// Fetch the block this contract was deployed at.
|
||||
pub async fn deployment_block(&self) -> Result<u64, RpcError<TransportErrorKind>> {
|
||||
let call = TransactionRequest::default()
|
||||
.to(self.address())
|
||||
.input(TransactionInput::new(abi::deploymentBlockCall::new(()).abi_encode().into()));
|
||||
let bytes = self.0.call(&call).await?;
|
||||
let deployment_block = abi::deploymentBlockCall::abi_decode_returns(&bytes, true)
|
||||
.map_err(|e| {
|
||||
TransportErrorKind::Custom(
|
||||
format!("node returned a non-u256 for function returning u256: {e:?}").into(),
|
||||
)
|
||||
})?
|
||||
._0;
|
||||
|
||||
Ok(deployment_block.try_into().unwrap())
|
||||
}
|
||||
|
||||
/// Get the message to be signed in order to update the key for Serai.
|
||||
pub fn update_serai_key_message(chain_id: U256, nonce: u64, key: &PublicKey) -> Vec<u8> {
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user