Skip to content

Commit

Permalink
update substrate to polkadot-v0.9.43
Browse files Browse the repository at this point in the history
  • Loading branch information
koushiro committed Jun 14, 2023
1 parent 41a90ef commit 18adfe1
Show file tree
Hide file tree
Showing 20 changed files with 729 additions and 556 deletions.
1,133 changes: 640 additions & 493 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,22 @@ repository = "https://github.com/paritytech/frontier/"

[workspace.dependencies]
bn = { package = "substrate-bn", version = "0.6", default-features = false }
clap = { version = "4.3", features = ["derive", "deprecated"] }
environmental = { version = "1.1.4", default-features = false }
ethereum = { version = "0.14.0", default-features = false }
ethereum-types = { version = "0.14.1", default-features = false }
evm = { version = "0.39.1", default-features = false }
hex-literal = { version = "0.3.4" }
impl-serde = { version = "0.4.0", default-features = false }
jsonrpsee = "0.16.2"
kvdb-rocksdb = "0.18.0"
kvdb-rocksdb = "0.19.0"
libsecp256k1 = { version = "0.7.1", default-features = false }
log = { version = "0.4.17", default-features = false }
parity-db = "0.4.6"
rlp = { version = "0.5", default-features = false }
scale-codec = { package = "parity-scale-codec", version = "3.2.1", default-features = false, features = ["derive"] }
scale-info = { version = "2.3.1", default-features = false, features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] }
serde_json = "1.0"
sqlx = { version = "0.7.0-alpha.3", default-features = false, features = ["macros"] }
tokio = "1.28.2"
Expand Down
2 changes: 1 addition & 1 deletion client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
clap = { version = "4.1", features = ["derive", "deprecated"] }
clap = { workspace = true }
ethereum-types = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand Down
2 changes: 0 additions & 2 deletions frame/base-fee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub mod pallet {
_marker: PhantomData<T>,
}

