diff --git a/Cargo.lock b/Cargo.lock index b9d088a..6318f4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,6 +79,12 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +[[package]] +name = "arc-swap" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" + [[package]] name = "ark-ff" version = "0.3.0" @@ -552,8 +558,9 @@ dependencies = [ [[package]] name = "client" version = "0.4.1" -source = "git+https://github.com/eigerco/helios?rev=07cc7af#07cc7af979219c4d4880910cd903af0a39a038db" +source = "git+https://github.com/eigerco/helios?rev=62c7237#62c7237c592025c028a32046a766c2b6780d114e" dependencies = [ + "arc-swap", "common", "config", "consensus", @@ -585,7 +592,7 @@ dependencies = [ [[package]] name = "common" version = "0.4.1" -source = "git+https://github.com/eigerco/helios?rev=07cc7af#07cc7af979219c4d4880910cd903af0a39a038db" +source = "git+https://github.com/eigerco/helios?rev=62c7237#62c7237c592025c028a32046a766c2b6780d114e" dependencies = [ "candid", "ethers-core", @@ -602,7 +609,7 @@ dependencies = [ [[package]] name = "config" version = "0.4.1" -source = "git+https://github.com/eigerco/helios?rev=07cc7af#07cc7af979219c4d4880910cd903af0a39a038db" +source = "git+https://github.com/eigerco/helios?rev=62c7237#62c7237c592025c028a32046a766c2b6780d114e" dependencies = [ "common", "ethers-core", @@ -623,7 +630,7 @@ dependencies = [ [[package]] name = "consensus" version = "0.4.1" -source = "git+https://github.com/eigerco/helios?rev=07cc7af#07cc7af979219c4d4880910cd903af0a39a038db" +source = "git+https://github.com/eigerco/helios?rev=62c7237#62c7237c592025c028a32046a766c2b6780d114e" dependencies = [ "async-trait", "bytes", @@ -1164,7 +1171,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "execution" version = "0.4.1" -source = "git+https://github.com/eigerco/helios?rev=07cc7af#07cc7af979219c4d4880910cd903af0a39a038db" +source = "git+https://github.com/eigerco/helios?rev=62c7237#62c7237c592025c028a32046a766c2b6780d114e" dependencies = [ "async-trait", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 40a5f7e..093d477 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,13 +9,20 @@ ethers-contract = { version = "2.0.9", default-features = false, features = [ ] } ethers-core = "2.0.9" eyre = "0.6.8" -helios_client = { package = "client", git = "https://github.com/eigerco/helios", rev = "07cc7af" } -helios_common = { package = "common", git = "https://github.com/eigerco/helios", rev = "07cc7af" } -helios_config = { package = "config", git = "https://github.com/eigerco/helios", rev = "07cc7af" } -helios_execution = { package = "execution", git = "https://github.com/eigerco/helios", rev = "07cc7af" } +helios_client = { package = "client", git = "https://github.com/eigerco/helios", rev = "62c7237" } +helios_common = { package = "common", git = "https://github.com/eigerco/helios", rev = "62c7237" } +helios_config = { package = "config", git = "https://github.com/eigerco/helios", rev = "62c7237" } +helios_execution = { package = "execution", git = "https://github.com/eigerco/helios", rev = "62c7237" } interface = { path = "src/interface" } [profile.release] opt-level = "z" lto = true codegen-units = 1 + +# Uncomment to apply local changes of Helios +#[patch.'https://github.com/eigerco/helios'] +#client = { path = "../helios/client" } +#common = { path = "../helios/common" } +#config = { path = "../helios/config" } +#execution = { path = "../helios/execution" } diff --git a/src/ethereum-canister/src/helios.rs b/src/ethereum-canister/src/helios.rs index 7edae57..2d6ef8b 100644 --- a/src/ethereum-canister/src/helios.rs +++ b/src/ethereum-canister/src/helios.rs @@ -69,9 +69,9 @@ pub(crate) async fn start_client( Ok(()) } -pub(crate) async fn get_last_checkpoint() -> Option { +pub(crate) fn get_last_checkpoint() -> Option { match try_client() { - Some(client) => client.get_last_checkpoint().await, + Some(client) => client.get_last_checkpoint(), None => None, } } diff --git a/src/ethereum-canister/src/lib.rs b/src/ethereum-canister/src/lib.rs index 4a431a2..2bbb0e7 100644 --- a/src/ethereum-canister/src/lib.rs +++ b/src/ethereum-canister/src/lib.rs @@ -62,22 +62,19 @@ async fn setup(request: SetupRequest) { } #[query] -async fn get_block_number() -> Nat { +fn get_block_number() -> Nat { let helios = helios::client(); - let head_block_num = helios - .get_block_number() - .await - .expect("get_block_number failed"); + let head_block_num = helios.get_block_number().expect("get_block_number failed"); head_block_num.into() } #[query] -async fn get_gas_price() -> U256 { +fn get_gas_price() -> U256 { let helios = helios::client(); - let gas_price = helios.get_gas_price().await.expect("get_gas_price failed"); + let gas_price = helios.get_gas_price().expect("get_gas_price failed"); gas_price.into() } @@ -114,7 +111,7 @@ async fn erc721_owner_of(request: Erc721OwnerOfRequest) -> Address { async fn pre_upgrade() { debug!("Stopping client"); - let checkpoint = helios::get_last_checkpoint().await; + let checkpoint = helios::get_last_checkpoint(); save_static_string(&LAST_CHECKPOINT, checkpoint); helios::shutdown().await; @@ -123,7 +120,7 @@ async fn pre_upgrade() { } #[post_upgrade] -async fn post_upgrade() { +fn post_upgrade() { let _ = ic_logger::init_with_level(log::Level::Trace); // Workaround because cross-canister calls are not allowed in post_upgrade. @@ -131,20 +128,20 @@ async fn post_upgrade() { set_timer(std::time::Duration::from_secs(1), || { ic_cdk::spawn(async move { let Some(network) = load_static_string(&LAST_NETWORK) else { - return + return; }; let Ok(network) = network.parse::() else { error!("Failed to parse network: {network}. Use `setup` to initalize canister."); - return + return; }; let Some(consensus_rpc_url) = load_static_string(&LAST_CONSENSUS_RPC_URL) else { - return + return; }; let Some(execution_rpc_url) = load_static_string(&LAST_EXECUTION_RPC_URL) else { - return + return; }; let checkpoint = load_static_string(&LAST_CHECKPOINT);