Skip to content

Commit

Permalink
deps: update substrate to polkadot-sdk#dc28df0b278f2ca0f69d14363e0866…
Browse files Browse the repository at this point in the history
…8a9ecc2fac (polkadot-evm#1201)
  • Loading branch information
koushiro authored Sep 18, 2023
1 parent aff019d commit 5d86b28
Show file tree
Hide file tree
Showing 23 changed files with 699 additions and 477 deletions.
784 changes: 516 additions & 268 deletions Cargo.lock

Large diffs are not rendered by default.

145 changes: 73 additions & 72 deletions Cargo.toml

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions client/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<Block: BlockT, I: Clone + BlockImport<Block>, C> Clone for FrontierBlockImp
impl<B, I, C> FrontierBlockImport<B, I, C>
where
B: BlockT,
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>>,
I: BlockImport<B>,
I::Error: Into<ConsensusError>,
C: ProvideRuntimeApi<B>,
C::Api: BlockBuilderApi<B> + EthereumRuntimeRPCApi<B>,
Expand All @@ -98,13 +98,12 @@ where
impl<B, I, C> BlockImport<B> for FrontierBlockImport<B, I, C>
where
B: BlockT,
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync,
I: BlockImport<B> + Send + Sync,
I::Error: Into<ConsensusError>,
C: ProvideRuntimeApi<B> + Send + Sync,
C::Api: BlockBuilderApi<B> + EthereumRuntimeRPCApi<B>,
{
type Error = ConsensusError;
type Transaction = sp_api::TransactionFor<C, B>;

async fn check_block(
&mut self,
Expand All @@ -115,7 +114,7 @@ where

async fn import_block(
&mut self,
block: BlockImportParams<B, Self::Transaction>,
block: BlockImportParams<B>,
) -> Result<ImportResult, Self::Error> {
// We validate that there are only one frontier log. No other
// actions are needed and mapping syncing is delegated to a separate
Expand Down
15 changes: 6 additions & 9 deletions client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ use scale_codec::{Decode, Encode};
// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_transaction_pool::ChainApi;
use sp_api::{
ApiExt, CallApiAt, CallApiAtParams, CallContext, Extensions, ProvideRuntimeApi,
StorageTransactionCache,
};
use sp_api::{ApiExt, CallApiAt, CallApiAtParams, CallContext, Extensions, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::HeaderBackend;
use sp_inherents::CreateInherentDataProviders;
use sp_io::hashing::{blake2_128, twox_128};
use sp_runtime::{traits::Block as BlockT, DispatchError, SaturatedConversion};
use sp_runtime::{
traits::{Block as BlockT, HashingFor},
DispatchError, SaturatedConversion,
};
use sp_state_machine::OverlayedChanges;
// Frontier
use fc_rpc_core::types::*;
Expand Down Expand Up @@ -241,14 +241,11 @@ where
api_version,
state_overrides,
)?;
let storage_transaction_cache =
RefCell::<StorageTransactionCache<B, C::StateBackend>>::default();
let params = CallApiAtParams {
at: substrate_hash,
function: "EthereumRuntimeRPCApi_call",
arguments: encoded_params,
overlayed_changes: &RefCell::new(overlayed_changes),
storage_transaction_cache: &storage_transaction_cache,
call_context: CallContext::Offchain,
recorder: &None,
extensions: &RefCell::new(Extensions::new()),
Expand Down Expand Up @@ -888,7 +885,7 @@ where
block_hash: B::Hash,
api_version: u32,
state_overrides: Option<BTreeMap<H160, CallStateOverride>>,
) -> RpcResult<OverlayedChanges> {
) -> RpcResult<OverlayedChanges<HashingFor<B>>> {
let mut overlayed_changes = OverlayedChanges::default();
if let Some(state_overrides) = state_overrides {
for (address, state_override) in state_overrides {
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub mod frontier_backend_client {
use sp_io::hashing::{blake2_128, twox_128};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, UniqueSaturatedInto, Zero},
traits::{Block as BlockT, HashingFor, UniqueSaturatedInto, Zero},
};
use sp_state_machine::OverlayedChanges;
// Frontier
Expand All @@ -95,7 +95,7 @@ pub mod frontier_backend_client {

fn set_overlayed_changes(
client: &C,
overlayed_changes: &mut OverlayedChanges,
overlayed_changes: &mut OverlayedChanges<HashingFor<B>>,
block: B::Hash,
_version: u32,
address: H160,
Expand Down Expand Up @@ -148,7 +148,7 @@ pub mod frontier_backend_client {

fn set_overlayed_changes(
client: &C,
overlayed_changes: &mut OverlayedChanges,
overlayed_changes: &mut OverlayedChanges<HashingFor<B>>,
block: B::Hash,
_version: u32,
address: H160,
Expand Down
29 changes: 15 additions & 14 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,23 @@ mod mock;
#[cfg(all(feature = "std", test))]
mod tests;

pub use ethereum::{
AccessListItem, BlockV2 as Block, LegacyTransactionMessage, Log, ReceiptV3 as Receipt,
TransactionAction, TransactionV2 as Transaction,
};
use ethereum_types::{Bloom, BloomInput, H160, H256, H64, U256};
use evm::ExitReason;
use fp_consensus::{PostLog, PreLog, FRONTIER_ENGINE_ID};
use fp_ethereum::ValidatedTransaction as ValidatedTransactionT;
use fp_evm::{
CallOrCreateInfo, CheckEvmTransaction, CheckEvmTransactionConfig, TransactionValidationError,
};
use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA};
use scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
// Substrate
use frame_support::{
codec::{Decode, Encode, MaxEncodedLen},
dispatch::{
DispatchErrorWithPostInfo, DispatchInfo, DispatchResultWithPostInfo, Pays, PostDispatchInfo,
},
scale_info::TypeInfo,
traits::{EnsureOrigin, Get, PalletInfoAccess, Time},
weights::Weight,
};
use frame_system::{pallet_prelude::OriginFor, CheckWeight, WeightInfo};
use pallet_evm::{BlockHashMapping, FeeCalculator, GasWeightMapping, Runner};
use sp_runtime::{
generic::DigestItem,
traits::{DispatchInfoOf, Dispatchable, One, Saturating, UniqueSaturatedInto, Zero},
Expand All @@ -58,13 +56,16 @@ use sp_runtime::{
RuntimeDebug, SaturatedConversion,
};
use sp_std::{marker::PhantomData, prelude::*};

pub use ethereum::{
AccessListItem, BlockV2 as Block, LegacyTransactionMessage, Log, ReceiptV3 as Receipt,
TransactionAction, TransactionV2 as Transaction,
};
// Frontier
use fp_consensus::{PostLog, PreLog, FRONTIER_ENGINE_ID};
pub use fp_ethereum::TransactionData;
use fp_ethereum::ValidatedTransaction as ValidatedTransactionT;
use fp_evm::{
CallOrCreateInfo, CheckEvmTransaction, CheckEvmTransactionConfig, TransactionValidationError,
};
pub use fp_rpc::TransactionStatus;
use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA};
use pallet_evm::{BlockHashMapping, FeeCalculator, GasWeightMapping, Runner};

#[derive(Clone, Eq, PartialEq, RuntimeDebug)]
#[derive(Encode, Decode, MaxEncodedLen, TypeInfo)]
Expand Down
9 changes: 5 additions & 4 deletions frame/ethereum/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@
//! Test utilities
use ethereum::{TransactionAction, TransactionSignature};
use rlp::RlpStream;
// Substrate
use frame_support::{
dispatch::Dispatchable,
parameter_types,
traits::{ConstU32, FindAuthor},
weights::Weight,
ConsensusEngineId, PalletId,
};
use pallet_evm::{AddressMapping, EnsureAddressTruncated, FeeCalculator};
use rlp::RlpStream;
use sp_core::{hashing::keccak_256, H160, H256, U256};
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
traits::{BlakeTwo256, Dispatchable, IdentityLookup},
AccountId32, BuildStorage,
};
// Frontier
use pallet_evm::{AddressMapping, EnsureAddressTruncated, FeeCalculator};

use super::*;
use crate::IntermediateStateRoot;
Expand Down
1 change: 1 addition & 0 deletions frame/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
environmental = { workspace = true, optional = true }
evm = { workspace = true, features = ["with-codec"] }
hash-db = { workspace = true }
hex = { workspace = true, optional = true }
hex-literal = { workspace = true }
impl-trait-for-tuples = "0.2.2"
Expand Down
2 changes: 1 addition & 1 deletion frame/evm/precompile/curve25519/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = { workspace = true }
repository = { workspace = true }

[dependencies]
curve25519-dalek = { version = "4.0.0-rc.1", default-features = false, features = ["alloc"] }
curve25519-dalek = { version = "4.1.0", default-features = false, features = ["alloc"] }
# Frontier
fp-evm = { workspace = true }

Expand Down
5 changes: 4 additions & 1 deletion frame/evm/precompile/dispatch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ edition = { workspace = true }
repository = { workspace = true }

[dependencies]
scale-codec = { package = "parity-scale-codec", workspace = true }
# Substrate
frame-support = { workspace = true }
sp-runtime = { workspace = true }
# Frontier
fp-evm = { workspace = true }
pallet-evm = { workspace = true }

[dev-dependencies]
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-info = { workspace = true }
# Substrate
frame-system = { workspace = true, features = ["default"] }
Expand All @@ -30,8 +31,10 @@ sp-std = { workspace = true, features = ["default"] }
[features]
default = ["std"]
std = [
"scale-codec/std",
# Substrate
"frame-support/std",
"sp-runtime/std",
# Frontier
"fp-evm/std",
"pallet-evm/std",
Expand Down
14 changes: 9 additions & 5 deletions frame/evm/precompile/dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ mod tests;

use alloc::format;
use core::marker::PhantomData;

use scale_codec::{Decode, DecodeLimit};
// Substrate
use frame_support::{
dispatch::{DispatchClass, GetDispatchInfo, Pays, PostDispatchInfo},
traits::{ConstU32, Get},
};
use sp_runtime::traits::Dispatchable;
// Frontier
use fp_evm::{
ExitError, ExitSucceed, Precompile, PrecompileFailure, PrecompileHandle, PrecompileOutput,
PrecompileResult,
};
use frame_support::{
codec::{Decode, DecodeLimit as _},
dispatch::{DispatchClass, Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo},
traits::{ConstU32, Get},
};
use pallet_evm::{AddressMapping, GasWeightMapping};

// `DecodeLimit` specifies the max depth a call can use when decoding, as unbounded depth
Expand Down
2 changes: 1 addition & 1 deletion frame/evm/precompile/ed25519/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = { workspace = true }
repository = { workspace = true }

[dependencies]
ed25519-dalek = { version = "1.0.0", default-features = false, features = ["alloc", "u64_backend"] }
ed25519-dalek = { version = "2.0.0", default-features = false, features = ["alloc"] }
# Frontier
fp-evm = { workspace = true }

Expand Down
18 changes: 6 additions & 12 deletions frame/evm/precompile/ed25519/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
extern crate alloc;

use alloc::vec::Vec;
use core::convert::TryFrom;
use ed25519_dalek::{PublicKey, Signature, Verifier};

use ed25519_dalek::{Signature, Verifier, VerifyingKey};
use fp_evm::{ExitError, ExitSucceed, LinearCostPrecompile, PrecompileFailure};

pub struct Ed25519Verify;
Expand All @@ -44,7 +44,7 @@ impl LinearCostPrecompile for Ed25519Verify {
let mut buf = [0u8; 4];

let msg = &i[0..32];
let pk = PublicKey::from_bytes(&i[32..64]).map_err(|_| PrecompileFailure::Error {
let pk = VerifyingKey::try_from(&i[32..64]).map_err(|_| PrecompileFailure::Error {
exit_status: ExitError::Other("Public key recover failed".into()),
})?;
let sig = Signature::try_from(&i[64..128]).map_err(|_| PrecompileFailure::Error {
Expand All @@ -65,7 +65,7 @@ impl LinearCostPrecompile for Ed25519Verify {
#[cfg(test)]
mod tests {
use super::*;
use ed25519_dalek::{Keypair, SecretKey, Signer};
use ed25519_dalek::{Signer, SigningKey};

#[test]
fn test_empty_input() -> Result<(), PrecompileFailure> {
Expand Down Expand Up @@ -96,14 +96,8 @@ mod tests {
073, 197, 105, 123, 050, 105, 025, 112, 059, 172, 003, 028, 174, 127, 096,
];

let secret_key =
SecretKey::from_bytes(&secret_key_bytes).expect("Failed to generate secretkey");
let public_key = (&secret_key).into();

let keypair = Keypair {
secret: secret_key,
public: public_key,
};
let keypair = SigningKey::from_bytes(&secret_key_bytes);
let public_key = keypair.verifying_key();

let msg: &[u8] = b"abcdefghijklmnopqrstuvwxyz123456";
assert_eq!(msg.len(), 32);
Expand Down
2 changes: 1 addition & 1 deletion frame/evm/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ benchmarks! {

let x in 1..10000000;

use frame_benchmarking::vec;
use rlp::RlpStream;
use sp_core::{H160, U256};
use sp_std::vec;

// contract bytecode below is for:
//
Expand Down
6 changes: 4 additions & 2 deletions frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ pub mod weights;
pub use evm::{
Config as EvmConfig, Context, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed,
};
use hash_db::Hasher;
use impl_trait_for_tuples::impl_for_tuples;
use scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
// Substrate
use frame_support::{
dispatch::{DispatchResultWithPostInfo, MaxEncodedLen, Pays, PostDispatchInfo},
dispatch::{DispatchResultWithPostInfo, Pays, PostDispatchInfo},
traits::{
tokens::{
currency::Currency,
Expand All @@ -85,7 +87,7 @@ use frame_support::{
weights::Weight,
};
use frame_system::RawOrigin;
use sp_core::{Decode, Encode, Hasher, H160, H256, U256};
use sp_core::{H160, H256, U256};
use sp_runtime::{
traits::{BadOrigin, NumberFor, Saturating, UniqueSaturatedInto, Zero},
AccountId32, DispatchErrorWithPostInfo,
Expand Down
13 changes: 9 additions & 4 deletions precompiles/src/substrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@
//! - Substrate call dispatch.
//! - Substrate DB read and write costs
use crate::{evm::handle::using_precompile_handle, solidity::revert::revert};
use core::marker::PhantomData;
use fp_evm::{ExitError, PrecompileFailure, PrecompileHandle};

// Substrate
use frame_support::{
dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo},
pallet_prelude::*,
dispatch::{GetDispatchInfo, PostDispatchInfo},
traits::Get,
weights::Weight,
};
use sp_runtime::{traits::Dispatchable, DispatchError};
// Frontier
use fp_evm::{ExitError, PrecompileFailure, PrecompileHandle};
use pallet_evm::GasWeightMapping;

use crate::{evm::handle::using_precompile_handle, solidity::revert::revert};

#[derive(Debug)]
pub enum TryDispatchError {
Evm(ExitError),
Expand Down
2 changes: 1 addition & 1 deletion primitives/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
evm = { workspace = true, features = ["with-codec"] }
num_enum = { version = "0.6.1", default-features = false }
num_enum = { workspace = true, default-features = false }
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-info = { workspace = true }
serde = { workspace = true, optional = true }
Expand Down
Loading

0 comments on commit 5d86b28

Please sign in to comment.