#[cfg(feature = "std")]
impl<T: Config> GenesisConfig<T> {
pub fn new(base_fee_per_gas: U256, elasticity: Permill) -> Self {
Self {
Expand All @@ -70,7 +69,6 @@ pub mod pallet {
}
}

#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion frame/dynamic-fee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub mod pallet {
}

#[pallet::genesis_config]
#[cfg_attr(feature = "std", derive(Default))]
#[derive(Default)]
pub struct GenesisConfig {
pub min_gas_price: U256,
}
Expand Down
7 changes: 3 additions & 4 deletions frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ use sp_runtime::{
traits::{BadOrigin, Saturating, UniqueSaturatedInto, Zero},
AccountId32, DispatchErrorWithPostInfo,
};
use sp_std::{cmp::min, vec::Vec};
use sp_std::{cmp::min, collections::btree_map::BTreeMap, vec::Vec};

pub use evm::{
Config as EvmConfig, Context, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed,
};
use fp_account::AccountId20;
#[cfg(feature = "std")]
use fp_evm::GenesisAccount;
pub use fp_evm::{
Account, CallInfo, CreateInfo, ExecutionInfo, FeeCalculator, InvalidEvmTransactionError,
Expand Down Expand Up @@ -478,9 +477,9 @@ pub mod pallet {
}

#[pallet::genesis_config]
#[cfg_attr(feature = "std", derive(Default))]
#[derive(Default)]
pub struct GenesisConfig {
pub accounts: std::collections::BTreeMap<H160, GenesisAccount>,
pub accounts: BTreeMap<H160, GenesisAccount>,
}

#[pallet::genesis_build]
Expand Down
9 changes: 8 additions & 1 deletion primitives/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ std = [
"log/std",
"scale-codec/std",
"scale-info/std",
"serde",
"serde/std",
# Substrate
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
serde = [
"dep:serde",
"impl-serde",
"scale-info/serde",
"sp-core/serde",
"sp-runtime/serde",
]
8 changes: 4 additions & 4 deletions primitives/account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
// Substrate
use sp_core::{ecdsa, H160, H256};
use sp_core::{ecdsa, RuntimeDebug, H160, H256};
use sp_io::hashing::keccak_256;

/// A fully Ethereum-compatible `AccountId`.
Expand All @@ -30,7 +30,7 @@ use sp_io::hashing::keccak_256;
#[derive(Encode, Decode, MaxEncodedLen, TypeInfo)]
pub struct AccountId20(pub [u8; 20]);

#[cfg(feature = "std")]
#[cfg(feature = "serde")]
impl_serde::impl_fixed_hash_serde!(AccountId20, 20);

#[cfg(feature = "std")]
Expand Down Expand Up @@ -113,8 +113,8 @@ impl From<ecdsa::Public> for AccountId20 {
}
}

#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[derive(Eq, PartialEq, Clone, Encode, Decode, sp_core::RuntimeDebug, TypeInfo)]
#[derive(Eq, PartialEq, Clone, RuntimeDebug, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct EthereumSignature(ecdsa::Signature);

impl sp_runtime::traits::Verify for EthereumSignature {
Expand Down
8 changes: 7 additions & 1 deletion primitives/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ default = ["std"]
std = [
"evm/std",
"evm/with-serde",
"serde",
"serde/std",
"scale-codec/std",
# Substrate
"frame-support/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
]
serde = [
"dep:serde",
"scale-info/serde",
"sp-core/serde",
"sp-runtime/serde",
]
24 changes: 12 additions & 12 deletions primitives/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ mod validation;
use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight};
use scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use sp_core::{H160, U256};
use sp_core::{H160, H256, U256};
use sp_runtime::Perbill;
use sp_std::vec::Vec;
use sp_std::{collections::btree_map::BTreeMap, vec::Vec};

pub use evm::{
backend::{Basic as Account, Log},
Expand All @@ -48,8 +48,8 @@ pub use self::{
},
};

#[derive(Clone, Eq, PartialEq, Default, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[derive(Clone, Eq, PartialEq, Default, Debug, Encode, Decode)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
/// External input from the transaction.
pub struct Vicinity {
/// Current transaction gas price.
Expand All @@ -58,8 +58,8 @@ pub struct Vicinity {
pub origin: H160,
}

#[derive(Clone, Eq, PartialEq, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ExecutionInfo<T> {
pub exit_reason: ExitReason,
pub value: T,
Expand All @@ -70,23 +70,23 @@ pub struct ExecutionInfo<T> {
pub type CallInfo = ExecutionInfo<Vec<u8>>;
pub type CreateInfo = ExecutionInfo<H160>;

#[derive(Clone, Eq, PartialEq, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum CallOrCreateInfo {
Call(CallInfo),
Create(CreateInfo),
}

/// Account definition used for genesis block construction.
#[cfg(feature = "std")]
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, Serialize, Deserialize)]
#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct GenesisAccount {
/// Account nonce.
pub nonce: U256,
/// Account balance.
pub balance: U256,
/// Full account storage.
pub storage: std::collections::BTreeMap<sp_core::H256, sp_core::H256>,
pub storage: BTreeMap<H256, H256>,
/// Account code.
pub code: Vec<u8>,
}
Expand Down
7 changes: 6 additions & 1 deletion primitives/self-contained/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ default = ["std"]
std = [
"scale-codec/std",
"scale-info/std",
"serde",
"serde/std",
# Substrate
"frame-support/std",
"sp-runtime/std",
]
serde = [
"dep:serde",
"scale-info/serde",
"sp-runtime/serde",
]
try-runtime = [
"sp-runtime/try-runtime",
]
4 changes: 2 additions & 2 deletions primitives/self-contained/src/unchecked_extrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ where
}
}

#[cfg(feature = "std")]
#[cfg(feature = "serde")]
impl<Address: Encode, Signature: Encode, Call: Encode, Extra: SignedExtension> serde::Serialize
for UncheckedExtrinsic<Address, Call, Signature, Extra>
{
Expand All @@ -192,7 +192,7 @@ impl<Address: Encode, Signature: Encode, Call: Encode, Extra: SignedExtension> s
}
}

