From 6d8f5d40f20506d91c27ae46f9f679140aca1500 Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:50:43 +0300 Subject: [PATCH 1/5] feat(crates-io): publish gbuiltins (#4306) --- Cargo.lock | 2 +- gbuiltins/staking/Cargo.toml | 4 ++-- gbuiltins/staking/src/lib.rs | 4 +--- utils/crates-io/src/lib.rs | 3 +++ 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f721de284e4..bd513d4afba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6217,8 +6217,8 @@ dependencies = [ name = "gbuiltin-staking" version = "1.6.2" dependencies = [ - "derive_more 0.99.18", "gprimitives", + "parity-scale-codec", "scale-info", ] diff --git a/gbuiltins/staking/Cargo.toml b/gbuiltins/staking/Cargo.toml index b3e6404913c..71860b4b882 100644 --- a/gbuiltins/staking/Cargo.toml +++ b/gbuiltins/staking/Cargo.toml @@ -9,6 +9,6 @@ homepage.workspace = true repository.workspace = true [dependencies] -gprimitives.workspace = true -derive_more.workspace = true +parity-scale-codec = { workspace = true, features = ["derive"] } scale-info = { workspace = true, features = ["derive"] } +gprimitives = { workspace = true, features = ["codec"] } diff --git a/gbuiltins/staking/src/lib.rs b/gbuiltins/staking/src/lib.rs index ae3912404d7..ae71c44efc8 100644 --- a/gbuiltins/staking/src/lib.rs +++ b/gbuiltins/staking/src/lib.rs @@ -60,14 +60,13 @@ extern crate alloc; use alloc::vec::Vec; use gprimitives::ActorId; -use scale_info::scale::{self, Decode, Encode}; +use parity_scale_codec::{Decode, Encode}; /// Type that should be used to create a message to the staking built-in actor. /// /// A [partial] mirror of the staking pallet interface. Not all extrinsics /// are supported, more can be added as needed for real-world use cases. #[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)] -#[codec(crate = scale)] pub enum Request { /// Bond up to the `value` from the sender to self as the controller. Bond { value: u128, payee: RewardAccount }, @@ -93,7 +92,6 @@ pub enum Request { /// /// A "mirror" of the staking pallet's `RewardDestination` enum. #[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, Debug)] -#[codec(crate = scale)] pub enum RewardAccount { /// Pay rewards to the sender's account and increase the amount at stake. Staked, diff --git a/utils/crates-io/src/lib.rs b/utils/crates-io/src/lib.rs index e0b4f4fb71e..ea24b531bee 100644 --- a/utils/crates-io/src/lib.rs +++ b/utils/crates-io/src/lib.rs @@ -49,6 +49,7 @@ pub const SAFE_DEPENDENCIES: &[&str] = &[ "gsdk-codegen", "gsys", "numerated", + "gbuiltin-bls381", ]; /// Required packages with local dependencies. @@ -58,6 +59,8 @@ pub const SAFE_DEPENDENCIES: &[&str] = &[ /// the order. pub const STACKED_DEPENDENCIES: &[&str] = &[ "gprimitives", + "gbuiltin-eth-bridge", + "gbuiltin-staking", "gstd-codegen", "gcore", "gmeta", From 40ae438cf24e19a79766740509dd1d2ebaf03803 Mon Sep 17 00:00:00 2001 From: playX18 <158266309+playX18@users.noreply.github.com> Date: Thu, 24 Oct 2024 00:03:01 +0700 Subject: [PATCH 2/5] refactor(gstd,utils,runtime-interface): get rid of uncecessary clippy lints (#4305) Co-authored-by: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> --- gstd/src/prelude.rs | 2 +- runtime-interface/sandbox/src/detail.rs | 6 ++---- utils/gring/src/keyring.rs | 1 - utils/gring/src/keystore.rs | 1 - 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/gstd/src/prelude.rs b/gstd/src/prelude.rs index ee7a1ee6a76..6b45123eb5a 100644 --- a/gstd/src/prelude.rs +++ b/gstd/src/prelude.rs @@ -61,7 +61,7 @@ pub mod collections { /// /// [`alloc::ffi`]: ::alloc::ffi pub mod ffi { - pub use ::alloc::ffi::*; + pub use ::alloc::ffi::{CString, FromVecWithNulError, IntoStringError, NulError}; pub use core::ffi::*; } diff --git a/runtime-interface/sandbox/src/detail.rs b/runtime-interface/sandbox/src/detail.rs index 68ca0fd5792..647b0b76d1e 100644 --- a/runtime-interface/sandbox/src/detail.rs +++ b/runtime-interface/sandbox/src/detail.rs @@ -73,7 +73,6 @@ struct SupervisorContext<'a, 'b> { } impl<'a, 'b> sandbox_env::SupervisorContext for SupervisorContext<'a, 'b> { - #[allow(clippy::needless_borrows_for_generic_args)] fn invoke( &mut self, invoke_args_ptr: Pointer, @@ -82,7 +81,7 @@ impl<'a, 'b> sandbox_env::SupervisorContext for SupervisorContext<'a, 'b> { ) -> gear_sandbox_host::error::Result { let mut ret_vals = [Val::null()]; let result = self.dispatch_thunk.call( - &mut self.caller, + &mut *self.caller, &[ Val::I32(u32::from(invoke_args_ptr) as i32), Val::I32(invoke_args_len as i32), @@ -479,7 +478,6 @@ pub fn memory_new(context: &mut dyn FunctionContext, initial: u32, maximum: u32) method_result } -#[allow(clippy::needless_borrows_for_generic_args)] pub fn memory_set( context: &mut dyn FunctionContext, memory_idx: u32, @@ -494,7 +492,7 @@ pub fn memory_set( sp_wasm_interface::with_caller_mut(context, |caller| { trace("memory_set", caller); - let Ok(buffer) = read_memory(&caller, val_ptr, val_len) else { + let Ok(buffer) = read_memory(&mut *caller, val_ptr, val_len) else { method_result = sandbox_env::env::ERR_OUT_OF_BOUNDS; return; }; diff --git a/utils/gring/src/keyring.rs b/utils/gring/src/keyring.rs index ab1caaa0fd9..822bb7e55b2 100644 --- a/utils/gring/src/keyring.rs +++ b/utils/gring/src/keyring.rs @@ -76,7 +76,6 @@ impl Keyring { } /// Update and get the primary key. - #[allow(clippy::assigning_clones)] pub fn primary(&mut self) -> Result { if self.ring.is_empty() { return Err(anyhow!( diff --git a/utils/gring/src/keystore.rs b/utils/gring/src/keystore.rs index 36a3c7bbdd1..a9a499a43b8 100644 --- a/utils/gring/src/keystore.rs +++ b/utils/gring/src/keystore.rs @@ -137,7 +137,6 @@ impl Keystore { } /// Returns self with the given name in meta. - #[allow(clippy::assigning_clones)] pub fn with_name(mut self, name: &str) -> Self { self.meta.name = name.to_owned(); self From 291bf27fa7fb759edef2f8ce21b9662c017cdd26 Mon Sep 17 00:00:00 2001 From: Arsenii Lyashenko Date: Thu, 24 Oct 2024 18:28:31 +0300 Subject: [PATCH 3/5] feat(ethexe): Initial on-chain `db-sync` request validation (#4243) --- ethexe/cli/src/service.rs | 87 +++++++++--- ethexe/cli/src/tests.rs | 5 + ethexe/ethereum/src/lib.rs | 4 + ethexe/ethereum/src/router/mod.rs | 17 ++- ethexe/network/src/db_sync/mod.rs | 188 ++++++++++++++++++++++---- ethexe/network/src/db_sync/ongoing.rs | 161 ++++++++++++++++++---- ethexe/network/src/lib.rs | 73 +++++++++- ethexe/network/src/peer_score.rs | 8 ++ 8 files changed, 462 insertions(+), 81 deletions(-) diff --git a/ethexe/cli/src/service.rs b/ethexe/cli/src/service.rs index a418816637b..b9b17dde143 100644 --- a/ethexe/cli/src/service.rs +++ b/ethexe/cli/src/service.rs @@ -22,7 +22,7 @@ use crate::{ config::{Config, ConfigPublicKey, PrometheusConfig}, metrics::MetricsService, }; -use anyhow::{anyhow, Ok, Result}; +use anyhow::{anyhow, Result}; use ethexe_common::{ router::{ BlockCommitment, CodeCommitment, RequestEvent as RouterRequestEvent, StateTransition, @@ -30,8 +30,8 @@ use ethexe_common::{ BlockRequestEvent, }; use ethexe_db::{BlockMetaStorage, CodesStorage, Database}; -use ethexe_ethereum::router::RouterQuery; -use ethexe_network::NetworkReceiverEvent; +use ethexe_ethereum::{primitives::U256, router::RouterQuery}; +use ethexe_network::{db_sync, NetworkReceiverEvent}; use ethexe_observer::{RequestBlockData, RequestEvent}; use ethexe_processor::LocalOutcome; use ethexe_sequencer::agro::AggregatedCommitments; @@ -53,6 +53,7 @@ pub struct Service { db: Database, observer: ethexe_observer::Observer, query: ethexe_observer::Query, + router_query: RouterQuery, processor: ethexe_processor::Processor, signer: ethexe_signer::Signer, block_time: Duration, @@ -186,6 +187,7 @@ impl Service { network, observer, query, + router_query, processor, sequencer, signer, @@ -210,6 +212,7 @@ impl Service { db: Database, observer: ethexe_observer::Observer, query: ethexe_observer::Query, + router_query: RouterQuery, processor: ethexe_processor::Processor, signer: ethexe_signer::Signer, block_time: Duration, @@ -223,6 +226,7 @@ impl Service { db, observer, query, + router_query, processor, signer, block_time, @@ -404,6 +408,7 @@ impl Service { network, mut observer, mut query, + mut router_query, mut processor, mut sequencer, signer: _signer, @@ -505,25 +510,39 @@ impl Service { validation_round_timer.stop(); } - event = maybe_await(network_receiver.as_mut().map(|rx| rx.recv())) => { - let Some(NetworkReceiverEvent::Message { source, data }) = event else { - continue; - }; - - log::debug!("Received a network message from peer {source:?}"); - - let result = Self::process_network_message( - data.as_slice(), - &db, - validator.as_mut(), - sequencer.as_mut(), - network_sender.as_mut(), - ); - - if let Err(err) = result { - // TODO: slash peer/validator in case of error #4175 - // TODO: consider error log as temporary solution #4175 - log::warn!("Failed to process network message: {err}"); + Some(event) = maybe_await(network_receiver.as_mut().map(|rx| rx.recv())) => { + match event { + NetworkReceiverEvent::Message { source, data } => { + log::debug!("Received a network message from peer {source:?}"); + + let result = Self::process_network_message( + data.as_slice(), + &db, + validator.as_mut(), + sequencer.as_mut(), + network_sender.as_mut(), + ); + + if let Err(err) = result { + // TODO: slash peer/validator in case of error #4175 + // TODO: consider error log as temporary solution #4175 + log::warn!("Failed to process network message: {err}"); + } + } + NetworkReceiverEvent::ExternalValidation(validating_response) => { + let validated = Self::process_response_validation(&validating_response, &mut router_query).await?; + let res = if validated { + Ok(validating_response) + } else { + Err(validating_response) + }; + + network_sender + .as_mut() + .expect("if network receiver is `Some()` so does sender") + .request_validated(res); + } + _ => {} } } _ = maybe_await(network_handle.as_mut()) => { @@ -781,6 +800,30 @@ impl Service { } } } + + async fn process_response_validation( + validating_response: &db_sync::ValidatingResponse, + router_query: &mut RouterQuery, + ) -> Result { + let response = validating_response.response(); + + if let db_sync::Response::ProgramIds(ids) = response { + let ethereum_programs = router_query.programs_count().await?; + if ethereum_programs != U256::from(ids.len()) { + return Ok(false); + } + + // TODO: #4309 + for &id in ids { + let code_id = router_query.program_code_id(id).await?; + if code_id.is_none() { + return Ok(false); + } + } + } + + Ok(true) + } } mod utils { diff --git a/ethexe/cli/src/tests.rs b/ethexe/cli/src/tests.rs index a15a9f1fda9..9146bd20a3f 100644 --- a/ethexe/cli/src/tests.rs +++ b/ethexe/cli/src/tests.rs @@ -1274,6 +1274,10 @@ mod utils { .await .unwrap(); + let router_query = RouterQuery::new(&self.rpc_url, self.router_address) + .await + .unwrap(); + let network = self.network_address.as_ref().map(|addr| { let config_path = tempfile::tempdir().unwrap().into_path(); let mut config = @@ -1322,6 +1326,7 @@ mod utils { self.db.clone(), self.observer.clone(), query, + router_query, processor, self.signer.clone(), self.block_time, diff --git a/ethexe/ethereum/src/lib.rs b/ethexe/ethereum/src/lib.rs index ac5164a5b00..190fb01934e 100644 --- a/ethexe/ethereum/src/lib.rs +++ b/ethexe/ethereum/src/lib.rs @@ -57,6 +57,10 @@ pub mod mirror; pub mod router; pub mod wvara; +pub mod primitives { + pub use alloy::primitives::*; +} + pub(crate) type AlloyTransport = BoxTransport; type AlloyProvider = FillProvider, AlloyTransport, AlloyEthereum>; diff --git a/ethexe/ethereum/src/router/mod.rs b/ethexe/ethereum/src/router/mod.rs index e096b1b4d32..f80e189bc92 100644 --- a/ethexe/ethereum/src/router/mod.rs +++ b/ethexe/ethereum/src/router/mod.rs @@ -19,7 +19,7 @@ use crate::{abi::IRouter, wvara::WVara, AlloyProvider, AlloyTransport, TryGetReceipt}; use alloy::{ consensus::{SidecarBuilder, SimpleCoder}, - primitives::{Address, Bytes, B256}, + primitives::{Address, Bytes, B256, U256}, providers::{Provider, ProviderBuilder, RootProvider}, rpc::types::Filter, transports::BoxTransport, @@ -29,7 +29,7 @@ use ethexe_common::router::{BlockCommitment, CodeCommitment}; use ethexe_signer::{Address as LocalAddress, Signature as LocalSignature}; use events::signatures; use futures::StreamExt; -use gear_core::ids::prelude::CodeIdExt as _; +use gear_core::ids::{prelude::CodeIdExt as _, ProgramId}; use gprimitives::{ActorId, CodeId, H160, H256}; use std::sync::Arc; @@ -275,4 +275,17 @@ impl RouterQuery { .map(|res| res._0.to()) .map_err(Into::into) } + + pub async fn programs_count(&self) -> Result { + let count = self.instance.programsCount().call().await?; + Ok(count._0) + } + + pub async fn program_code_id(&self, program_id: ProgramId) -> Result> { + let program_id = LocalAddress::try_from(program_id).expect("infallible"); + let program_id = Address::new(program_id.0); + let code_id = self.instance.programCodeId(program_id).call().await?; + let code_id = Some(CodeId::new(code_id._0.0)).filter(|&code_id| code_id != CodeId::zero()); + Ok(code_id) + } } diff --git a/ethexe/network/src/db_sync/mod.rs b/ethexe/network/src/db_sync/mod.rs index 66ae4900d60..967ed3b41ff 100644 --- a/ethexe/network/src/db_sync/mod.rs +++ b/ethexe/network/src/db_sync/mod.rs @@ -18,9 +18,11 @@ mod ongoing; +pub use ongoing::ValidatingResponse; + use crate::{ db_sync::ongoing::{ - OngoingRequests, OngoingResponses, PeerFailed, PeerResponse, SendRequestError, + ExternalValidation, OngoingRequests, OngoingResponses, PeerResponse, SendRequestError, SendRequestErrorKind, }, export::{Multiaddr, PeerId}, @@ -42,7 +44,7 @@ use libp2p::{ }; use parity_scale_codec::{Decode, Encode}; use std::{ - collections::{BTreeMap, BTreeSet}, + collections::{BTreeMap, BTreeSet, VecDeque}, task::{Context, Poll}, time::Duration, }; @@ -77,7 +79,7 @@ impl Request { } } (Request::ProgramIds, Response::ProgramIds(_ids)) => None, - _ => unreachable!("should be checked in `validate_response`"), + _ => unreachable!("should be checked in `Response::validate()`"), } } } @@ -107,11 +109,14 @@ impl Response { (Response::ProgramIds(ids), Response::ProgramIds(new_ids)) => { ids.extend(new_ids); } - _ => unreachable!("should be checked in `validate_response`"), + _ => unreachable!("should be checked in `Response::validate()`"), } } - fn validate(&self, request: &Request) -> Result<(), ResponseValidationError> { + /// Validates response against request. + /// + /// Returns `false` if external validation is required. + fn validate(&self, request: &Request) -> Result { match (request, self) { (Request::DataForHashes(_requested_hashes), Response::DataForHashes(hashes)) => { for (hash, data) in hashes { @@ -120,9 +125,9 @@ impl Response { } } - Ok(()) + Ok(true) } - (Request::ProgramIds, Response::ProgramIds(_ids)) => Ok(()), + (Request::ProgramIds, Response::ProgramIds(_ids)) => Ok(false), (_, _) => Err(ResponseValidationError::TypeMismatch), } } @@ -145,7 +150,7 @@ impl Response { true } (Request::ProgramIds, Response::ProgramIds(_ids)) => false, - _ => unreachable!("should be checked in `validate_response`"), + _ => unreachable!("should be checked in `Response::validate()`"), } } } @@ -184,6 +189,8 @@ pub enum Event { //// The ID of request request_id: RequestId, }, + /// External validation is mandatory for response + ExternalValidation(ValidatingResponse), /// Request completion done RequestSucceed { /// The ID of request @@ -261,6 +268,7 @@ type InnerBehaviour = request_response::Behaviour, peer_score_handle: peer_score::Handle, ongoing_requests: OngoingRequests, ongoing_responses: OngoingResponses, @@ -274,6 +282,7 @@ impl Behaviour { [(STREAM_PROTOCOL, ProtocolSupport::Full)], request_response::Config::default(), ), + pending_events: VecDeque::new(), peer_score_handle: peer_score_handle.clone(), ongoing_requests: OngoingRequests::new(&config, peer_score_handle), ongoing_responses: OngoingResponses::new(db, &config), @@ -284,6 +293,44 @@ impl Behaviour { self.ongoing_requests.push_pending_request(request) } + pub(crate) fn request_validated( + &mut self, + res: Result, + ) { + let res = self + .ongoing_requests + .on_external_validation(res, &mut self.inner); + let event = match res { + Ok(ExternalValidation::Success { + request_id, + response, + }) => Event::RequestSucceed { + request_id, + response, + }, + Ok(ExternalValidation::NewRound { + peer_id, + request_id, + }) => Event::NewRequestRound { + request_id, + peer_id, + reason: NewRequestRoundReason::PartialData, + }, + Err(SendRequestError { + request_id, + kind: SendRequestErrorKind::OutOfRounds, + }) => Event::RequestFailed { + request_id, + error: RequestFailure::OutOfRounds, + }, + Err(SendRequestError { + request_id, + kind: SendRequestErrorKind::NoPeers, + }) => Event::PendingStateRequest { request_id }, + }; + self.pending_events.push_back(event); + } + fn handle_inner_event( &mut self, event: request_response::Event, @@ -327,11 +374,14 @@ impl Behaviour { request_id, response, ) { - Ok((request_id, response)) => Event::RequestSucceed { + Ok(PeerResponse::Success { + request_id, + response, + }) => Event::RequestSucceed { request_id, response, }, - Err(PeerResponse::NewRound { + Ok(PeerResponse::NewRound { peer_id, request_id, }) => Event::NewRequestRound { @@ -339,17 +389,20 @@ impl Behaviour { peer_id, reason: NewRequestRoundReason::PartialData, }, - Err(PeerResponse::SendRequest(SendRequestError { + Ok(PeerResponse::ExternalValidation(validating_response)) => { + Event::ExternalValidation(validating_response) + } + Err(SendRequestError { request_id, kind: SendRequestErrorKind::OutOfRounds, - })) => Event::RequestFailed { + }) => Event::RequestFailed { request_id, error: RequestFailure::OutOfRounds, }, - Err(PeerResponse::SendRequest(SendRequestError { + Err(SendRequestError { request_id, - kind: SendRequestErrorKind::Pending, - })) => Event::PendingStateRequest { request_id }, + kind: SendRequestErrorKind::NoPeers, + }) => Event::PendingStateRequest { request_id }, }; return Poll::Ready(ToSwarm::GenerateEvent(event)); @@ -376,17 +429,17 @@ impl Behaviour { peer_id, reason: NewRequestRoundReason::PeerFailed, }, - Err(PeerFailed::SendRequest(SendRequestError { + Err(SendRequestError { request_id, kind: SendRequestErrorKind::OutOfRounds, - })) => Event::RequestFailed { + }) => Event::RequestFailed { request_id, error: RequestFailure::OutOfRounds, }, - Err(PeerFailed::SendRequest(SendRequestError { + Err(SendRequestError { request_id, - kind: SendRequestErrorKind::Pending, - })) => Event::PendingStateRequest { request_id }, + kind: SendRequestErrorKind::NoPeers, + }) => Event::PendingStateRequest { request_id }, }; return Poll::Ready(ToSwarm::GenerateEvent(event)); @@ -494,6 +547,10 @@ impl NetworkBehaviour for Behaviour { })); } + if let Some(event) = self.pending_events.pop_front() { + return Poll::Ready(ToSwarm::GenerateEvent(event)); + } + let event = match self.ongoing_requests.send_pending_request(&mut self.inner) { Ok(Some((peer_id, request_id))) => Some(Event::NewRequestRound { request_id, @@ -510,7 +567,7 @@ impl NetworkBehaviour for Behaviour { }), Err(SendRequestError { request_id: _, - kind: SendRequestErrorKind::Pending, + kind: SendRequestErrorKind::NoPeers, }) => None, }; if let Some(event) = event { @@ -598,17 +655,14 @@ mod tests { #[tokio::test] async fn smoke() { - const PID1: ProgramId = ProgramId::new([1; 32]); - const PID2: ProgramId = ProgramId::new([2; 32]); - init_logger(); let (mut alice, _alice_db) = new_swarm().await; let (mut bob, bob_db) = new_swarm().await; let bob_peer_id = *bob.local_peer_id(); - bob_db.set_program_code_id(PID1, CodeId::zero()); - bob_db.set_program_code_id(PID2, CodeId::zero()); + let hello_hash = bob_db.write(b"hello"); + let world_hash = bob_db.write(b"world"); alice.connect(&mut bob).await; tokio::spawn(async move { @@ -640,7 +694,9 @@ mod tests { } }); - let request_id = alice.behaviour_mut().request(Request::ProgramIds); + let request_id = alice + .behaviour_mut() + .request(Request::DataForHashes([hello_hash, world_hash].into())); let event = alice.next_behaviour_event().await; assert_eq!( @@ -657,7 +713,13 @@ mod tests { event, Event::RequestSucceed { request_id, - response: Response::ProgramIds([PID1, PID2].into()) + response: Response::DataForHashes( + [ + (hello_hash, b"hello".to_vec()), + (world_hash, b"world".to_vec()) + ] + .into() + ) } ) } @@ -1035,4 +1097,74 @@ mod tests { let event = alice.next_behaviour_event().await; assert!(matches!(event, Event::ResponseSent { peer_id, .. } if peer_id == bob_peer_id)); } + + #[tokio::test] + async fn external_validation() { + const PID1: ProgramId = ProgramId::new([1; 32]); + const PID2: ProgramId = ProgramId::new([2; 32]); + + init_logger(); + + let (mut alice, _alice_db) = new_swarm().await; + let (mut bob, _bob_db) = new_swarm().await; + let (mut charlie, charlie_db) = new_swarm().await; + let bob_peer_id = *bob.local_peer_id(); + let charlie_peer_id = *charlie.local_peer_id(); + + alice.connect(&mut bob).await; + tokio::spawn(bob.loop_on_next()); + + charlie_db.set_program_code_id(PID1, CodeId::zero()); + charlie_db.set_program_code_id(PID2, CodeId::zero()); + + let request_id = alice.behaviour_mut().request(Request::ProgramIds); + + let event = alice.next_behaviour_event().await; + assert_eq!( + event, + Event::NewRequestRound { + request_id, + peer_id: bob_peer_id, + reason: NewRequestRoundReason::FromQueue, + } + ); + + let event = alice.next_behaviour_event().await; + if let Event::ExternalValidation(validating_response) = event { + assert_eq!(validating_response.peer_id(), bob_peer_id); + let response = validating_response.response(); + assert_eq!(*response, Response::ProgramIds([].into())); + alice + .behaviour_mut() + .request_validated(Err(validating_response)); + } else { + unreachable!(); + } + + alice.connect(&mut charlie).await; + tokio::spawn(charlie.loop_on_next()); + + // `Event::NewRequestRound` skipped by `connect()` above + + let event = alice.next_behaviour_event().await; + if let Event::ExternalValidation(validating_response) = event { + assert_eq!(validating_response.peer_id(), charlie_peer_id); + let response = validating_response.response(); + assert_eq!(*response, Response::ProgramIds([PID1, PID2].into())); + alice + .behaviour_mut() + .request_validated(Ok(validating_response)); + } else { + unreachable!(); + } + + let event = alice.next_behaviour_event().await; + assert_eq!( + event, + Event::RequestSucceed { + request_id, + response: Response::ProgramIds([PID1, PID2].into()), + } + ); + } } diff --git a/ethexe/network/src/db_sync/ongoing.rs b/ethexe/network/src/db_sync/ongoing.rs index cd1e481c784..6374312c696 100644 --- a/ethexe/network/src/db_sync/ongoing.rs +++ b/ethexe/network/src/db_sync/ongoing.rs @@ -46,23 +46,54 @@ pub(crate) struct SendRequestError { #[derive(Debug)] pub(crate) enum SendRequestErrorKind { OutOfRounds, - Pending, + NoPeers, } -#[derive(Debug, derive_more::From)] +#[derive(Debug)] pub(crate) enum PeerResponse { + Success { + request_id: RequestId, + response: Response, + }, NewRound { peer_id: PeerId, request_id: RequestId, }, - #[from] - SendRequest(SendRequestError), + ExternalValidation(ValidatingResponse), } -#[derive(Debug, derive_more::From)] -pub(crate) enum PeerFailed { - #[from] - SendRequest(SendRequestError), +#[derive(Debug)] +pub(crate) enum ExternalValidation { + Success { + request_id: RequestId, + response: Response, + }, + NewRound { + peer_id: PeerId, + request_id: RequestId, + }, +} + +#[derive(Debug, Eq, PartialEq)] +pub struct ValidatingResponse { + ongoing_request: OngoingRequest, + peer_id: PeerId, + response: Response, +} + +impl ValidatingResponse { + pub fn request(&self) -> &Request { + &self.ongoing_request.request + } + + pub fn response(&self) -> &Response { + &self.response + } + + #[cfg(test)] + pub(crate) fn peer_id(&self) -> PeerId { + self.peer_id + } } #[derive(Debug)] @@ -76,6 +107,14 @@ pub(crate) struct OngoingRequest { peer_score_handle: Handle, } +impl PartialEq for OngoingRequest { + fn eq(&self, other: &Self) -> bool { + self.request_id == other.request_id + } +} + +impl Eq for OngoingRequest {} + impl OngoingRequest { pub(crate) fn new( request_id: RequestId, @@ -94,7 +133,7 @@ impl OngoingRequest { } } - fn inner_complete(&mut self, peer: PeerId, new_response: Response) -> Response { + fn merge_and_strip(&mut self, peer: PeerId, new_response: Response) -> Response { let mut response = if let Some(mut response) = self.response.take() { response.merge(new_response); response @@ -113,25 +152,53 @@ impl OngoingRequest { response } + fn inner_complete( + mut self, + peer: PeerId, + response: Response, + ) -> Result<(RequestId, Response), Self> { + if let Some(new_request) = self.request.difference(&response) { + self.request = new_request; + self.response = Some(self.merge_and_strip(peer, response)); + Err(self) + } else { + let request_id = self.request_id; + let response = self.merge_and_strip(peer, response); + Ok((request_id, response)) + } + } + /// Try to bring the request to the complete state. /// /// Returns `Err(self)` if response validation is failed or response is incomplete. - fn try_complete(mut self, peer: PeerId, response: Response) -> Result { + fn try_complete(mut self, peer: PeerId, response: Response) -> Result { self.tried_peers.insert(peer); - if let Err(error) = response.validate(&self.request) { - let request_id = self.request_id; - log::trace!( - "response validation failed for request {request_id:?} from {peer}: {error:?}", - ); - Err(self) - } else if let Some(new_request) = self.request.difference(&response) { - self.request = new_request; - self.response = Some(self.inner_complete(peer, response)); - Err(self) - } else { - let response = self.inner_complete(peer, response); - Ok(response) + let request_id = self.request_id; + + match response.validate(&self.request) { + Ok(true) => self + .inner_complete(peer, response) + .map(|(request_id, response)| PeerResponse::Success { + request_id, + response, + }), + Ok(false) => { + let validating_response = ValidatingResponse { + ongoing_request: self, + peer_id: peer, + response, + }; + Ok(PeerResponse::ExternalValidation(validating_response)) + } + Err(error) => { + log::trace!( + "response validation failed for request {request_id:?} from {peer}: {error:?}", + ); + self.peer_score_handle.invalid_data(peer); + + Err(self) + } } } @@ -269,7 +336,7 @@ impl OngoingRequests { self.pending_requests.push_back(ongoing_request); Err(SendRequestError { request_id, - kind: SendRequestErrorKind::Pending, + kind: SendRequestErrorKind::NoPeers, }) } } @@ -293,7 +360,7 @@ impl OngoingRequests { peer: PeerId, request_id: OutboundRequestId, response: Response, - ) -> Result<(RequestId, Response), PeerResponse> { + ) -> Result { let ongoing_request = self .active_requests .remove(&request_id) @@ -301,12 +368,50 @@ impl OngoingRequests { let request_id = ongoing_request.request_id; let new_ongoing_request = match ongoing_request.try_complete(peer, response) { - Ok(response) => return Ok((request_id, response)), + Ok(peer_response) => return Ok(peer_response), Err(new_ongoing_request) => new_ongoing_request, }; let peer_id = self.send_request(behaviour, new_ongoing_request)?; - Err(PeerResponse::NewRound { + Ok(PeerResponse::NewRound { + peer_id, + request_id, + }) + } + + pub(crate) fn on_external_validation( + &mut self, + res: Result, + behaviour: &mut InnerBehaviour, + ) -> Result { + let new_ongoing_request = match res { + Ok(validating_response) => { + let ValidatingResponse { + ongoing_request, + peer_id, + response, + } = validating_response; + + match ongoing_request.inner_complete(peer_id, response) { + Ok((request_id, response)) => { + return Ok(ExternalValidation::Success { + request_id, + response, + }) + } + Err(new_ongoing_request) => new_ongoing_request, + } + } + Err(validating_response) => { + self.peer_score_handle + .invalid_data(validating_response.peer_id); + validating_response.ongoing_request + } + }; + + let request_id = new_ongoing_request.request_id; + let peer_id = self.send_request(behaviour, new_ongoing_request)?; + Ok(ExternalValidation::NewRound { peer_id, request_id, }) @@ -317,7 +422,7 @@ impl OngoingRequests { behaviour: &mut InnerBehaviour, peer: PeerId, request_id: OutboundRequestId, - ) -> Result<(PeerId, RequestId), PeerFailed> { + ) -> Result<(PeerId, RequestId), SendRequestError> { let ongoing_request = self .active_requests .remove(&request_id) diff --git a/ethexe/network/src/lib.rs b/ethexe/network/src/lib.rs index 53fbb3950f9..a7d7c39116f 100644 --- a/ethexe/network/src/lib.rs +++ b/ethexe/network/src/lib.rs @@ -122,6 +122,7 @@ impl NetworkService { enum NetworkSenderEvent { PublishMessage { data: Vec }, RequestDbData(db_sync::Request), + RequestValidated(Result), } #[derive(Debug, Clone)] @@ -147,6 +148,13 @@ impl NetworkSender { pub fn request_db_data(&self, request: db_sync::Request) { let _res = self.tx.send(NetworkSenderEvent::RequestDbData(request)); } + + pub fn request_validated( + &self, + res: Result, + ) { + let _res = self.tx.send(NetworkSenderEvent::RequestValidated(res)); + } } #[derive(Debug, Eq, PartialEq)] @@ -157,6 +165,7 @@ pub enum NetworkReceiverEvent { }, DbResponse(Result), PeerBlocked(PeerId), + ExternalValidation(db_sync::ValidatingResponse), } pub struct NetworkReceiver { @@ -437,6 +446,13 @@ impl NetworkEventLoop { } BehaviourEvent::Gossipsub(_) => {} // + BehaviourEvent::DbSync(db_sync::Event::ExternalValidation(validating_response)) => { + let _res = self + .external_tx + .send(NetworkReceiverEvent::ExternalValidation( + validating_response, + )); + } BehaviourEvent::DbSync(db_sync::Event::RequestSucceed { request_id: _, response, @@ -472,6 +488,9 @@ impl NetworkEventLoop { NetworkSenderEvent::RequestDbData(request) => { self.swarm.behaviour_mut().db_sync.request(request); } + NetworkSenderEvent::RequestValidated(res) => { + self.swarm.behaviour_mut().db_sync.request_validated(res); + } } } } @@ -703,7 +722,7 @@ mod tests { let mut service1 = NetworkService::new(config.clone(), &signer1, db).unwrap(); let peer_id = service1.event_loop.local_peer_id(); - let multiaddr: Multiaddr = format!("/memory/3/p2p/{peer_id}").parse().unwrap(); + let multiaddr: Multiaddr = format!("/memory/5/p2p/{peer_id}").parse().unwrap(); let peer_score_handle = service1.event_loop.score_handle(); @@ -733,4 +752,56 @@ mod tests { Some(NetworkReceiverEvent::PeerBlocked(service2_peer_id)) ); } + + #[tokio::test] + async fn external_validation() { + init_logger(); + + let tmp_dir1 = tempfile::tempdir().unwrap(); + let config = NetworkEventLoopConfig::new_memory(tmp_dir1.path().to_path_buf(), "/memory/7"); + let signer1 = ethexe_signer::Signer::new(tmp_dir1.path().join("key")).unwrap(); + let db = Database::from_one(&MemDb::default(), [0; 20]); + let mut service1 = NetworkService::new(config.clone(), &signer1, db).unwrap(); + + let peer_id = service1.event_loop.local_peer_id(); + let multiaddr: Multiaddr = format!("/memory/7/p2p/{peer_id}").parse().unwrap(); + + tokio::spawn(service1.event_loop.run()); + + // second service + let tmp_dir2 = tempfile::tempdir().unwrap(); + let signer2 = ethexe_signer::Signer::new(tmp_dir2.path().join("key")).unwrap(); + let mut config2 = + NetworkEventLoopConfig::new_memory(tmp_dir2.path().to_path_buf(), "/memory/8"); + config2.bootstrap_addresses = [multiaddr].into(); + let db = Database::from_one(&MemDb::default(), [0; 20]); + let service2 = NetworkService::new(config2.clone(), &signer2, db).unwrap(); + tokio::spawn(service2.event_loop.run()); + + // Wait for the connection to be established + tokio::time::sleep(Duration::from_secs(1)).await; + + service1 + .sender + .request_db_data(db_sync::Request::ProgramIds); + + let event = timeout(Duration::from_secs(5), service1.receiver.recv()) + .await + .expect("time has elapsed") + .unwrap(); + if let NetworkReceiverEvent::ExternalValidation(validating_response) = event { + service1.sender.request_validated(Ok(validating_response)); + } else { + unreachable!(); + } + + let event = timeout(Duration::from_secs(5), service1.receiver.recv()) + .await + .expect("time has elapsed") + .unwrap(); + assert_eq!( + event, + NetworkReceiverEvent::DbResponse(Ok(db_sync::Response::ProgramIds([].into()))) + ); + } } diff --git a/ethexe/network/src/peer_score.rs b/ethexe/network/src/peer_score.rs index 14bea14d156..1a0caec83c5 100644 --- a/ethexe/network/src/peer_score.rs +++ b/ethexe/network/src/peer_score.rs @@ -35,6 +35,7 @@ use tokio::sync::mpsc; pub(crate) enum ScoreChangedReason { UnsupportedProtocol, ExcessiveData, + InvalidData, } impl ScoreChangedReason { @@ -42,6 +43,7 @@ impl ScoreChangedReason { match self { ScoreChangedReason::UnsupportedProtocol => config.unsupported_protocol, ScoreChangedReason::ExcessiveData => config.excessive_data, + ScoreChangedReason::InvalidData => config.invalid_data, } } } @@ -67,6 +69,10 @@ impl Handle { pub fn excessive_data(&self, peer_id: PeerId) { let _res = self.0.send((peer_id, ScoreChangedReason::ExcessiveData)); } + + pub fn invalid_data(&self, peer_id: PeerId) { + let _res = self.0.send((peer_id, ScoreChangedReason::InvalidData)); + } } #[derive(Debug, Eq, PartialEq)] @@ -95,6 +101,7 @@ pub(crate) enum Event { pub(crate) struct Config { unsupported_protocol: u8, excessive_data: u8, + invalid_data: u8, } impl Default for Config { @@ -102,6 +109,7 @@ impl Default for Config { Self { unsupported_protocol: u8::MAX, excessive_data: u8::MAX, + invalid_data: u8::MAX, } } } From 73929e309d40aceec8da761b8b2313eab7ea41a4 Mon Sep 17 00:00:00 2001 From: Sabaun Taraki Date: Thu, 24 Oct 2024 20:05:39 +0300 Subject: [PATCH 4/5] feat(pallet-gear-builtin): Add proxy builtin (#4259) Co-authored-by: Dmitry Novikov --- Cargo.lock | 23 ++++ Cargo.toml | 3 + examples/proxy-broker/Cargo.toml | 21 ++++ examples/proxy-broker/build.rs | 21 ++++ examples/proxy-broker/src/lib.rs | 33 +++++ examples/proxy-broker/src/wasm.rs | 72 +++++++++++ gbuiltins/proxy/Cargo.toml | 14 +++ gbuiltins/proxy/src/lib.rs | 64 ++++++++++ pallets/gear-builtin/Cargo.toml | 4 + pallets/gear-builtin/src/lib.rs | 44 +++++++ pallets/gear-builtin/src/mock.rs | 105 +++++++++++++++- pallets/gear-builtin/src/proxy.rs | 95 ++++++++++++++ pallets/gear-builtin/src/staking.rs | 44 +------ pallets/gear-builtin/src/tests/mod.rs | 9 +- pallets/gear-builtin/src/tests/proxy.rs | 160 ++++++++++++++++++++++++ runtime/vara/Cargo.toml | 1 + runtime/vara/src/lib.rs | 17 +++ 17 files changed, 682 insertions(+), 48 deletions(-) create mode 100644 examples/proxy-broker/Cargo.toml create mode 100644 examples/proxy-broker/build.rs create mode 100644 examples/proxy-broker/src/lib.rs create mode 100644 examples/proxy-broker/src/wasm.rs create mode 100644 gbuiltins/proxy/Cargo.toml create mode 100644 gbuiltins/proxy/src/lib.rs create mode 100644 pallets/gear-builtin/src/proxy.rs create mode 100644 pallets/gear-builtin/src/tests/proxy.rs diff --git a/Cargo.lock b/Cargo.lock index bd513d4afba..5f080df16e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3769,6 +3769,16 @@ dependencies = [ "scale-info", ] +[[package]] +name = "demo-proxy-broker" +version = "0.1.0" +dependencies = [ + "gbuiltin-proxy", + "gear-wasm-builder", + "gstd", + "parity-scale-codec", +] + [[package]] name = "demo-proxy-relay" version = "0.1.0" @@ -6213,6 +6223,15 @@ dependencies = [ "scale-info", ] +[[package]] +name = "gbuiltin-proxy" +version = "1.6.2" +dependencies = [ + "derive_more 0.99.18", + "gprimitives", + "scale-info", +] + [[package]] name = "gbuiltin-staking" version = "1.6.2" @@ -11485,6 +11504,7 @@ dependencies = [ "ark-scale 0.0.12", "ark-serialize 0.4.2", "ark-std 0.4.0", + "demo-proxy-broker", "demo-staking-broker", "demo-waiting-proxy", "derive_more 0.99.18", @@ -11496,6 +11516,7 @@ dependencies = [ "frame-support-test", "frame-system", "gbuiltin-bls381", + "gbuiltin-proxy", "gbuiltin-staking", "gear-common", "gear-core", @@ -11514,6 +11535,7 @@ dependencies = [ "pallet-gear-messenger", "pallet-gear-program", "pallet-gear-scheduler", + "pallet-proxy", "pallet-session", "pallet-staking", "pallet-timestamp", @@ -18846,6 +18868,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", + "gbuiltin-proxy", "gbuiltin-staking", "gear-common", "gear-core", diff --git a/Cargo.toml b/Cargo.toml index da0cb93b1f8..d8ed67f243c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,6 +62,7 @@ members = [ "examples/program-factory", "examples/program-generator", "examples/proxy", + "examples/proxy-broker", "examples/proxy-relay", "examples/proxy-reservation-with-gas", "examples/read-big-state", @@ -216,6 +217,7 @@ galloc = { path = "galloc" } gbuiltin-bls381 = { path = "gbuiltins/bls381", default-features = false } gbuiltin-eth-bridge = { path = "gbuiltins/eth-bridge", default-features = false } gbuiltin-staking = { path = "gbuiltins/staking" } +gbuiltin-proxy = { path = "gbuiltins/proxy" } gcore = { path = "gcore" } gcli = { path = "gcli" } gclient = { path = "gclient" } @@ -484,6 +486,7 @@ demo-rwlock = { path = "examples/rwlock" } demo-send-from-reservation = { path = "examples/send-from-reservation" } demo-signal-entry = { path = "examples/signal-entry", default-features = false } demo-staking-broker = { path = "examples/staking-broker" } +demo-proxy-broker = { path = "examples/proxy-broker" } demo-state-rollback = { path = "examples/state-rollback" } demo-sync-duplicate = { path = "examples/sync-duplicate" } demo-vec = { path = "examples/vec" } diff --git a/examples/proxy-broker/Cargo.toml b/examples/proxy-broker/Cargo.toml new file mode 100644 index 00000000000..d0d1a943a99 --- /dev/null +++ b/examples/proxy-broker/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "demo-proxy-broker" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +gbuiltin-proxy.workspace = true +gstd.workspace = true +parity-scale-codec.workspace = true + +[build-dependencies] +gear-wasm-builder.workspace = true + +[features] +debug = ["gstd/debug"] +std = [] +default = ["std"] diff --git a/examples/proxy-broker/build.rs b/examples/proxy-broker/build.rs new file mode 100644 index 00000000000..6a370b53a71 --- /dev/null +++ b/examples/proxy-broker/build.rs @@ -0,0 +1,21 @@ +// This file is part of Gear. + +// Copyright (C) 2024 Gear Technologies Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +fn main() { + gear_wasm_builder::build(); +} diff --git a/examples/proxy-broker/src/lib.rs b/examples/proxy-broker/src/lib.rs new file mode 100644 index 00000000000..28b7cf0f8c3 --- /dev/null +++ b/examples/proxy-broker/src/lib.rs @@ -0,0 +1,33 @@ +// This file is part of Gear. +// +// Copyright (C) 2024 Gear Technologies Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(feature = "std")] +mod code { + include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +} + +#[cfg(feature = "std")] +pub use code::WASM_BINARY_OPT as WASM_BINARY; + +#[cfg(not(feature = "std"))] +pub const WASM_BINARY: &[u8] = &[]; + +#[cfg(not(feature = "std"))] +pub mod wasm; diff --git a/examples/proxy-broker/src/wasm.rs b/examples/proxy-broker/src/wasm.rs new file mode 100644 index 00000000000..f3f9225360e --- /dev/null +++ b/examples/proxy-broker/src/wasm.rs @@ -0,0 +1,72 @@ +// This file is part of Gear. +// +// Copyright (C) 2024 Gear Technologies Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Basic implementation of the proxy-broker for demo purpose only. + +use gbuiltin_proxy::Request; +use gstd::{actor_id, debug, errors::Error, msg, ActorId}; + +// Proxy builtin actor program id (hardcoded for all runtimes); +// +// Calculated as hash((b"built/in", 3u64).encode()) +const BUILTIN_ADDRESS: ActorId = + actor_id!("0xf2816ced0b15749595392d3a18b5a2363d6fefe5b3b6153739f218151b7acdbf"); + +#[gstd::async_main] +async fn main() { + let request: Request = msg::load().expect("handle: invalid payload received"); + match request { + add_proxy @ Request::AddProxy { .. } => { + debug!( + "handle: Sending `add_proxy` request with data {:?}", + add_proxy + ); + + send_request(add_proxy).await; + } + remove_proxy @ Request::RemoveProxy { .. } => { + debug!( + "handle: Sending `remove_proxy` request with data {:?}", + remove_proxy + ); + + send_request(remove_proxy).await; + } + } +} + +async fn send_request(req: Request) { + let res = msg::send_for_reply(BUILTIN_ADDRESS, req, 0, 0) + .expect("handle::send_request: failed sending message for reply") + .await; + match res { + Ok(_) => { + debug!("handle::send_request: Success reply from builtin actor received"); + msg::reply_bytes(b"Success", 0).expect("Failed to send reply"); + } + Err(e) => { + debug!("handle::send_request: Error reply from builtin actor received: {e:?}"); + match e { + Error::ErrorReply(payload, _) => { + panic!("{}", payload); + } + _ => panic!("Error in upstream program"), + } + } + } +} diff --git a/gbuiltins/proxy/Cargo.toml b/gbuiltins/proxy/Cargo.toml new file mode 100644 index 00000000000..4912223625b --- /dev/null +++ b/gbuiltins/proxy/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "gbuiltin-proxy" +description = "Types and traits to interact with proxy builtin actor." +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +gprimitives.workspace = true +derive_more.workspace = true +scale-info = { workspace = true, features = ["derive"] } diff --git a/gbuiltins/proxy/src/lib.rs b/gbuiltins/proxy/src/lib.rs new file mode 100644 index 00000000000..49eecad834b --- /dev/null +++ b/gbuiltins/proxy/src/lib.rs @@ -0,0 +1,64 @@ +// This file is part of Gear. + +// Copyright (C) 2021-2024 Gear Technologies Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Types used to communicate with proxy built-in. + +#![no_std] + +use gprimitives::ActorId; +use scale_info::scale::{self, Decode, Encode}; + +/// Request that can be handled by the proxy builtin. +/// +/// Currently all proxies aren't required to send announcement, +/// i.e. no delays for the delegate actions. +#[derive(Debug, Clone, Copy, Eq, PartialEq, Encode, Decode)] +#[codec(crate = scale)] +pub enum Request { + /// Add proxy request. + /// + /// Requests to add `delegate` as a delegate for the actions + /// defined by `proxy_type` to be done on behalf of the request + /// sender. + AddProxy { + delegate: ActorId, + proxy_type: ProxyType, + }, + /// Remove proxy request. + /// + /// Request sender asks to remove `delegate` with set of allowed actions + /// defined in `proxy_type` from his list of proxies. + RemoveProxy { + delegate: ActorId, + proxy_type: ProxyType, + }, +} + +/// Proxy type. +/// +/// The mirror enum for the one defined in vara-runtime crate. +#[derive(Debug, Clone, Copy, Eq, PartialEq, Encode, Decode)] +#[codec(crate = scale)] +pub enum ProxyType { + Any, + NonTransfer, + Governance, + Staking, + IdentityJudgement, + CancelProxy, +} diff --git a/pallets/gear-builtin/Cargo.toml b/pallets/gear-builtin/Cargo.toml index cbb9c77edf4..4430f848c20 100644 --- a/pallets/gear-builtin/Cargo.toml +++ b/pallets/gear-builtin/Cargo.toml @@ -30,6 +30,7 @@ common.workspace = true core-processor.workspace = true gbuiltin-bls381.workspace = true gbuiltin-staking.workspace = true +gbuiltin-proxy.workspace = true gear-core.workspace = true gear-core-errors.workspace = true gear-runtime-interface.workspace = true @@ -41,10 +42,12 @@ sp-std.workspace = true sp-runtime = { workspace = true, features = ["serde"] } pallet-gear.workspace = true pallet-staking.workspace = true +pallet-proxy.workspace = true [dev-dependencies] demo-waiting-proxy.workspace = true demo-staking-broker.workspace = true +demo-proxy-broker.workspace = true gprimitives.workspace = true sp-core = { workspace = true, features = ["std"] } sp-externalities = { workspace = true, features = ["std"] } @@ -81,6 +84,7 @@ std = [ "gear-runtime-interface/std", "pallet-gear/std", "pallet-staking/std", + "pallet-proxy/std", "parity-scale-codec/std", "scale-info/std", "sp-crypto-ec-utils/std", diff --git a/pallets/gear-builtin/src/lib.rs b/pallets/gear-builtin/src/lib.rs index e31069a873e..4109567c7ad 100644 --- a/pallets/gear-builtin/src/lib.rs +++ b/pallets/gear-builtin/src/lib.rs @@ -36,6 +36,7 @@ extern crate alloc; pub mod benchmarking; pub mod bls12_381; +pub mod proxy; pub mod staking; pub mod weights; @@ -58,6 +59,7 @@ use core_processor::{ process_execution_error, process_success, SuccessfulDispatchResultKind, SystemReservationContext, }; +use frame_support::dispatch::extract_actual_weight; use gear_core::{ gas::GasCounter, ids::{hash, ProgramId}, @@ -73,6 +75,8 @@ use sp_std::prelude::*; pub use pallet::*; +type CallOf = ::RuntimeCall; + const LOG_TARGET: &str = "gear::builtin"; /// Built-in actor error type @@ -172,6 +176,7 @@ impl BuiltinCollection for Tuple { #[frame_support::pallet] pub mod pallet { use super::*; + use common::Origin; use frame_support::{ dispatch::{GetDispatchInfo, PostDispatchInfo}, pallet_prelude::*, @@ -212,6 +217,45 @@ pub mod pallet { pub fn generate_actor_id(builtin_id: u64) -> ProgramId { hash((SEED, builtin_id).encode().as_slice()).into() } + + pub(crate) fn dispatch_call( + origin: ProgramId, + call: CallOf, + gas_limit: u64, + ) -> (Result<(), BuiltinActorError>, u64) + where + T::AccountId: Origin, + { + let call_info = call.get_dispatch_info(); + + // Necessary upfront gas sufficiency check + if gas_limit < call_info.weight.ref_time() { + return (Err(BuiltinActorError::InsufficientGas), 0_u64); + } + + // Execute call + let res = call.dispatch(frame_system::RawOrigin::Signed(origin.cast()).into()); + let actual_gas = extract_actual_weight(&res, &call_info).ref_time(); + + match res { + Ok(_post_info) => { + log::debug!( + target: LOG_TARGET, + "Call dispatched successfully", + ); + (Ok(()), actual_gas) + } + Err(e) => { + log::debug!(target: LOG_TARGET, "Error dispatching call: {:?}", e); + ( + Err(BuiltinActorError::Custom(LimitedStr::from_small_str( + e.into(), + ))), + actual_gas, + ) + } + } + } } } diff --git a/pallets/gear-builtin/src/mock.rs b/pallets/gear-builtin/src/mock.rs index 98ce908b8b7..77d22b0809b 100644 --- a/pallets/gear-builtin/src/mock.rs +++ b/pallets/gear-builtin/src/mock.rs @@ -16,23 +16,27 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{self as pallet_gear_builtin, bls12_381, ActorWithId, BuiltinActor, BuiltinActorError}; +use crate::{ + self as pallet_gear_builtin, bls12_381, proxy, ActorWithId, BuiltinActor, BuiltinActorError, +}; use common::{GasProvider, GasTree}; use core::cell::RefCell; use frame_support::{ construct_runtime, parameter_types, - traits::{ConstBool, ConstU32, ConstU64, FindAuthor, OnFinalize, OnInitialize}, + traits::{ConstBool, ConstU32, ConstU64, FindAuthor, InstanceFilter, OnFinalize, OnInitialize}, }; use frame_support_test::TestRandomness; use frame_system::{self as system, pallet_prelude::BlockNumberFor}; +use gbuiltin_proxy::ProxyType as BuiltinProxyType; use gear_core::{ ids::ProgramId, message::{Payload, StoredDispatch}, }; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use sp_core::H256; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, - BuildStorage, Perbill, Permill, + BuildStorage, Perbill, Permill, RuntimeDebug, }; use sp_std::convert::{TryFrom, TryInto}; @@ -79,6 +83,7 @@ construct_runtime!( Authorship: pallet_authorship, Timestamp: pallet_timestamp, Staking: pallet_staking, + Proxy: pallet_proxy, GearProgram: pallet_gear_program, GearMessenger: pallet_gear_messenger, GearScheduler: pallet_gear_scheduler, @@ -94,12 +99,105 @@ parameter_types! { pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT; } +#[derive( + Copy, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + Encode, + Decode, + RuntimeDebug, + MaxEncodedLen, + scale_info::TypeInfo, +)] +pub enum ProxyType { + Any, + NonTransfer, + Governance, + Staking, + IdentityJudgement, + CancelProxy, +} + +impl Default for ProxyType { + fn default() -> Self { + Self::Any + } +} + +impl From for ProxyType { + fn from(proxy_type: BuiltinProxyType) -> Self { + match proxy_type { + BuiltinProxyType::Any => ProxyType::Any, + BuiltinProxyType::NonTransfer => ProxyType::NonTransfer, + BuiltinProxyType::Governance => ProxyType::Governance, + BuiltinProxyType::Staking => ProxyType::Staking, + BuiltinProxyType::IdentityJudgement => ProxyType::IdentityJudgement, + BuiltinProxyType::CancelProxy => ProxyType::CancelProxy, + } + } +} + +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { + match self { + ProxyType::Any => true, + ProxyType::NonTransfer => !matches!(c, RuntimeCall::Balances(..)), + ProxyType::CancelProxy => { + matches!( + c, + RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) + ) + } + ProxyType::Staking => matches!(c, RuntimeCall::Staking(..)), + ProxyType::Governance | ProxyType::IdentityJudgement => { + unimplemented!("No pallets defined in test runtime") + } + } + } + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + (ProxyType::NonTransfer, _) => true, + _ => false, + } + } +} + common::impl_pallet_system!(Test); common::impl_pallet_balances!(Test); common::impl_pallet_authorship!(Test); common::impl_pallet_timestamp!(Test); common::impl_pallet_staking!(Test); +parameter_types! { + pub const ProxyDepositBase: Balance = 1; + pub const ProxyDepositFactor: Balance = 1; + pub const MaxProxies: u32 = 100; + pub const MaxPending: u32 = 100; + pub const AnnouncementDepositBase: Balance = 1; + pub const AnnouncementDepositFactor: Balance = 1; +} + +impl pallet_proxy::Config for Test { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type ProxyType = ProxyType; + type ProxyDepositBase = ProxyDepositBase; + type ProxyDepositFactor = ProxyDepositFactor; + type MaxProxies = MaxProxies; + type WeightInfo = (); + type MaxPending = MaxPending; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositBase; +} + parameter_types! { pub const BlockGasLimit: u64 = 100_000_000_000; pub const OutgoingLimit: u32 = 1024; @@ -222,6 +320,7 @@ impl pallet_gear_builtin::Config for Test { ActorWithId, ActorWithId, ActorWithId<1, bls12_381::Actor>, + ActorWithId<3, proxy::Actor>, ); type WeightInfo = (); } diff --git a/pallets/gear-builtin/src/proxy.rs b/pallets/gear-builtin/src/proxy.rs new file mode 100644 index 00000000000..0a68ca2c5c2 --- /dev/null +++ b/pallets/gear-builtin/src/proxy.rs @@ -0,0 +1,95 @@ +// This file is part of Gear. + +// Copyright (C) 2024 Gear Technologies Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Proxy builtin actor implementation. + +use super::*; +use common::Origin; +use gbuiltin_proxy::{ProxyType as BuiltinProxyType, Request}; +use pallet_proxy::Config as ProxyConfig; +use sp_runtime::traits::StaticLookup; + +/// Proxy builtin actor. +pub struct Actor(PhantomData); + +impl Actor +where + T::AccountId: Origin, + ::ProxyType: From, + CallOf: From>, +{ + /// Casts received request to a runtime call. + fn cast(request: Request) -> Result, BuiltinActorError> { + Ok(match request { + Request::AddProxy { + delegate, + proxy_type, + } => { + let delegate = T::Lookup::unlookup(delegate.cast()); + let proxy_type = proxy_type.into(); + let delay = 0u32.into(); + + pallet_proxy::Call::::add_proxy { + delegate, + proxy_type, + delay, + } + } + Request::RemoveProxy { + delegate, + proxy_type, + } => { + let delegate = T::Lookup::unlookup(delegate.cast()); + let proxy_type = proxy_type.into(); + let delay = 0u32.into(); + + pallet_proxy::Call::::remove_proxy { + delegate, + proxy_type, + delay, + } + } + } + .into()) + } +} + +impl BuiltinActor for Actor +where + T::AccountId: Origin, + ::ProxyType: From, + CallOf: From>, +{ + type Error = BuiltinActorError; + + fn handle(dispatch: &StoredDispatch, gas_limit: u64) -> (Result, u64) { + let Ok(request) = Request::decode(&mut dispatch.payload_bytes()) else { + return (Err(BuiltinActorError::DecodingError), 0); + }; + + let origin = dispatch.source(); + + match Self::cast(request) { + Ok(call) => { + let (result, actual_gas) = Pallet::::dispatch_call(origin, call, gas_limit); + (result.map(|_| Default::default()), actual_gas) + } + Err(e) => (Err(e), gas_limit), + } + } +} diff --git a/pallets/gear-builtin/src/staking.rs b/pallets/gear-builtin/src/staking.rs index d6900bb5f68..a5a24370cd5 100644 --- a/pallets/gear-builtin/src/staking.rs +++ b/pallets/gear-builtin/src/staking.rs @@ -21,13 +21,10 @@ use super::*; use common::Origin; use core::marker::PhantomData; -use frame_support::dispatch::{extract_actual_weight, GetDispatchInfo}; use gbuiltin_staking::*; use pallet_staking::{Config as StakingConfig, NominationsQuota, RewardDestination}; use parity_scale_codec::Decode; -use sp_runtime::traits::{Dispatchable, StaticLookup, UniqueSaturatedInto}; - -type CallOf = ::RuntimeCall; +use sp_runtime::traits::{StaticLookup, UniqueSaturatedInto}; pub struct Actor(PhantomData); @@ -36,41 +33,6 @@ where T::AccountId: Origin, CallOf: From>, { - fn dispatch_call( - origin: T::AccountId, - call: CallOf, - gas_limit: u64, - ) -> (Result<(), BuiltinActorError>, u64) { - let call_info = call.get_dispatch_info(); - - // Necessary upfront gas sufficiency check - if gas_limit < call_info.weight.ref_time() { - return (Err(BuiltinActorError::InsufficientGas), 0_u64); - } - - // Execute call - let res = call.dispatch(frame_system::RawOrigin::Signed(origin).into()); - let actual_gas = extract_actual_weight(&res, &call_info).ref_time(); - match res { - Ok(_post_info) => { - log::debug!( - target: LOG_TARGET, - "Call dispatched successfully", - ); - (Ok(()), actual_gas) - } - Err(e) => { - log::debug!(target: LOG_TARGET, "Error dispatching call: {:?}", e); - ( - Err(BuiltinActorError::Custom(LimitedStr::from_small_str( - e.into(), - ))), - actual_gas, - ) - } - } - } - fn cast(request: Request) -> CallOf { match request { Request::Bond { value, payee } => { @@ -146,7 +108,7 @@ where fn handle(dispatch: &StoredDispatch, gas_limit: u64) -> (Result, u64) { let message = dispatch.message(); - let origin: T::AccountId = dispatch.source().cast(); + let origin = dispatch.source(); let mut payload = message.payload_bytes(); // Rule out payloads that exceed the largest reasonable size. @@ -169,7 +131,7 @@ where // Handle staking requests let call = Self::cast(request); - let (result, gas_spent) = Self::dispatch_call(origin, call, gas_limit); + let (result, gas_spent) = Pallet::::dispatch_call(origin, call, gas_limit); (result.map(|_| Default::default()), gas_spent) } diff --git a/pallets/gear-builtin/src/tests/mod.rs b/pallets/gear-builtin/src/tests/mod.rs index d071cfd12b6..99ab57e66a4 100644 --- a/pallets/gear-builtin/src/tests/mod.rs +++ b/pallets/gear-builtin/src/tests/mod.rs @@ -18,7 +18,8 @@ //! Builtin actor pallet tests. -pub mod bad_builtin_ids; -pub mod basic; -pub mod bls381; -pub mod staking; +mod bad_builtin_ids; +mod basic; +mod bls381; +mod proxy; +mod staking; diff --git a/pallets/gear-builtin/src/tests/proxy.rs b/pallets/gear-builtin/src/tests/proxy.rs new file mode 100644 index 00000000000..d693d9b902c --- /dev/null +++ b/pallets/gear-builtin/src/tests/proxy.rs @@ -0,0 +1,160 @@ +// This file is part of Gear. + +// Copyright (C) 2021-2024 Gear Technologies Inc. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Proxy builtin tests. + +use super::basic::init_logger; +use crate::mock::*; +use common::Origin; +use demo_proxy_broker::WASM_BINARY; +use frame_support::{assert_err, assert_ok}; +use gbuiltin_proxy::{ProxyType, Request}; +use gear_core::ids::{prelude::*, CodeId, ProgramId}; +use pallet_balances::Call as BalancesCall; +use pallet_proxy::{Error as ProxyError, Event as ProxyEvent}; +use parity_scale_codec::Encode; + +#[test] +fn add_remove_proxy_works() { + init_logger(); + new_test_ext().execute_with(|| { + let proxy_pid = utils::upload_and_initialize_broker(); + + // Add proxy + let add_proxy_req = Request::AddProxy { + delegate: SIGNER.cast(), + proxy_type: ProxyType::Any, + }; + utils::send_proxy_request(proxy_pid, add_proxy_req); + + System::assert_has_event(RuntimeEvent::Proxy(ProxyEvent::ProxyAdded { + delegator: proxy_pid.cast(), + delegatee: SIGNER, + proxy_type: ProxyType::Any.into(), + delay: 0, + })); + + System::reset_events(); + + // Remove proxy + let remove_proxy_req = Request::RemoveProxy { + delegate: SIGNER.cast(), + proxy_type: ProxyType::Any, + }; + utils::send_proxy_request(proxy_pid, remove_proxy_req); + + System::assert_has_event(RuntimeEvent::Proxy(ProxyEvent::ProxyRemoved { + delegator: proxy_pid.cast(), + delegatee: SIGNER, + proxy_type: ProxyType::Any.into(), + delay: 0, + })); + + // Execute proxy + let dest = 42; + let value = EXISTENTIAL_DEPOSIT * 3; + let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest, value }); + + assert_err!( + Proxy::proxy( + RuntimeOrigin::signed(SIGNER), + proxy_pid.cast(), + None, + Box::new(call) + ), + ProxyError::::NotProxy, + ); + }) +} + +#[test] +fn add_execute_proxy_works() { + init_logger(); + new_test_ext().execute_with(|| { + let proxy_pid = utils::upload_and_initialize_broker(); + + // Add proxy + let add_proxy_req = Request::AddProxy { + delegate: SIGNER.cast(), + proxy_type: ProxyType::Any, + }; + utils::send_proxy_request(proxy_pid, add_proxy_req); + + System::assert_has_event(RuntimeEvent::Proxy(ProxyEvent::ProxyAdded { + delegator: proxy_pid.cast(), + delegatee: SIGNER, + proxy_type: ProxyType::Any.into(), + delay: 0, + })); + + // Execute proxy + let dest = 42; + let value = EXISTENTIAL_DEPOSIT * 3; + let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest, value }); + + assert_ok!(Proxy::proxy( + RuntimeOrigin::signed(SIGNER), + proxy_pid.cast(), + None, + Box::new(call) + )); + assert_eq!(Balances::free_balance(dest), value); + }) +} + +mod utils { + use super::*; + + pub(super) fn upload_and_initialize_broker() -> ProgramId { + let code = WASM_BINARY; + let salt = b"proxy_broker"; + let pid = ProgramId::generate_from_user(CodeId::generate(code), salt); + assert_ok!(Gear::upload_program( + RuntimeOrigin::signed(SIGNER), + code.to_vec(), + salt.to_vec(), + Default::default(), + 10_000_000_000, + 0, + false, + )); + run_to_next_block(); + + // Top-up balance of the proxy so it can pay adding proxy deposit + assert_ok!(>::transfer( + &1, + &pid.cast(), + 10 * EXISTENTIAL_DEPOSIT, + frame_support::traits::ExistenceRequirement::AllowDeath + )); + + pid + } + + pub(super) fn send_proxy_request(proxy_pid: ProgramId, req: Request) { + assert_ok!(Gear::send_message( + RuntimeOrigin::signed(SIGNER), + proxy_pid, + req.encode(), + 10_000_000_000, + 0, + false, + )); + run_to_next_block(); + } +} diff --git a/runtime/vara/Cargo.toml b/runtime/vara/Cargo.toml index 512d3bc73c0..fc902592b4c 100644 --- a/runtime/vara/Cargo.toml +++ b/runtime/vara/Cargo.toml @@ -106,6 +106,7 @@ pallet-gear-builtin-rpc-runtime-api.workspace = true pallet-gear-eth-bridge-rpc-runtime-api.workspace = true runtime-primitives.workspace = true gbuiltin-staking.workspace = true +gbuiltin-proxy.workspace = true [dev-dependencies] sp-io.workspace = true diff --git a/runtime/vara/src/lib.rs b/runtime/vara/src/lib.rs index 1ffec3ed121..0d950b7a5f8 100644 --- a/runtime/vara/src/lib.rs +++ b/runtime/vara/src/lib.rs @@ -65,6 +65,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, }; +use gbuiltin_proxy::ProxyType as BuiltinProxyType; use pallet_election_provider_multi_phase::{GeometricDepositBase, SolutionAccuracyOf}; pub use pallet_gear::manager::{ExtManager, HandleKind}; use pallet_gear_builtin::ActorWithId; @@ -1003,6 +1004,19 @@ impl Default for ProxyType { } } +impl From for ProxyType { + fn from(proxy_type: BuiltinProxyType) -> Self { + match proxy_type { + BuiltinProxyType::Any => ProxyType::Any, + BuiltinProxyType::NonTransfer => ProxyType::NonTransfer, + BuiltinProxyType::Governance => ProxyType::Governance, + BuiltinProxyType::Staking => ProxyType::Staking, + BuiltinProxyType::IdentityJudgement => ProxyType::IdentityJudgement, + BuiltinProxyType::CancelProxy => ProxyType::CancelProxy, + } + } +} + impl InstanceFilter for ProxyType { fn filter(&self, c: &RuntimeCall) -> bool { match self { @@ -1180,6 +1194,8 @@ impl pallet_gear_messenger::Config for Runtime { pub type BuiltinActors = ( ActorWithId<1, pallet_gear_builtin::bls12_381::Actor>, ActorWithId<2, pallet_gear_builtin::staking::Actor>, + // The ID = 3 is for the pallet_gear_eth_bridge::Actor. + ActorWithId<4, pallet_gear_builtin::proxy::Actor>, ); /// Builtin actors arranged in a tuple. @@ -1188,6 +1204,7 @@ pub type BuiltinActors = ( ActorWithId<1, pallet_gear_builtin::bls12_381::Actor>, ActorWithId<2, pallet_gear_builtin::staking::Actor>, ActorWithId<3, pallet_gear_eth_bridge::Actor>, + ActorWithId<4, pallet_gear_builtin::proxy::Actor>, ); impl pallet_gear_builtin::Config for Runtime { From 50142d00cd88dfa5161a8eb7ad0439332556cbc5 Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:50:51 +0300 Subject: [PATCH 5/5] chore(deps): remove ethers in favor of alloy (#4316) --- Cargo.lock | 1157 +++++--------------------------------- Cargo.toml | 2 +- ethexe/cli/src/tests.rs | 3 +- ethexe/signer/Cargo.toml | 4 +- ethexe/signer/src/lib.rs | 23 +- 5 files changed, 159 insertions(+), 1030 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f080df16e4..94275f1ff5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -440,7 +440,7 @@ dependencies = [ "futures-utils-wasm", "lru 0.12.3", "pin-project", - "reqwest 0.12.4", + "reqwest", "serde", "serde_json", "thiserror", @@ -504,7 +504,7 @@ dependencies = [ "alloy-transport-ws", "futures", "pin-project", - "reqwest 0.12.4", + "reqwest", "serde", "serde_json", "tokio", @@ -730,7 +730,7 @@ checksum = "b367dcccada5b28987c2296717ee04b9a5637aacd78eacb1726ef211678b5212" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest 0.12.4", + "reqwest", "serde_json", "tower 0.5.1", "tracing", @@ -750,7 +750,7 @@ dependencies = [ "rustls 0.23.10", "serde_json", "tokio", - "tokio-tungstenite 0.24.0", + "tokio-tungstenite", "tracing", "ws_stream_wasm", ] @@ -1265,15 +1265,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" -[[package]] -name = "ascii-canvas" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" -dependencies = [ - "term", -] - [[package]] name = "asn1-rs" version = "0.5.2" @@ -1738,12 +1729,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" -[[package]] -name = "bech32" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" - [[package]] name = "beef" version = "0.5.2" @@ -2045,7 +2030,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ - "sha2 0.10.8", "tinyvec", ] @@ -2144,16 +2128,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bzip2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" -dependencies = [ - "bzip2-sys", - "libc", -] - [[package]] name = "bzip2-sys" version = "0.1.11+1.0.8" @@ -2577,58 +2551,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "coins-bip32" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b6be4a5df2098cd811f3194f64ddb96c267606bffd9689ac7b0160097b01ad3" -dependencies = [ - "bs58 0.5.1", - "coins-core", - "digest 0.10.7", - "hmac 0.12.1", - "k256", - "serde", - "sha2 0.10.8", - "thiserror", -] - -[[package]] -name = "coins-bip39" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" -dependencies = [ - "bitvec", - "coins-bip32", - "hmac 0.12.1", - "once_cell", - "pbkdf2 0.12.2", - "rand 0.8.5", - "sha2 0.10.8", - "thiserror", -] - -[[package]] -name = "coins-core" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" -dependencies = [ - "base64 0.21.7", - "bech32", - "bs58 0.5.1", - "digest 0.10.7", - "generic-array 0.14.7", - "hex", - "ripemd", - "serde", - "serde_derive", - "sha2 0.10.8", - "sha3", - "thiserror", -] - [[package]] name = "color-eyre" version = "0.6.3" @@ -2988,7 +2910,7 @@ dependencies = [ "cargo-http-registry", "cargo_metadata 0.18.1", "clap 4.5.9", - "reqwest 0.11.27", + "reqwest", "serde", "tempfile", "tokio", @@ -4213,25 +4135,6 @@ dependencies = [ "dirs-sys 0.3.7", ] -[[package]] -name = "dirs" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" -dependencies = [ - "dirs-sys 0.4.1", -] - -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - [[package]] name = "dirs-sys" version = "0.3.7" @@ -4506,48 +4409,12 @@ dependencies = [ "zeroize", ] -[[package]] -name = "ena" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" -dependencies = [ - "log", -] - [[package]] name = "encode_unicode" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" -[[package]] -name = "encoding_rs" -version = "0.8.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "enr" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3d8dc56e02f954cac8eb489772c552c473346fc34f67412bb6244fd647f7e4" -dependencies = [ - "base64 0.21.7", - "bytes", - "hex", - "k256", - "log", - "rand 0.8.5", - "rlp", - "serde", - "sha3", - "zeroize", -] - [[package]] name = "enum-as-inner" version = "0.5.1" @@ -4658,381 +4525,63 @@ name = "enumset" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e875f1719c16de097dee81ed675e2d9bb63096823ed3f0ca827b7dea3028bbbb" -dependencies = [ - "enumset_derive", -] - -[[package]] -name = "enumset_derive" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" -dependencies = [ - "darling 0.20.10", - "proc-macro2", - "quote", - "syn 2.0.71", -] - -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "environmental" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "etc" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b241177c7107d9829286c2ffdc5eee98d992d6356f3515e7f412f988b1a72fd" - -[[package]] -name = "eth-keystore" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab" -dependencies = [ - "aes 0.8.4", - "ctr 0.9.2", - "digest 0.10.7", - "hex", - "hmac 0.12.1", - "pbkdf2 0.11.0", - "rand 0.8.5", - "scrypt", - "serde", - "serde_json", - "sha2 0.10.8", - "sha3", - "thiserror", - "uuid 0.8.2", -] - -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "primitive-types", - "scale-info", - "uint", -] - -[[package]] -name = "ethers" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816841ea989f0c69e459af1cf23a6b0033b19a55424a1ea3a30099becdb8dec0" -dependencies = [ - "ethers-addressbook", - "ethers-contract", - "ethers-core", - "ethers-etherscan", - "ethers-middleware", - "ethers-providers", - "ethers-signers", - "ethers-solc", -] - -[[package]] -name = "ethers-addressbook" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5495afd16b4faa556c3bba1f21b98b4983e53c1755022377051a975c3b021759" -dependencies = [ - "ethers-core", - "once_cell", - "serde", - "serde_json", -] - -[[package]] -name = "ethers-contract" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fceafa3578c836eeb874af87abacfb041f92b4da0a78a5edd042564b8ecdaaa" -dependencies = [ - "const-hex", - "ethers-contract-abigen", - "ethers-contract-derive", - "ethers-core", - "ethers-providers", - "futures-util", - "once_cell", - "pin-project", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "ethers-contract-abigen" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04ba01fbc2331a38c429eb95d4a570166781f14290ef9fdb144278a90b5a739b" -dependencies = [ - "Inflector", - "const-hex", - "dunce", - "ethers-core", - "ethers-etherscan", - "eyre", - "prettyplease 0.2.15", - "proc-macro2", - "quote", - "regex", - "reqwest 0.11.27", - "serde", - "serde_json", - "syn 2.0.71", - "toml 0.8.14", - "walkdir", -] - -[[package]] -name = "ethers-contract-derive" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87689dcabc0051cde10caaade298f9e9093d65f6125c14575db3fd8c669a168f" -dependencies = [ - "Inflector", - "const-hex", - "ethers-contract-abigen", - "ethers-core", - "proc-macro2", - "quote", - "serde_json", - "syn 2.0.71", -] - -[[package]] -name = "ethers-core" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d80cc6ad30b14a48ab786523af33b37f28a8623fc06afd55324816ef18fb1f" -dependencies = [ - "arrayvec 0.7.4", - "bytes", - "cargo_metadata 0.18.1", - "chrono", - "const-hex", - "elliptic-curve", - "ethabi", - "generic-array 0.14.7", - "k256", - "num_enum 0.7.2", - "once_cell", - "open-fastrlp", - "rand 0.8.5", - "rlp", - "serde", - "serde_json", - "strum 0.26.2", - "syn 2.0.71", - "tempfile", - "thiserror", - "tiny-keccak", - "unicode-xid", -] - -[[package]] -name = "ethers-etherscan" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79e5973c26d4baf0ce55520bd732314328cabe53193286671b47144145b9649" -dependencies = [ - "chrono", - "ethers-core", - "reqwest 0.11.27", - "semver 1.0.18", - "serde", - "serde_json", - "thiserror", - "tracing", -] - -[[package]] -name = "ethers-middleware" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48f9fdf09aec667c099909d91908d5eaf9be1bd0e2500ba4172c1d28bfaa43de" -dependencies = [ - "async-trait", - "auto_impl", - "ethers-contract", - "ethers-core", - "ethers-etherscan", - "ethers-providers", - "ethers-signers", - "futures-channel", - "futures-locks", - "futures-util", - "instant", - "reqwest 0.11.27", - "serde", - "serde_json", - "thiserror", - "tokio", - "tracing", - "tracing-futures", - "url", -] - -[[package]] -name = "ethers-providers" -version = "2.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6434c9a33891f1effc9c75472e12666db2fa5a0fec4b29af6221680a6fe83ab2" -dependencies = [ - "async-trait", - "auto_impl", - "base64 0.21.7", - "bytes", - "const-hex", - "enr", - "ethers-core", - "futures-core", - "futures-timer", - "futures-util", - "hashers", - "http 0.2.9", - "instant", - "jsonwebtoken", - "once_cell", - "pin-project", - "reqwest 0.11.27", - "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-tungstenite 0.20.1", - "tracing", - "tracing-futures", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "ws_stream_wasm", +dependencies = [ + "enumset_derive", ] [[package]] -name = "ethers-signers" -version = "2.0.14" +name = "enumset_derive" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "228875491c782ad851773b652dd8ecac62cda8571d3bc32a5853644dd26766c2" +checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ - "async-trait", - "coins-bip32", - "coins-bip39", - "const-hex", - "elliptic-curve", - "eth-keystore", - "ethers-core", - "rand 0.8.5", - "sha2 0.10.8", - "thiserror", - "tracing", + "darling 0.20.10", + "proc-macro2", + "quote", + "syn 2.0.71", ] [[package]] -name = "ethers-solc" -version = "2.0.14" +name = "env_logger" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66244a771d9163282646dbeffe0e6eca4dda4146b6498644e678ac6089b11edd" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ - "cfg-if", - "const-hex", - "dirs 5.0.1", - "dunce", - "ethers-core", - "glob 0.3.1", - "home", - "md-5", - "num_cpus", - "once_cell", - "path-slash", - "rayon", + "humantime", + "is-terminal", + "log", "regex", - "semver 1.0.18", - "serde", - "serde_json", - "solang-parser", - "svm-rs", - "thiserror", - "tiny-keccak", - "tokio", - "tracing", - "walkdir", - "yansi", + "termcolor", +] + +[[package]] +name = "environmental" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", ] +[[package]] +name = "etc" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b241177c7107d9829286c2ffdc5eee98d992d6356f3515e7f412f988b1a72fd" + [[package]] name = "ethexe-cli" version = "1.6.2" @@ -5167,7 +4716,7 @@ dependencies = [ "gprimitives", "log", "parity-scale-codec", - "reqwest 0.11.27", + "reqwest", "tokio", "wabt", ] @@ -5286,9 +4835,9 @@ dependencies = [ name = "ethexe-signer" version = "1.6.2" dependencies = [ + "alloy", "anyhow", "derive_more 0.99.18", - "ethers", "ethexe-common", "gprimitives", "hex", @@ -6085,16 +5634,6 @@ dependencies = [ "pin-project-lite 0.2.13", ] -[[package]] -name = "futures-locks" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" -dependencies = [ - "futures-channel", - "futures-task", -] - [[package]] name = "futures-macro" version = "0.3.30" @@ -6156,10 +5695,6 @@ name = "futures-timer" version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" -dependencies = [ - "gloo-timers", - "send_wrapper 0.4.0", -] [[package]] name = "futures-util" @@ -6253,7 +5788,7 @@ dependencies = [ "demo-messenger", "demo-new-meta", "demo-waiter", - "dirs 4.0.0", + "dirs", "env_logger", "etc", "gclient", @@ -6269,7 +5804,7 @@ dependencies = [ "keyring", "log", "rand 0.8.5", - "reqwest 0.11.27", + "reqwest", "scale-info", "serde", "thiserror", @@ -6653,7 +6188,7 @@ dependencies = [ "parking_lot 0.12.3", "primitive-types", "rand 0.8.5", - "reqwest 0.11.27", + "reqwest", "subxt", "thiserror", "tokio", @@ -7278,18 +6813,6 @@ dependencies = [ "regex", ] -[[package]] -name = "gloo-timers" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - [[package]] name = "gmeta" version = "1.6.2" @@ -7338,7 +6861,7 @@ dependencies = [ "base64 0.21.7", "clap 4.5.9", "colored", - "dirs 4.0.0", + "dirs", "gear-ss58", "hex", "nacl", @@ -7616,15 +7139,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hashers" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" -dependencies = [ - "fxhash", -] - [[package]] name = "hashlink" version = "0.8.4" @@ -8002,16 +7516,21 @@ dependencies = [ ] [[package]] -name = "hyper-tls" -version = "0.5.0" +name = "hyper-rustls" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ - "bytes", - "hyper 0.14.27", - "native-tls", + "futures-util", + "http 1.1.0", + "hyper 1.4.1", + "hyper-util", + "rustls 0.23.10", + "rustls-pki-types", "tokio", - "tokio-native-tls", + "tokio-rustls 0.26.0", + "tower-service", + "webpki-roots 0.26.3", ] [[package]] @@ -8173,15 +7692,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - [[package]] name = "impl-serde" version = "0.4.0" @@ -8321,7 +7831,7 @@ dependencies = [ "socket2 0.5.7", "widestring", "windows-sys 0.48.0", - "winreg 0.50.0", + "winreg", ] [[package]] @@ -8350,15 +7860,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.12.1" @@ -8662,7 +8163,7 @@ checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" dependencies = [ "async-trait", "hyper 0.14.27", - "hyper-rustls", + "hyper-rustls 0.24.1", "jsonrpsee-core 0.16.3", "jsonrpsee-types 0.16.3", "rustc-hash 1.1.0", @@ -8681,7 +8182,7 @@ checksum = "1ccf93fc4a0bfe05d851d37d7c32b7f370fe94336b52a2f0efc5f1981895c2e5" dependencies = [ "async-trait", "hyper 0.14.27", - "hyper-rustls", + "hyper-rustls 0.24.1", "jsonrpsee-core 0.22.5", "jsonrpsee-types 0.22.5", "serde", @@ -8845,20 +8346,6 @@ dependencies = [ "url", ] -[[package]] -name = "jsonwebtoken" -version = "8.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" -dependencies = [ - "base64 0.21.7", - "pem 1.1.1", - "ring 0.16.20", - "serde", - "serde_json", - "simple_asn1", -] - [[package]] name = "junit-common" version = "0.1.0" @@ -8877,7 +8364,6 @@ dependencies = [ "elliptic-curve", "once_cell", "sha2 0.10.8", - "signature", ] [[package]] @@ -8950,34 +8436,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "lalrpop" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da4081d44f4611b66c6dd725e6de3169f9f63905421e8626fcb86b6a898998b8" -dependencies = [ - "ascii-canvas", - "bit-set", - "diff", - "ena", - "is-terminal", - "itertools 0.10.5", - "lalrpop-util", - "petgraph", - "regex", - "regex-syntax 0.7.5", - "string_cache", - "term", - "tiny-keccak", - "unicode-xid", -] - -[[package]] -name = "lalrpop-util" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f35c735096c0293d313e8f2a641627472b83d01b937177fe76e5e2708d31e0d" - [[package]] name = "lazy-pages-fuzzer" version = "0.1.0" @@ -10245,16 +9703,6 @@ dependencies = [ "rawpointer", ] -[[package]] -name = "md-5" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" -dependencies = [ - "cfg-if", - "digest 0.10.7", -] - [[package]] name = "memchr" version = "2.7.2" @@ -10743,12 +10191,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "new_debug_unreachable" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" - [[package]] name = "nix" version = "0.22.3" @@ -11007,7 +10449,6 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.71", @@ -11089,31 +10530,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec 0.7.4", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "openssl" version = "0.10.60" @@ -12473,17 +11889,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core 0.6.4", - "subtle 2.6.1", -] - [[package]] name = "paste" version = "1.0.15" @@ -12496,12 +11901,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" -[[package]] -name = "path-slash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" - [[package]] name = "pathdiff" version = "0.2.1" @@ -12517,18 +11916,6 @@ dependencies = [ "crypto-mac 0.11.0", ] -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest 0.10.7", - "hmac 0.12.1", - "password-hash", - "sha2 0.10.8", -] - [[package]] name = "pbkdf2" version = "0.12.2" @@ -12536,7 +11923,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" dependencies = [ "digest 0.10.7", - "hmac 0.12.1", ] [[package]] @@ -12604,85 +11990,34 @@ dependencies = [ ] [[package]] -name = "pest_meta" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" -dependencies = [ - "once_cell", - "pest", - "sha2 0.10.8", -] - -[[package]] -name = "petgraph" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" -dependencies = [ - "fixedbitset", - "indexmap 2.6.0", -] - -[[package]] -name = "pharos" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" -dependencies = [ - "futures", - "rustc_version 0.4.0", -] - -[[package]] -name = "phf" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" -dependencies = [ - "phf_macros", - "phf_shared 0.11.2", -] - -[[package]] -name = "phf_generator" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" -dependencies = [ - "phf_shared 0.11.2", - "rand 0.8.5", -] - -[[package]] -name = "phf_macros" -version = "0.11.2" +name = "pest_meta" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" dependencies = [ - "phf_generator", - "phf_shared 0.11.2", - "proc-macro2", - "quote", - "syn 2.0.71", + "once_cell", + "pest", + "sha2 0.10.8", ] [[package]] -name = "phf_shared" -version = "0.10.0" +name = "petgraph" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ - "siphasher 0.3.11", + "fixedbitset", + "indexmap 2.6.0", ] [[package]] -name = "phf_shared" -version = "0.11.2" +name = "pharos" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" dependencies = [ - "siphasher 0.3.11", + "futures", + "rustc_version 0.4.0", ] [[package]] @@ -12881,12 +12216,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "precomputed-hash" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" - [[package]] name = "predicates" version = "2.1.5" @@ -12955,7 +12284,6 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", - "impl-rlp", "impl-serde", "scale-info", "uint", @@ -13634,12 +12962,6 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" -[[package]] -name = "regex-syntax" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" - [[package]] name = "regex-syntax" version = "0.8.2" @@ -13685,63 +13007,21 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2 0.3.21", - "http 0.2.9", - "http-body 0.4.5", - "hyper 0.14.27", - "hyper-rustls", - "hyper-tls 0.5.0", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite 0.2.13", - "rustls 0.21.7", - "rustls-pemfile 1.0.3", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-native-tls", - "tokio-rustls 0.24.1", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots 0.25.2", - "winreg 0.50.0", -] - -[[package]] -name = "reqwest" -version = "0.12.4" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64 0.22.1", "bytes", + "futures-channel", "futures-core", "futures-util", "http 1.1.0", "http-body 1.0.0", "http-body-util", "hyper 1.4.1", - "hyper-tls 0.6.0", + "hyper-rustls 0.27.3", + "hyper-tls", "hyper-util", "ipnet", "js-sys", @@ -13751,19 +13031,24 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite 0.2.13", + "quinn", + "rustls 0.23.10", "rustls-pemfile 2.1.2", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 1.0.1", "tokio", "tokio-native-tls", + "tokio-rustls 0.26.0", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg 0.52.0", + "webpki-roots 0.26.3", + "windows-registry", ] [[package]] @@ -13833,15 +13118,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "ripemd" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" -dependencies = [ - "digest 0.10.7", -] - [[package]] name = "rkyv" version = "0.7.42" @@ -13857,7 +13133,7 @@ dependencies = [ "rkyv_derive", "seahash", "tinyvec", - "uuid 1.4.1", + "uuid", ] [[package]] @@ -13878,21 +13154,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", - "rlp-derive", "rustc-hex", ] -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "rocksdb" version = "0.21.0" @@ -14340,15 +13604,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "salsa20" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" -dependencies = [ - "cipher 0.4.4", -] - [[package]] name = "same-file" version = "1.0.6" @@ -14997,7 +14252,7 @@ dependencies = [ "futures", "futures-timer", "hyper 0.14.27", - "hyper-rustls", + "hyper-rustls 0.24.1", "libp2p 0.51.4", "log", "num_cpus", @@ -15527,9 +14782,9 @@ dependencies = [ [[package]] name = "schnellru" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" +checksum = "c9a8ef13a93c54d20580de1e5c413e624e53121d42fc7e2c11d10ef7f8b02367" dependencies = [ "ahash 0.8.11", "cfg-if", @@ -15591,18 +14846,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" -[[package]] -name = "scrypt" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" -dependencies = [ - "hmac 0.12.1", - "pbkdf2 0.11.0", - "salsa20", - "sha2 0.10.8", -] - [[package]] name = "sct" version = "0.7.0" @@ -15772,12 +15015,6 @@ dependencies = [ "pest", ] -[[package]] -name = "send_wrapper" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" - [[package]] name = "send_wrapper" version = "0.6.0" @@ -16085,18 +15322,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" -[[package]] -name = "simple_asn1" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" -dependencies = [ - "num-bigint", - "num-traits", - "thiserror", - "time", -] - [[package]] name = "siphasher" version = "0.3.11" @@ -16314,20 +15539,6 @@ dependencies = [ "sha1", ] -[[package]] -name = "solang-parser" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" -dependencies = [ - "itertools 0.11.0", - "lalrpop", - "lalrpop-util", - "phf", - "thiserror", - "unicode-xid", -] - [[package]] name = "sp-allocator" version = "4.1.0-dev" @@ -17328,19 +16539,6 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e75b72ee54e2f93c3ea1354066162be893ee5e25773ab743de3e088cecbb4f31" -[[package]] -name = "string_cache" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" -dependencies = [ - "new_debug_unreachable", - "once_cell", - "parking_lot 0.12.3", - "phf_shared 0.10.0", - "precomputed-hash", -] - [[package]] name = "strsim" version = "0.8.0" @@ -17710,26 +16908,6 @@ dependencies = [ "sp-crypto-hashing", ] -[[package]] -name = "svm-rs" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11297baafe5fa0c99d5722458eac6a5e25c01eb1b8e5cd137f54079093daa7a4" -dependencies = [ - "dirs 5.0.1", - "fs2", - "hex", - "once_cell", - "reqwest 0.11.27", - "semver 1.0.18", - "serde", - "serde_json", - "sha2 0.10.8", - "thiserror", - "url", - "zip", -] - [[package]] name = "syn" version = "1.0.109" @@ -17770,6 +16948,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] + [[package]] name = "synstructure" version = "0.12.6" @@ -17874,17 +17061,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "term" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" -dependencies = [ - "dirs-next", - "rustversion", - "winapi", -] - [[package]] name = "termcolor" version = "1.2.0" @@ -18152,21 +17328,6 @@ dependencies = [ "tokio-stream", ] -[[package]] -name = "tokio-tungstenite" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" -dependencies = [ - "futures-util", - "log", - "rustls 0.21.7", - "tokio", - "tokio-rustls 0.24.1", - "tungstenite 0.20.1", - "webpki-roots 0.25.2", -] - [[package]] name = "tokio-tungstenite" version = "0.24.0" @@ -18179,7 +17340,7 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", - "tungstenite 0.24.0", + "tungstenite", "webpki-roots 0.26.3", ] @@ -18306,7 +17467,7 @@ dependencies = [ "futures-core", "futures-util", "pin-project-lite 0.2.13", - "sync_wrapper", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", ] @@ -18613,26 +17774,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" -[[package]] -name = "tungstenite" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 0.2.9", - "httparse", - "log", - "rand 0.8.5", - "rustls 0.21.7", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.24.0" @@ -18832,16 +17973,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "uuid" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" -dependencies = [ - "getrandom 0.2.15", - "serde", -] - [[package]] name = "uuid" version = "1.4.1" @@ -20029,6 +19160,36 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.33.0" @@ -20314,16 +19475,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "wit-parser" version = "0.6.4" @@ -20351,7 +19502,7 @@ dependencies = [ "log", "pharos", "rustc_version 0.4.0", - "send_wrapper 0.6.0", + "send_wrapper", "thiserror", "wasm-bindgen", "wasm-bindgen-futures", @@ -20598,26 +19749,6 @@ dependencies = [ "syn 2.0.71", ] -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "aes 0.8.4", - "byteorder", - "bzip2", - "constant_time_eq 0.1.5", - "crc32fast", - "crossbeam-utils", - "flate2", - "hmac 0.12.1", - "pbkdf2 0.11.0", - "sha1", - "time", - "zstd 0.11.2+zstd.1.5.2", -] - [[package]] name = "zstd" version = "0.11.2+zstd.1.5.2" diff --git a/Cargo.toml b/Cargo.toml index d8ed67f243c..94d6641b6e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -162,7 +162,7 @@ rand = { version = "0.8", default-features = false } rayon = "1.10" regex = "^1.9" region = "3.0.2" -reqwest = { version = "0.11.27", default-features = false } +reqwest = { version = "0.12.8", default-features = false } scale-info = { version = "2.5.0", default-features = false } serde = { version = "^1", default-features = false } serde_json = "^1" diff --git a/ethexe/cli/src/tests.rs b/ethexe/cli/src/tests.rs index 9146bd20a3f..f2fc1ecaf86 100644 --- a/ethexe/cli/src/tests.rs +++ b/ethexe/cli/src/tests.rs @@ -828,8 +828,7 @@ mod utils { (rpc_url, None) } Err(_) => { - let mut anvil = Anvil::new().try_spawn().unwrap(); - drop(anvil.child_mut().stdout.take()); //temp fix for alloy#1078 + let anvil = Anvil::new().try_spawn().unwrap(); log::info!("📍 Anvil started at {}", anvil.ws_endpoint()); (anvil.ws_endpoint(), Some(anvil)) } diff --git a/ethexe/signer/Cargo.toml b/ethexe/signer/Cargo.toml index a1559d5262d..4c4fbdb4681 100644 --- a/ethexe/signer/Cargo.toml +++ b/ethexe/signer/Cargo.toml @@ -20,7 +20,7 @@ derive_more.workspace = true tempfile.workspace = true secp256k1 = { version = "0.30", features = ["rand", "global-context", "hashes", "recovery"] } -sha3 = { version = "0.10.0", default-features = false } +sha3 = { version = "0.10", default-features = false } [dev-dependencies] -ethers = "2" +alloy.workspace = true diff --git a/ethexe/signer/src/lib.rs b/ethexe/signer/src/lib.rs index 6b8778e652d..973b153d668 100644 --- a/ethexe/signer/src/lib.rs +++ b/ethexe/signer/src/lib.rs @@ -290,11 +290,9 @@ impl Signer { #[cfg(test)] mod tests { - use std::env::temp_dir; - use super::*; - - use ethers::utils::keccak256; + use alloy::primitives::{keccak256, Signature}; + use std::env::temp_dir; #[test] fn test_signer_with_known_vectors() { @@ -323,10 +321,11 @@ mod tests { let hash = keccak256(message); // Recover the address using the signature - let ethers_sig = ethers::core::types::Signature::try_from(signature.as_ref()) - .expect("failed to parse sig"); + let alloy_sig = Signature::try_from(signature.as_ref()).expect("failed to parse sig"); - let recovered_address = ethers_sig.recover(hash).expect("Failed to recover address"); + let recovered_address = alloy_sig + .recover_address_from_prehash(&hash) + .expect("Failed to recover address"); // Verify the recovered address matches the expected address assert_eq!( @@ -360,11 +359,11 @@ mod tests { let hash = keccak256(message); // Recover the address using the signature - // TODO: remove the deprecated ethers crate in favor of alloy #4197 - let ethers_sig = ethers::core::types::Signature::try_from(signature.as_ref()) - .expect("failed to parse sig"); + let alloy_sig = Signature::try_from(signature.as_ref()).expect("failed to parse sig"); - let recovered_address = ethers_sig.recover(hash).expect("Failed to recover address"); + let recovered_address = alloy_sig + .recover_address_from_prehash(&hash) + .expect("Failed to recover address"); // Verify the recovered address matches the expected address assert_eq!( @@ -404,7 +403,7 @@ mod tests { .sign(public_key, message) .expect("Failed to sign message"); - let hash = keccak256(message); + let hash = keccak256(message).0; let recovered_public_key = signature .recover_from_digest(hash.into())