Skip to content

Commit

Permalink
feat: support evm assets in multi-asset-delegation (#852)
Browse files Browse the repository at this point in the history
* chore : switch to asset-id evm

* cleanup

* bump subxt

* clean slate

* use common exports

* use common exports

* wip

* wip

* wip

* fix compile

* cleanup

* compiling

* precompiles fixes

* runtimes building

* update mocks

* cleanup tests

* update js types

* update subxt

* cleanup clippy

* use nightly fmt

* use stable fmt

* cleanup clippy

* cleanup tests

* cleanup tests

* cleanup fmt

* more tests passing

* cleanup clippy

* clipyy fixes

* cleanup clippy
  • Loading branch information
1xstj authored Dec 17, 2024
1 parent af5234c commit 99b7fd7
Show file tree
Hide file tree
Showing 91 changed files with 4,419 additions and 2,795 deletions.
73 changes: 73 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions client/evm-tracing/src/formatters/blockscout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

use crate::listeners::call_list::Listener;
use crate::types::serialization::*;
use crate::types::{
single::{Call, TransactionTrace},
CallResult, CallType, CreateResult,
use crate::{
listeners::call_list::Listener,
types::{
serialization::*,
single::{Call, TransactionTrace},
CallResult, CallType, CreateResult,
},
};
use ethereum_types::{H160, U256};
use parity_scale_codec::{Decode, Encode};
Expand Down
2 changes: 1 addition & 1 deletion client/evm-tracing/src/formatters/call_tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl super::ResponseFormatter for Formatter {
//
// We consider an item to be `Ordering::Less` when:
// - Is closer to the root or
// - Is greater than its sibling.
// - Is greater than its sibling.
result.sort_by(|a, b| match (a, b) {
(
Call::CallTracer(CallTracerCall { trace_address: Some(a), .. }),
Expand Down
3 changes: 1 addition & 2 deletions client/evm-tracing/src/formatters/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

use crate::listeners::raw::Listener;
use crate::types::single::TransactionTrace;
use crate::{listeners::raw::Listener, types::single::TransactionTrace};

pub struct Formatter;

Expand Down
13 changes: 8 additions & 5 deletions client/evm-tracing/src/formatters/trace_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

use super::blockscout::BlockscoutCallInner as CallInner;
use crate::listeners::call_list::Listener;
use crate::types::{
block::{
TransactionTrace, TransactionTraceAction, TransactionTraceOutput, TransactionTraceResult,
use crate::{
listeners::call_list::Listener,
types::{
block::{
TransactionTrace, TransactionTraceAction, TransactionTraceOutput,
TransactionTraceResult,
},
CallResult, CreateResult, CreateType,
},
CallResult, CreateResult, CreateType,
};
use ethereum_types::H256;

Expand Down
10 changes: 6 additions & 4 deletions client/evm-tracing/src/listeners/call_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

use crate::formatters::blockscout::BlockscoutCall as Call;
use crate::formatters::blockscout::BlockscoutCallInner as CallInner;
use crate::types::{single::Log, CallResult, CallType, ContextType, CreateResult};
use crate::{
formatters::blockscout::{BlockscoutCall as Call, BlockscoutCallInner as CallInner},
types::{single::Log, CallResult, CallType, ContextType, CreateResult},
};
use ethereum_types::{H160, U256};
use evm_tracing_events::{
runtime::{Capture, ExitError, ExitReason, ExitSucceed},
Expand Down Expand Up @@ -1094,7 +1095,8 @@ mod tests {
listener.finish_transaction();
assert_eq!(listener.entries.len(), 1);
// Each nested call contains 11 elements in the callstack (main + 10 subcalls).
// There are 5 main nested calls for a total of 56 elements in the callstack: 1 main + 55 nested.
// There are 5 main nested calls for a total of 56 elements in the callstack: 1 main + 55
// nested.
assert_eq!(listener.entries[0].len(), (depth * (subdepth + 1)) + 1);
}

Expand Down
3 changes: 2 additions & 1 deletion client/evm-tracing/src/listeners/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ impl Listener {
.global_storage_changes
.insert(context.address, context.storage_cache);

// Apply storage changes to parent, either updating its cache or map of changes.
// Apply storage changes to parent, either updating its cache or
// map of changes.
for (address, mut storage) in
context.global_storage_changes.into_iter()
{
Expand Down
10 changes: 5 additions & 5 deletions client/rpc/trace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
//! The implementation is composed of multiple tasks :
//! - Many calls the RPC handler `Trace::filter`, communicating with the main task.
//! - A main `CacheTask` managing the cache and the communication between tasks.
//! - For each traced block an async task responsible to wait for a permit, spawn a blocking
//! task and waiting for the result, then send it to the main `CacheTask`.
//! - For each traced block an async task responsible to wait for a permit, spawn a blocking task
//! and waiting for the result, then send it to the main `CacheTask`.
use futures::{select, stream::FuturesUnordered, FutureExt, StreamExt};
use std::{collections::BTreeMap, future::Future, marker::PhantomData, sync::Arc, time::Duration};
Expand Down Expand Up @@ -595,9 +595,9 @@ where

/// Handle a request to get the traces of the provided block.
/// - If the result is stored in the cache, it sends it immediatly.
/// - If the block is currently being pooled, it is added in this block cache waiting list,
/// and all requests concerning this block will be satisfied when the tracing for this block
/// is finished.
/// - If the block is currently being pooled, it is added in this block cache waiting list, and
/// all requests concerning this block will be satisfied when the tracing for this block is
/// finished.
/// - If this block is missing from the cache, it means no batch asked for it. All requested
/// blocks should be contained in a batch beforehand, and thus an error is returned.
#[instrument(skip(self))]
Expand Down
25 changes: 11 additions & 14 deletions node/src/manual_seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,30 @@
// limitations under the License.

//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
use crate::cli::Sealing;
pub use crate::eth::{db_config_dir, EthConfiguration};
use crate::eth::{
new_frontier_partial, spawn_frontier_tasks, BackendType, EthApi, FrontierBackend,
FrontierBlockImport, FrontierPartialComponents, RpcConfig, StorageOverride,
StorageOverrideHandler,
use crate::{
cli::Sealing,
eth::{
new_frontier_partial, spawn_frontier_tasks, BackendType, EthApi, FrontierBackend,
FrontierBlockImport, FrontierPartialComponents, RpcConfig, StorageOverride,
StorageOverrideHandler,
},
};
use futures::future;
use futures::FutureExt;
use futures::{channel::mpsc, prelude::*};
use futures::{channel::mpsc, future, prelude::*, FutureExt};
use futures_timer::Delay;
use sc_client_api::{Backend, BlockBackend};
use sc_consensus::BasicQueue;
use sc_consensus_babe::BabeLink;
use sc_consensus_babe::{BabeWorkerHandle, SlotProportion};
use sc_consensus_babe::{BabeLink, BabeWorkerHandle, SlotProportion};
use sc_consensus_grandpa::SharedVoterState;
#[allow(deprecated)]
pub use sc_executor::NativeElseWasmExecutor;
use sc_service::{error::Error as ServiceError, ChainType, Configuration, TaskManager};
use sc_telemetry::TelemetryHandle;
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker};
use sc_transaction_pool::FullPool;
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_core::U256;
use sp_runtime::traits::Block as BlockT;
use std::cell::RefCell;
use std::{path::Path, sync::Arc, time::Duration};
use std::{cell::RefCell, path::Path, sync::Arc, time::Duration};
use substrate_prometheus_endpoint::Registry;
use tangle_primitives::Block;

Expand Down
3 changes: 1 addition & 2 deletions pallets/claims/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use sp_std::convert::TryFrom;
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use crate::{pallet as pallet_airdrop_claims, sr25519_utils::sub, tests::get_bounded_vec};
use frame_support::derive_impl;
use frame_support::{
ord_parameter_types, parameter_types,
derive_impl, ord_parameter_types, parameter_types,
traits::{OnFinalize, OnInitialize, WithdrawReasons},
};
use pallet_balances;
Expand Down
80 changes: 79 additions & 1 deletion pallets/multi-asset-delegation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,65 @@ frame-support = { workspace = true }
frame-system = { workspace = true }
parity-scale-codec = { workspace = true }
scale-info = { workspace = true }
log = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
ethabi = { workspace = true }
pallet-balances = { workspace = true }
tangle-primitives = { workspace = true }
pallet-assets = { workspace = true, default-features = false }
fp-evm = { workspace = true }
itertools = { workspace = true, features = ["use_alloc"] }
serde = { workspace = true, features = ["derive"], optional = true }
hex = { workspace = true, features = ["alloc"] }

[dev-dependencies]
ethereum = { workspace = true, features = ["with-codec"] }
ethers = "2.0"
num_enum = { workspace = true }
hex-literal = { workspace = true }
libsecp256k1 = { workspace = true }
pallet-assets = { workspace = true }
pallet-balances = { workspace = true }
pallet-timestamp = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
smallvec = { workspace = true }
sp-io = { workspace = true }
sp-keystore = { workspace = true }

# Frontier Primitive
fp-account = { workspace = true }
fp-consensus = { workspace = true }
fp-dynamic-fee = { workspace = true }
fp-ethereum = { workspace = true }
fp-rpc = { workspace = true }
fp-self-contained = { workspace = true }
fp-storage = { workspace = true }

# Frontier FRAME
pallet-base-fee = { workspace = true }
pallet-dynamic-fee = { workspace = true }
pallet-ethereum = { workspace = true }
pallet-evm = { workspace = true }
pallet-evm-chain-id = { workspace = true }

pallet-evm-precompile-blake2 = { workspace = true }
pallet-evm-precompile-bn128 = { workspace = true }
pallet-evm-precompile-curve25519 = { workspace = true }
pallet-evm-precompile-ed25519 = { workspace = true }
pallet-evm-precompile-modexp = { workspace = true }
pallet-evm-precompile-sha3fips = { workspace = true }
pallet-evm-precompile-simple = { workspace = true }

precompile-utils = { workspace = true }
sp-keyring ={ workspace = true}
pallet-session = { workspace = true }
pallet-staking = { workspace = true }
sp-staking = { workspace = true }
frame-election-provider-support = { workspace = true }

[features]
default = ["std"]
Expand All @@ -33,7 +85,33 @@ std = [
"sp-std/std",
"pallet-balances/std",
"pallet-assets/std",
"tangle-primitives/std"
"tangle-primitives/std",
"ethabi/std",
"log/std",
"fp-evm/std",
"serde/std",
"hex/std",

"pallet-evm-precompile-modexp/std",
"pallet-evm-precompile-sha3fips/std",
"pallet-evm-precompile-simple/std",
"pallet-evm-precompile-blake2/std",
"pallet-evm-precompile-bn128/std",
"pallet-evm-precompile-curve25519/std",
"pallet-evm-precompile-ed25519/std",
"precompile-utils/std",
"pallet-staking/std",
"fp-account/std",
"fp-consensus/std",
"fp-dynamic-fee/std",
"fp-ethereum/std",
"fp-evm/std",
"fp-rpc/std",
"fp-self-contained/std",
"fp-storage/std",
"ethabi/std",
"sp-keyring/std",
"pallet-ethereum/std"
]
try-runtime = ["frame-support/try-runtime"]
runtime-benchmarks = [
Expand Down
Loading

0 comments on commit 99b7fd7

Please sign in to comment.