#[cfg(feature = "std")]
#[cfg(feature = "serde")]
impl<'a, Address: Decode, Signature: Decode, Call: Decode, Extra: SignedExtension>
serde::Deserialize<'a> for UncheckedExtrinsic<Address, Call, Signature, Extra>
{
Expand Down
5 changes: 4 additions & 1 deletion primitives/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ serde = { workspace = true, optional = true }
default = ["std"]
std = [
"scale-codec/std",
"serde",
"serde/std",
]
serde = [
"dep:serde",
]
2 changes: 1 addition & 1 deletion template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
async-trait = "0.1"
clap = { version = "4.1", features = ["derive", "deprecated"] }
clap = { workspace = true }
futures = "0.3.25"
hex-literal = { workspace = true }
jsonrpsee = { workspace = true, features = ["server", "macros"] }
Expand Down
8 changes: 5 additions & 3 deletions template/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
use sp_state_machine::BasicExternalities;
// Frontier
use frontier_template_runtime::{
AccountId, EnableManualSeal, GenesisConfig, SS58Prefix, Signature, WASM_BINARY,
AccountId, Balance, EnableManualSeal, GenesisConfig, SS58Prefix, Signature, WASM_BINARY,
};

// The URL for the telemetry server.
Expand Down Expand Up @@ -77,6 +77,8 @@ fn properties() -> Properties {
properties
}

const UNITS: Balance = 1_000_000_000_000_000_000;

pub fn development_config(enable_manual_seal: Option<bool>) -> DevChainSpec {
let wasm_binary = WASM_BINARY.expect("WASM not available");

Expand Down Expand Up @@ -161,6 +163,7 @@ pub fn local_testnet_config() -> ChainSpec {
None,
// Protocol ID
None,
// Fork ID
None,
// Properties
None,
Expand Down Expand Up @@ -195,11 +198,10 @@ fn testnet_genesis(

// Monetary
balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, 1 << 60))
.map(|k| (k, 1_000_000 * UNITS))
.collect(),
},
transaction_payment: Default::default(),
Expand Down
11 changes: 2 additions & 9 deletions template/node/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use futures::{future, prelude::*};
use sc_client_api::{BlockchainEvents, StateBackendFor};
use sc_executor::NativeExecutionDispatch;
use sc_network_sync::SyncingService;
use sc_service::{error::Error as ServiceError, BasePath, Configuration, TaskManager};
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sp_api::ConstructRuntimeApi;
use sp_runtime::traits::BlakeTwo256;
// Frontier
Expand All @@ -26,14 +26,7 @@ use crate::client::{FullBackend, FullClient};
pub type FrontierBackend = fc_db::Backend<Block>;

pub fn db_config_dir(config: &Configuration) -> PathBuf {
let application = &config.impl_name;
config
.base_path
.as_ref()
.map(|base_path| base_path.config_dir(config.chain_spec.id()))
.unwrap_or_else(|| {
BasePath::from_project("", "", application).config_dir(config.chain_spec.id())
})
config.base_path.config_dir(config.chain_spec.id())
}

/// Avalailable frontier backend types.
Expand Down
11 changes: 5 additions & 6 deletions template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ where
fee_history_cache_limit,
} = new_frontier_partial(&eth_config)?;

let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);
let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name(
&client.block_hash(0)?.expect("Genesis block exists; qed"),
&config.chain_spec,
Expand All @@ -317,12 +318,9 @@ where
let warp_sync_params = if sealing.is_some() {
None
} else {
config
.network
.extra_sets
.push(sc_consensus_grandpa::grandpa_peers_set_config(
grandpa_protocol_name.clone(),
));
net_config.add_notification_protocol(sc_consensus_grandpa::grandpa_peers_set_config(
grandpa_protocol_name.clone(),
));
let warp_sync: Arc<dyn sc_network::config::WarpSyncProvider<Block>> =
Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
Expand All @@ -335,6 +333,7 @@ where
let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
net_config,
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
Expand Down
3 changes: 2 additions & 1 deletion template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ std = [
"frame-support/std",
"frame-system/std",
"frame-system-rpc-runtime-api/std",
"frame-system-benchmarking/std",
"frame-system-benchmarking?/std",
"pallet-aura/std",
"pallet-balances/std",
"pallet-grandpa/std",
Expand Down Expand Up @@ -118,6 +118,7 @@ runtime-benchmarks = [
"pallet-balances/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-ethereum/runtime-benchmarks",
"pallet-evm/runtime-benchmarks",
"pallet-hotfix-sufficients/runtime-benchmarks",
Expand Down
Loading

0 comments on commit 18adfe1

Please sign in to comment.