mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-07-20 16:55:44 +00:00
Remove un-necessary trace call from the benchmark driver
This commit is contained in:
Generated
+1
@@ -5658,6 +5658,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy",
|
"alloy",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"async-stream",
|
||||||
"futures",
|
"futures",
|
||||||
"revive-common",
|
"revive-common",
|
||||||
"revive-dt-common",
|
"revive-dt-common",
|
||||||
|
|||||||
+2
-1
@@ -23,6 +23,7 @@ revive-dt-report = { version = "0.1.0", path = "crates/report" }
|
|||||||
revive-dt-solc-binaries = { version = "0.1.0", path = "crates/solc-binaries" }
|
revive-dt-solc-binaries = { version = "0.1.0", path = "crates/solc-binaries" }
|
||||||
|
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
async-stream = { version = "0.3.6" }
|
||||||
bson = { version = "2.15.0" }
|
bson = { version = "2.15.0" }
|
||||||
cacache = { version = "13.1.0" }
|
cacache = { version = "13.1.0" }
|
||||||
clap = { version = "4", features = ["derive"] }
|
clap = { version = "4", features = ["derive"] }
|
||||||
@@ -73,7 +74,7 @@ revive-solc-json-interface = { git = "https://github.com/paritytech/revive", rev
|
|||||||
revive-common = { git = "https://github.com/paritytech/revive", rev = "3389865af7c3ff6f29a586d82157e8bc573c1a8e" }
|
revive-common = { git = "https://github.com/paritytech/revive", rev = "3389865af7c3ff6f29a586d82157e8bc573c1a8e" }
|
||||||
revive-differential = { git = "https://github.com/paritytech/revive", rev = "3389865af7c3ff6f29a586d82157e8bc573c1a8e" }
|
revive-differential = { git = "https://github.com/paritytech/revive", rev = "3389865af7c3ff6f29a586d82157e8bc573c1a8e" }
|
||||||
|
|
||||||
zombienet-sdk = { git = "https://github.com/paritytech/zombienet-sdk.git", rev ="891f6554354ce466abd496366dbf8b4f82141241" }
|
zombienet-sdk = { git = "https://github.com/paritytech/zombienet-sdk.git", rev = "891f6554354ce466abd496366dbf8b4f82141241" }
|
||||||
|
|
||||||
[workspace.dependencies.alloy]
|
[workspace.dependencies.alloy]
|
||||||
version = "1.0.37"
|
version = "1.0.37"
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ use revive_dt_format::{
|
|||||||
},
|
},
|
||||||
traits::{ResolutionContext, ResolverApi},
|
traits::{ResolutionContext, ResolverApi},
|
||||||
};
|
};
|
||||||
use tokio::sync::{Mutex, mpsc::UnboundedSender};
|
use tokio::sync::{Mutex, OnceCell, mpsc::UnboundedSender};
|
||||||
use tracing::{Instrument, Span, debug, error, field::display, info, info_span, instrument};
|
use tracing::{Instrument, Span, debug, error, field::display, info, info_span, instrument};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -123,13 +123,7 @@ where
|
|||||||
&self.platform_information.reporter,
|
&self.platform_information.reporter,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.inspect_err(|err| {
|
.inspect_err(|err| error!(?err, "Pre-linking compilation failed"))
|
||||||
error!(
|
|
||||||
?err,
|
|
||||||
platform_identifier = %self.platform_information.platform.platform_identifier(),
|
|
||||||
"Pre-linking compilation failed"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.context("Failed to produce the pre-linking compiled contracts")?;
|
.context("Failed to produce the pre-linking compiled contracts")?;
|
||||||
|
|
||||||
let mut deployed_libraries = None::<HashMap<_, _>>;
|
let mut deployed_libraries = None::<HashMap<_, _>>;
|
||||||
@@ -137,13 +131,7 @@ where
|
|||||||
.test_definition
|
.test_definition
|
||||||
.metadata
|
.metadata
|
||||||
.contract_sources()
|
.contract_sources()
|
||||||
.inspect_err(|err| {
|
.inspect_err(|err| error!(?err, "Failed to retrieve contract sources from metadata"))
|
||||||
error!(
|
|
||||||
?err,
|
|
||||||
platform_identifier = %self.platform_information.platform.platform_identifier(),
|
|
||||||
"Failed to retrieve contract sources from metadata"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.context("Failed to get the contract instances from the metadata file")?;
|
.context("Failed to get the contract instances from the metadata file")?;
|
||||||
for library_instance in self
|
for library_instance in self
|
||||||
.test_definition
|
.test_definition
|
||||||
@@ -195,16 +183,11 @@ where
|
|||||||
error!(
|
error!(
|
||||||
?err,
|
?err,
|
||||||
%library_instance,
|
%library_instance,
|
||||||
platform_identifier = %self.platform_information.platform.platform_identifier(),
|
|
||||||
"Failed to deploy the library"
|
"Failed to deploy the library"
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
debug!(
|
debug!(?library_instance, "Deployed library");
|
||||||
?library_instance,
|
|
||||||
platform_identifier = %self.platform_information.platform.platform_identifier(),
|
|
||||||
"Deployed library"
|
|
||||||
);
|
|
||||||
|
|
||||||
let library_address = receipt
|
let library_address = receipt
|
||||||
.contract_address
|
.contract_address
|
||||||
@@ -227,13 +210,7 @@ where
|
|||||||
&self.platform_information.reporter,
|
&self.platform_information.reporter,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.inspect_err(|err| {
|
.inspect_err(|err| error!(?err, "Post-linking compilation failed"))
|
||||||
error!(
|
|
||||||
?err,
|
|
||||||
platform_identifier = %self.platform_information.platform.platform_identifier(),
|
|
||||||
"Post-linking compilation failed"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.context("Failed to compile the post-link contracts")?;
|
.context("Failed to compile the post-link contracts")?;
|
||||||
|
|
||||||
self.execution_state = ExecutionState::new(
|
self.execution_state = ExecutionState::new(
|
||||||
@@ -269,7 +246,6 @@ where
|
|||||||
skip_all,
|
skip_all,
|
||||||
fields(
|
fields(
|
||||||
driver_id = self.driver_id,
|
driver_id = self.driver_id,
|
||||||
platform_identifier = %self.platform_information.platform.platform_identifier(),
|
|
||||||
%step_path,
|
%step_path,
|
||||||
),
|
),
|
||||||
err(Debug),
|
err(Debug),
|
||||||
@@ -309,11 +285,7 @@ where
|
|||||||
.handle_function_call_execution(step, deployment_receipts)
|
.handle_function_call_execution(step, deployment_receipts)
|
||||||
.await
|
.await
|
||||||
.context("Failed to handle the function call execution")?;
|
.context("Failed to handle the function call execution")?;
|
||||||
let tracing_result = self
|
self.handle_function_call_variable_assignment(step, execution_receipt.transaction_hash)
|
||||||
.handle_function_call_call_frame_tracing(execution_receipt.transaction_hash)
|
|
||||||
.await
|
|
||||||
.context("Failed to handle the function call call frame tracing")?;
|
|
||||||
self.handle_function_call_variable_assignment(step, &tracing_result)
|
|
||||||
.await
|
.await
|
||||||
.context("Failed to handle function call variable assignment")?;
|
.context("Failed to handle function call variable assignment")?;
|
||||||
Ok(1)
|
Ok(1)
|
||||||
@@ -417,15 +389,19 @@ where
|
|||||||
async fn handle_function_call_variable_assignment(
|
async fn handle_function_call_variable_assignment(
|
||||||
&mut self,
|
&mut self,
|
||||||
step: &FunctionCallStep,
|
step: &FunctionCallStep,
|
||||||
tracing_result: &CallFrame,
|
tx_hash: TxHash,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let Some(ref assignments) = step.variable_assignments else {
|
let Some(ref assignments) = step.variable_assignments else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handling the return data variable assignments.
|
// Handling the return data variable assignments.
|
||||||
|
let callframe = OnceCell::new();
|
||||||
for (variable_name, output_word) in assignments.return_data.iter().zip(
|
for (variable_name, output_word) in assignments.return_data.iter().zip(
|
||||||
tracing_result
|
callframe
|
||||||
|
.get_or_try_init(|| self.handle_function_call_call_frame_tracing(tx_hash))
|
||||||
|
.await
|
||||||
|
.context("Failed to get the callframe trace for transaction")?
|
||||||
.output
|
.output
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
@@ -547,7 +523,6 @@ where
|
|||||||
skip_all,
|
skip_all,
|
||||||
fields(
|
fields(
|
||||||
driver_id = self.driver_id,
|
driver_id = self.driver_id,
|
||||||
platform_identifier = %self.platform_information.platform.platform_identifier(),
|
|
||||||
%contract_instance,
|
%contract_instance,
|
||||||
%deployer
|
%deployer
|
||||||
),
|
),
|
||||||
@@ -590,7 +565,6 @@ where
|
|||||||
skip_all,
|
skip_all,
|
||||||
fields(
|
fields(
|
||||||
driver_id = self.driver_id,
|
driver_id = self.driver_id,
|
||||||
platform_identifier = %self.platform_information.platform.platform_identifier(),
|
|
||||||
%contract_instance,
|
%contract_instance,
|
||||||
%deployer
|
%deployer
|
||||||
),
|
),
|
||||||
@@ -764,7 +738,9 @@ where
|
|||||||
.instrument(info_span!("Polling for receipt"))
|
.instrument(info_span!("Polling for receipt"))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
.instrument(info_span!("Polling for receipt", %transaction_hash))
|
||||||
.await
|
.await
|
||||||
|
.inspect(|_| info!("Found the transaction receipt"))
|
||||||
}
|
}
|
||||||
// endregion:Transaction Execution
|
// endregion:Transaction Execution
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use revive_dt_common::types::PrivateKeyAllocator;
|
|||||||
use revive_dt_core::Platform;
|
use revive_dt_core::Platform;
|
||||||
use revive_dt_format::steps::{Step, StepIdx, StepPath};
|
use revive_dt_format::steps::{Step, StepIdx, StepPath};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tracing::{error, info, info_span, instrument, warn};
|
use tracing::{Instrument, error, info, info_span, instrument, warn};
|
||||||
|
|
||||||
use revive_dt_config::{BenchmarkingContext, Context};
|
use revive_dt_config::{BenchmarkingContext, Context};
|
||||||
use revive_dt_report::Reporter;
|
use revive_dt_report::Reporter;
|
||||||
@@ -159,12 +159,15 @@ pub async fn handle_differential_benchmarks(
|
|||||||
|
|
||||||
futures::future::try_join(
|
futures::future::try_join(
|
||||||
watcher.run(),
|
watcher.run(),
|
||||||
driver.execute_all().inspect(|_| {
|
driver
|
||||||
info!("All transactions submitted - driver completed execution");
|
.execute_all()
|
||||||
watcher_tx
|
.instrument(info_span!("Executing Benchmarks", %platform_identifier))
|
||||||
.send(WatcherEvent::AllTransactionsSubmitted)
|
.inspect(|_| {
|
||||||
.unwrap()
|
info!("All transactions submitted - driver completed execution");
|
||||||
}),
|
watcher_tx
|
||||||
|
.send(WatcherEvent::AllTransactionsSubmitted)
|
||||||
|
.unwrap()
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.context("Failed to run the driver and executor")
|
.context("Failed to run the driver and executor")
|
||||||
|
|||||||
@@ -118,8 +118,9 @@ impl Watcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
remaining_transactions = watch_for_transaction_hashes.read().await.len(),
|
block_number = block.block_number,
|
||||||
block_tx_count = block.transaction_hashes.len(),
|
block_tx_count = block.transaction_hashes.len(),
|
||||||
|
remaining_transactions = watch_for_transaction_hashes.read().await.len(),
|
||||||
"Observed a block"
|
"Observed a block"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ rust-version.workspace = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
alloy = { workspace = true }
|
alloy = { workspace = true }
|
||||||
|
async-stream = { workspace = true }
|
||||||
futures = { workspace = true }
|
futures = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
tower = { workspace = true }
|
tower = { workspace = true }
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ use alloy::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use anyhow::Context as _;
|
use anyhow::Context as _;
|
||||||
use futures::{Stream, StreamExt};
|
use async_stream::stream;
|
||||||
|
use futures::Stream;
|
||||||
use revive_common::EVMVersion;
|
use revive_common::EVMVersion;
|
||||||
use revive_dt_common::fs::clear_directory;
|
use revive_dt_common::fs::clear_directory;
|
||||||
use revive_dt_format::traits::ResolverApi;
|
use revive_dt_format::traits::ResolverApi;
|
||||||
@@ -245,6 +246,12 @@ impl SubstrateNode {
|
|||||||
.arg("all")
|
.arg("all")
|
||||||
.arg("--rpc-max-connections")
|
.arg("--rpc-max-connections")
|
||||||
.arg(u32::MAX.to_string())
|
.arg(u32::MAX.to_string())
|
||||||
|
.arg("--consensus")
|
||||||
|
.arg("manual-seal-12000")
|
||||||
|
.arg("--pool-limit")
|
||||||
|
.arg(u32::MAX.to_string())
|
||||||
|
.arg("--pool-kbytes")
|
||||||
|
.arg(u32::MAX.to_string())
|
||||||
.env("RUST_LOG", Self::SUBSTRATE_LOG_ENV)
|
.env("RUST_LOG", Self::SUBSTRATE_LOG_ENV)
|
||||||
.stdout(stdout_file)
|
.stdout(stdout_file)
|
||||||
.stderr(stderr_file);
|
.stderr(stderr_file);
|
||||||
@@ -508,37 +515,46 @@ impl EthereumNode for SubstrateNode {
|
|||||||
+ '_,
|
+ '_,
|
||||||
>,
|
>,
|
||||||
> {
|
> {
|
||||||
|
fn create_stream(
|
||||||
|
provider: ConcreteProvider<ReviveNetwork, Arc<EthereumWallet>>,
|
||||||
|
) -> impl Stream<Item = MinedBlockInformation> {
|
||||||
|
stream! {
|
||||||
|
let mut block_number = provider.get_block_number().await.expect("Failed to get the block number");
|
||||||
|
loop {
|
||||||
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||||
|
|
||||||
|
let Ok(Some(block)) = provider.get_block_by_number(BlockNumberOrTag::Number(block_number)).await
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
block_number += 1;
|
||||||
|
yield MinedBlockInformation {
|
||||||
|
block_number: block.number(),
|
||||||
|
block_timestamp: block.header.timestamp,
|
||||||
|
mined_gas: block.header.gas_used as _,
|
||||||
|
block_gas_limit: block.header.gas_limit,
|
||||||
|
transaction_hashes: block
|
||||||
|
.transactions
|
||||||
|
.into_hashes()
|
||||||
|
.as_hashes()
|
||||||
|
.expect("Must be hashes")
|
||||||
|
.to_vec(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let provider = self
|
let provider = self
|
||||||
.provider()
|
.provider()
|
||||||
.await
|
.await
|
||||||
.context("Failed to create the provider for block subscription")?;
|
.context("Failed to create the provider for a block subscription")?;
|
||||||
let mut block_subscription = provider
|
|
||||||
.watch_full_blocks()
|
|
||||||
.await
|
|
||||||
.context("Failed to create the blocks stream")?;
|
|
||||||
block_subscription.set_channel_size(0xFFFF);
|
|
||||||
block_subscription.set_poll_interval(Duration::from_secs(1));
|
|
||||||
let block_stream = block_subscription.into_stream();
|
|
||||||
|
|
||||||
let mined_block_information_stream = block_stream.filter_map(|block| async {
|
let stream = Box::pin(create_stream(provider))
|
||||||
let block = block.ok()?;
|
as Pin<Box<dyn Stream<Item = MinedBlockInformation>>>;
|
||||||
Some(MinedBlockInformation {
|
|
||||||
block_number: block.number(),
|
|
||||||
block_timestamp: block.header.timestamp,
|
|
||||||
mined_gas: block.header.gas_used as _,
|
|
||||||
block_gas_limit: block.header.gas_limit,
|
|
||||||
transaction_hashes: block
|
|
||||||
.transactions
|
|
||||||
.into_hashes()
|
|
||||||
.as_hashes()
|
|
||||||
.expect("Must be hashes")
|
|
||||||
.to_vec(),
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(Box::pin(mined_block_information_stream)
|
Ok(stream)
|
||||||
as Pin<Box<dyn Stream<Item = MinedBlockInformation>>>)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ use alloy::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Context as _;
|
use anyhow::Context as _;
|
||||||
use futures::{Stream, StreamExt};
|
use async_stream::stream;
|
||||||
|
use futures::Stream;
|
||||||
use revive_common::EVMVersion;
|
use revive_common::EVMVersion;
|
||||||
use revive_dt_common::fs::clear_directory;
|
use revive_dt_common::fs::clear_directory;
|
||||||
use revive_dt_config::*;
|
use revive_dt_config::*;
|
||||||
@@ -122,6 +123,8 @@ impl ZombienetNode {
|
|||||||
const PARACHAIN_ID: u32 = 100;
|
const PARACHAIN_ID: u32 = 100;
|
||||||
const ETH_RPC_BASE_PORT: u16 = 8545;
|
const ETH_RPC_BASE_PORT: u16 = 8545;
|
||||||
|
|
||||||
|
const PROXY_LOG_ENV: &str = "info,eth-rpc=debug";
|
||||||
|
|
||||||
const ETH_RPC_READY_MARKER: &str = "Running JSON-RPC server";
|
const ETH_RPC_READY_MARKER: &str = "Running JSON-RPC server";
|
||||||
|
|
||||||
const EXPORT_CHAINSPEC_COMMAND: &str = "build-spec";
|
const EXPORT_CHAINSPEC_COMMAND: &str = "build-spec";
|
||||||
@@ -188,12 +191,13 @@ impl ZombienetNode {
|
|||||||
.with_node(|node| node.with_name("bob"))
|
.with_node(|node| node.with_name("bob"))
|
||||||
})
|
})
|
||||||
.with_global_settings(|global_settings| {
|
.with_global_settings(|global_settings| {
|
||||||
global_settings.with_base_dir(&self.base_directory)
|
// global_settings.with_base_dir(&self.base_directory)
|
||||||
|
global_settings
|
||||||
})
|
})
|
||||||
.with_parachain(|parachain| {
|
.with_parachain(|parachain| {
|
||||||
parachain
|
parachain
|
||||||
.with_id(Self::PARACHAIN_ID)
|
.with_id(Self::PARACHAIN_ID)
|
||||||
.with_chain_spec_path(template_chainspec_path.to_str().unwrap())
|
.with_chain_spec_path(template_chainspec_path.to_path_buf())
|
||||||
.with_chain("asset-hub-westend-local")
|
.with_chain("asset-hub-westend-local")
|
||||||
.with_collator(|node_config| {
|
.with_collator(|node_config| {
|
||||||
node_config
|
node_config
|
||||||
@@ -247,6 +251,7 @@ impl ZombienetNode {
|
|||||||
.arg(u32::MAX.to_string())
|
.arg(u32::MAX.to_string())
|
||||||
.arg("--rpc-port")
|
.arg("--rpc-port")
|
||||||
.arg(eth_rpc_port.to_string())
|
.arg(eth_rpc_port.to_string())
|
||||||
|
.env("RUST_LOG", Self::PROXY_LOG_ENV)
|
||||||
.stdout(stdout_file)
|
.stdout(stdout_file)
|
||||||
.stderr(stderr_file);
|
.stderr(stderr_file);
|
||||||
},
|
},
|
||||||
@@ -557,37 +562,46 @@ impl EthereumNode for ZombienetNode {
|
|||||||
+ '_,
|
+ '_,
|
||||||
>,
|
>,
|
||||||
> {
|
> {
|
||||||
|
fn create_stream(
|
||||||
|
provider: ConcreteProvider<ReviveNetwork, Arc<EthereumWallet>>,
|
||||||
|
) -> impl Stream<Item = MinedBlockInformation> {
|
||||||
|
stream! {
|
||||||
|
let mut block_number = provider.get_block_number().await.expect("Failed to get the block number");
|
||||||
|
loop {
|
||||||
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||||
|
|
||||||
|
let Ok(Some(block)) = provider.get_block_by_number(BlockNumberOrTag::Number(block_number)).await
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
block_number += 1;
|
||||||
|
yield MinedBlockInformation {
|
||||||
|
block_number: block.number(),
|
||||||
|
block_timestamp: block.header.timestamp,
|
||||||
|
mined_gas: block.header.gas_used as _,
|
||||||
|
block_gas_limit: block.header.gas_limit,
|
||||||
|
transaction_hashes: block
|
||||||
|
.transactions
|
||||||
|
.into_hashes()
|
||||||
|
.as_hashes()
|
||||||
|
.expect("Must be hashes")
|
||||||
|
.to_vec(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let provider = self
|
let provider = self
|
||||||
.provider()
|
.provider()
|
||||||
.await
|
.await
|
||||||
.context("Failed to create the provider for block subscription")?;
|
.context("Failed to create the provider for a block subscription")?;
|
||||||
let mut block_subscription = provider
|
|
||||||
.watch_full_blocks()
|
|
||||||
.await
|
|
||||||
.context("Failed to create the blocks stream")?;
|
|
||||||
block_subscription.set_channel_size(0xFFFF);
|
|
||||||
block_subscription.set_poll_interval(Duration::from_secs(1));
|
|
||||||
let block_stream = block_subscription.into_stream();
|
|
||||||
|
|
||||||
let mined_block_information_stream = block_stream.filter_map(|block| async {
|
let stream = Box::pin(create_stream(provider))
|
||||||
let block = block.ok()?;
|
as Pin<Box<dyn Stream<Item = MinedBlockInformation>>>;
|
||||||
Some(MinedBlockInformation {
|
|
||||||
block_number: block.number(),
|
|
||||||
block_timestamp: block.header.timestamp,
|
|
||||||
mined_gas: block.header.gas_used as _,
|
|
||||||
block_gas_limit: block.header.gas_limit,
|
|
||||||
transaction_hashes: block
|
|
||||||
.transactions
|
|
||||||
.into_hashes()
|
|
||||||
.as_hashes()
|
|
||||||
.expect("Must be hashes")
|
|
||||||
.to_vec(),
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(Box::pin(mined_block_information_stream)
|
Ok(stream)
|
||||||
as Pin<Box<dyn Stream<Item = MinedBlockInformation>>>)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-4
@@ -7,6 +7,10 @@ use alloy::{
|
|||||||
transports::TransportResult,
|
transports::TransportResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Percentage padding applied to estimated gas (e.g. 120 = 20% padding)
|
||||||
|
const GAS_ESTIMATE_PADDING_NUMERATOR: u64 = 120;
|
||||||
|
const GAS_ESTIMATE_PADDING_DENOMINATOR: u64 = 100;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct FallbackGasFiller {
|
pub struct FallbackGasFiller {
|
||||||
inner: GasFiller,
|
inner: GasFiller,
|
||||||
@@ -56,8 +60,6 @@ where
|
|||||||
provider: &P,
|
provider: &P,
|
||||||
tx: &<N as Network>::TransactionRequest,
|
tx: &<N as Network>::TransactionRequest,
|
||||||
) -> TransportResult<Self::Fillable> {
|
) -> TransportResult<Self::Fillable> {
|
||||||
// Try to fetch GasFiller’s “fillable” (gas_price, base_fee, estimate_gas, …)
|
|
||||||
// If it errors (i.e. tx would revert under eth_estimateGas), swallow it.
|
|
||||||
match self.inner.prepare(provider, tx).await {
|
match self.inner.prepare(provider, tx).await {
|
||||||
Ok(fill) => Ok(Some(fill)),
|
Ok(fill) => Ok(Some(fill)),
|
||||||
Err(_) => Ok(None),
|
Err(_) => Ok(None),
|
||||||
@@ -70,8 +72,17 @@ where
|
|||||||
mut tx: alloy::providers::SendableTx<N>,
|
mut tx: alloy::providers::SendableTx<N>,
|
||||||
) -> TransportResult<SendableTx<N>> {
|
) -> TransportResult<SendableTx<N>> {
|
||||||
if let Some(fill) = fillable {
|
if let Some(fill) = fillable {
|
||||||
// our inner GasFiller succeeded — use it
|
let mut tx = self.inner.fill(fill, tx).await?;
|
||||||
self.inner.fill(fill, tx).await
|
if let Some(builder) = tx.as_mut_builder() {
|
||||||
|
if let Some(estimated) = builder.gas_limit() {
|
||||||
|
let padded = estimated
|
||||||
|
.checked_mul(GAS_ESTIMATE_PADDING_NUMERATOR)
|
||||||
|
.and_then(|v| v.checked_div(GAS_ESTIMATE_PADDING_DENOMINATOR))
|
||||||
|
.unwrap_or(u64::MAX);
|
||||||
|
builder.set_gas_limit(padded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(tx)
|
||||||
} else {
|
} else {
|
||||||
if let Some(builder) = tx.as_mut_builder() {
|
if let Some(builder) = tx.as_mut_builder() {
|
||||||
builder.set_gas_limit(self.default_gas_limit);
|
builder.set_gas_limit(self.default_gas_limit);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
mod concurrency_limiter;
|
mod concurrency_limiter;
|
||||||
mod fallback_gas_provider;
|
mod fallback_gas_filler;
|
||||||
mod provider;
|
mod provider;
|
||||||
|
|
||||||
pub use concurrency_limiter::*;
|
pub use concurrency_limiter::*;
|
||||||
pub use fallback_gas_provider::*;
|
pub use fallback_gas_filler::*;
|
||||||
pub use provider::*;
|
pub use provider::*;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use alloy::{
|
|||||||
};
|
};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use revive_dt_common::futures::{PollingWaitBehavior, poll};
|
use revive_dt_common::futures::{PollingWaitBehavior, poll};
|
||||||
use tracing::debug;
|
use tracing::{Instrument, debug, info, info_span};
|
||||||
|
|
||||||
use crate::provider_utils::{ConcurrencyLimiterLayer, FallbackGasFiller};
|
use crate::provider_utils::{ConcurrencyLimiterLayer, FallbackGasFiller};
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ where
|
|||||||
// requests at any point of time and no more than that. This is done in an effort to stabilize
|
// requests at any point of time and no more than that. This is done in an effort to stabilize
|
||||||
// the framework from some of the interment issues that we've been seeing related to RPC calls.
|
// the framework from some of the interment issues that we've been seeing related to RPC calls.
|
||||||
static GLOBAL_CONCURRENCY_LIMITER_LAYER: LazyLock<ConcurrencyLimiterLayer> =
|
static GLOBAL_CONCURRENCY_LIMITER_LAYER: LazyLock<ConcurrencyLimiterLayer> =
|
||||||
LazyLock::new(|| ConcurrencyLimiterLayer::new(10));
|
LazyLock::new(|| ConcurrencyLimiterLayer::new(500));
|
||||||
|
|
||||||
let client = ClientBuilder::default()
|
let client = ClientBuilder::default()
|
||||||
.layer(GLOBAL_CONCURRENCY_LIMITER_LAYER.clone())
|
.layer(GLOBAL_CONCURRENCY_LIMITER_LAYER.clone())
|
||||||
@@ -117,12 +117,16 @@ where
|
|||||||
|
|
||||||
async move {
|
async move {
|
||||||
match provider.get_transaction_receipt(tx_hash).await {
|
match provider.get_transaction_receipt(tx_hash).await {
|
||||||
Ok(Some(receipt)) => Ok(ControlFlow::Break(receipt)),
|
Ok(Some(receipt)) => {
|
||||||
|
info!("Found the transaction receipt");
|
||||||
|
Ok(ControlFlow::Break(receipt))
|
||||||
|
}
|
||||||
_ => Ok(ControlFlow::Continue(())),
|
_ => Ok(ControlFlow::Continue(())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
.instrument(info_span!("Polling for receipt", %tx_hash))
|
||||||
.await
|
.await
|
||||||
.context(format!("Polling for receipt failed for {tx_hash}"))
|
.context(format!("Polling for receipt failed for {tx_hash}"))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user