Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
378d8fd
Changes based on substrate commits till the current master
dmitrylavrenov Dec 6, 2021
96b6fde
Add pallet-evm and pallet-ethereum from humanode fork
dmitrylavrenov Dec 3, 2021
f820824
integrate EVM to current humanode runtime
dmitrylavrenov Dec 13, 2021
3d91f98
Sort cargo
dmitrylavrenov Dec 14, 2021
b7b271b
Add ethereum rpc
dmitrylavrenov Dec 15, 2021
3c1edf4
Add evm config to define max_past_logs for eth api
dmitrylavrenov Dec 15, 2021
68c36de
Improve frontier precompiles and add frontier workers to service
dmitrylavrenov Dec 15, 2021
cc76eee
Fix cargo sort
dmitrylavrenov Jan 11, 2022
99c3b21
Fix std list in humanode-runtime cargo
dmitrylavrenov Jan 11, 2022
d48711f
Use frontier UncheckedExtrinsic as a part of evm integration
dmitrylavrenov Jan 11, 2022
be2627d
Add dynamic-fee to inherent data providers
dmitrylavrenov Jan 11, 2022
fc5343b
Add FrontierBlockImport
dmitrylavrenov Jan 11, 2022
fa8239a
Avoid code duplication for getting evm_config
dmitrylavrenov Jan 11, 2022
8c47e82
Add NetApi to humanode-rpc
dmitrylavrenov Jan 12, 2022
36431d3
Use FullGrandpa type instead of the whole Grandpa def
dmitrylavrenov Jan 12, 2022
6e837ad
Add FilterApi to humanode-rpc
dmitrylavrenov Jan 12, 2022
35d76b9
Export max_stored_filters to evm_config params
dmitrylavrenov Jan 12, 2022
fde558d
Merge branch 'master' into pallet-evm
dmitrylavrenov Jan 12, 2022
c9f6d65
Correct the patch list
MOZGIII Jan 14, 2022
d395c3b
Correct the indent at Cargo.toml
MOZGIII Jan 14, 2022
c3cb5cf
Remove not used CI address
dmitrylavrenov Jan 14, 2022
6835f4f
Update comment for max_past_logs at params.rs
dmitrylavrenov Jan 14, 2022
3a64d12
Update comment for max_past_logs at configuration.rs
dmitrylavrenov Jan 14, 2022
5b7c66e
Edit comments for FullGrandpa and FullFrontier type aliases
dmitrylavrenov Jan 14, 2022
8669741
Define a FullBioauth type
dmitrylavrenov Jan 14, 2022
415d32f
Remove wrapping with Arc and use it later when needed
dmitrylavrenov Jan 14, 2022
1b22326
Return Gerald account as Ethereum dev account
dmitrylavrenov Jan 17, 2022
19584ac
Fix comments based on review
dmitrylavrenov Jan 17, 2022
2f357cb
Move subscription_task_executor to Deps
dmitrylavrenov Jan 17, 2022
f7da4fd
Use raw_slot_duration at frontier-mapping-sync-worker
dmitrylavrenov Jan 17, 2022
c889944
Make frontier-related function to separate mod
dmitrylavrenov Jan 18, 2022
8b0351c
Add missing doc for frontier mod
dmitrylavrenov Jan 18, 2022
69bbb7d
Use super::Block at frontier mod
dmitrylavrenov Jan 18, 2022
3451193
Remove not used CheckedExtrinsic
dmitrylavrenov Jan 18, 2022
de2a966
Use spawn_blocking for frontier-mapping-sync-worker
dmitrylavrenov Jan 19, 2022
dd0de23
Implement TransactionConverterApi and RuntimeTransactionConverter
dmitrylavrenov Jan 19, 2022
0926af1
Getting eth address as a helper function
dmitrylavrenov Jan 19, 2022
e59ddba
Use updated frontier fork
dmitrylavrenov Jan 19, 2022
c13dae8
Fix frontier update by changing ethereum version at evm
dmitrylavrenov Jan 20, 2022
256f107
Apply frontier updates
dmitrylavrenov Jan 20, 2022
275f9a5
Remove useless clippy allowers
dmitrylavrenov Jan 20, 2022
505ba3b
Merge branch 'master' into pallet-evm
dmitrylavrenov Jan 20, 2022
2200607
Remove default-features for frontier-api
dmitrylavrenov Jan 20, 2022
2347aa9
Add eth prefix to ethereum related objects
dmitrylavrenov Jan 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
786 changes: 711 additions & 75 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
[workspace]
resolver = "2"
members = ["crates/*"]

[patch."https://github.com/paritytech/substrate"]
frame-benchmarking = { git = "https://github.com/humanode-network/substrate", branch = "master" }
frame-support = { git = "https://github.com/humanode-network/substrate", branch = "master" }
frame-system = { git = "https://github.com/humanode-network/substrate", branch = "master" }
pallet-balances = { git = "https://github.com/humanode-network/substrate", branch = "master" }
pallet-timestamp = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-block-builder = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-network = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-rpc = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-service = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-transaction-pool = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-transaction-pool-api = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-api = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-block-builder = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-core = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-database = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-externalities = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-inherents = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-io = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-std = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-storage = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-timestamp = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-transaction-pool = { git = "https://github.com/humanode-network/substrate", branch = "master" }
substrate-prometheus-endpoint = { git = "https://github.com/humanode-network/substrate", branch = "master" }
15 changes: 15 additions & 0 deletions crates/frontier-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "frontier-api"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
codec = { package = "parity-scale-codec", version = "2", default-features = false }
pallet-ethereum = { default-features = false, git = "https://github.com/humanode-network/frontier", branch = "substrate-1a30fa2" }
sp-api = { default-features = false, git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-std = { default-features = false, git = "https://github.com/humanode-network/substrate", branch = "master" }

[features]
default = ["std"]
std = ["codec/std", "sp-api/std", "sp-std/std", "pallet-ethereum/std"]
14 changes: 14 additions & 0 deletions crates/frontier-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! The runtime API for the frontier related stuff.

#![cfg_attr(not(feature = "std"), no_std)]

use codec::Decode;
use sp_std::prelude::*;

sp_api::decl_runtime_apis! {
/// Runtime API for the transaction converter.
pub trait TransactionConverterApi<Extrinsic: Decode> {
/// Convert an ethereum transaction to an extrinsic.
fn convert_transaction(transaction: pallet_ethereum::Transaction) -> Extrinsic;
}
}
9 changes: 9 additions & 0 deletions crates/humanode-peer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ robonode-client = { version = "0.1", path = "../robonode-client" }
anyhow = "1"
async-trait = "0.1"
codec = { package = "parity-scale-codec", version = "2.0.0" }
fc-consensus = { default-features = false, git = "https://github.com/humanode-network/frontier", branch = "substrate-1a30fa2" }
fc-db = { default-features = false, git = "https://github.com/humanode-network/frontier", branch = "substrate-1a30fa2" }
fc-mapping-sync = { default-features = false, git = "https://github.com/humanode-network/frontier", branch = "substrate-1a30fa2" }
fc-rpc = { default-features = false, git = "https://github.com/humanode-network/frontier", branch = "substrate-1a30fa2" }
fc-rpc-core = { default-features = false, git = "https://github.com/humanode-network/frontier", branch = "substrate-1a30fa2" }
fdlimit = "0.2"
frame-benchmarking-cli = { git = "https://github.com/humanode-network/substrate", branch = "master" }
futures = "0.3"
hex = "0.4.3"
hex-literal = "0.3"
pallet-dynamic-fee = { default-features = false, git = "https://github.com/humanode-network/frontier", branch = "substrate-1a30fa2" }
pallet-evm = { default-features = false, git = "https://github.com/humanode-network/frontier", branch = "substrate-1a30fa2" }
qr2term = "0.2"
reqwest = "0.11"
sc-basic-authorship = { git = "https://github.com/humanode-network/substrate", branch = "master" }
Expand All @@ -38,6 +45,7 @@ sc-consensus-aura = { git = "https://github.com/humanode-network/substrate", bra
sc-executor = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-finality-grandpa = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-network = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-rpc = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-service = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-telemetry = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sc-tracing = { git = "https://github.com/humanode-network/substrate", branch = "master" }
Expand All @@ -47,6 +55,7 @@ serde = { version = "1", features = ["derive"] }
sp-application-crypto = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-consensus-aura = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-core = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-finality-grandpa = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-keystore = { git = "https://github.com/humanode-network/substrate", branch = "master" }
sp-panic-handler = { git = "https://github.com/humanode-network/substrate", branch = "master" }
Expand Down
49 changes: 47 additions & 2 deletions crates/humanode-peer/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

use hex_literal::hex;
use humanode_runtime::{
AccountId, AuraConfig, BalancesConfig, BioauthConfig, GenesisConfig, GrandpaConfig,
RobonodePublicKeyWrapper, Signature, SudoConfig, SystemConfig, UnixMilliseconds, WASM_BINARY,
AccountId, AuraConfig, BalancesConfig, BioauthConfig, EVMConfig, EthereumConfig, GenesisConfig,
GrandpaConfig, RobonodePublicKeyWrapper, Signature, SudoConfig, SystemConfig, UnixMilliseconds,
WASM_BINARY,
};
use pallet_bioauth::{AuthTicketNonce, Authentication};
use sc_chain_spec_derive::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{H160, U256};
use sp_finality_grandpa::AuthorityId as GrandpaId;
use sp_runtime::{
app_crypto::{sr25519, Pair, Public},
traits::{IdentifyAccount, Verify},
};
use std::{collections::BTreeMap, str::FromStr};

/// The concrete chain spec type we're using for the humanode network.
pub type ChainSpec = sc_service::GenericChainSpec<humanode_runtime::GenesisConfig, Extensions>;
Expand Down Expand Up @@ -211,6 +214,48 @@ fn testnet_genesis(
consumed_auth_ticket_nonces,
active_authentications,
},
evm: EVMConfig {
accounts: {
let mut map = BTreeMap::new();
map.insert(
// H160 address of Alice dev account
// Derived from SS58 (42 prefix) address
// SS58: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
// hex: 0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
// Using the full hex key, truncating to the first 20 bytes (the first 40 hex chars)
H160::from_str("d43593c715fdd31c61141abd04a99fd6822c8558")
.expect("internal H160 is valid; qed"),
pallet_evm::GenesisAccount {
balance: U256::from_str("0xffffffffffffffffffffffffffffffff")
.expect("internal U256 is valid; qed"),
code: Default::default(),
nonce: Default::default(),
storage: Default::default(),
},
);
map.insert(
// H160 address of Gerald dev account
// Public address: 0x6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b
// Private key: 0x99b3c12287537e38c90a9219d4cb074a89a16e9cdb20bf85728ebd97c343e342
// A proper private key should be used to allow testing EVM as Ethereum developer
// For example, use it at Metamask, Remix, Truffle configuration, etc
// We don't have a good converter between Substrate and Ethereum private keys for now.
H160::from_str("6be02d1d3665660d22ff9624b7be0551ee1ac91b")
.expect("internal H160 is valid; qed"),
pallet_evm::GenesisAccount {
balance: U256::from_str("0xffffffffffffffffffffffffffffffff")
.expect("internal U256 is valid; qed"),
code: Default::default(),
nonce: Default::default(),
storage: Default::default(),
},
);
map
},
},
ethereum: EthereumConfig {},
dynamic_fee: Default::default(),
base_fee: Default::default(),
}
}

Expand Down
13 changes: 13 additions & 0 deletions crates/humanode-peer/src/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,18 @@ pub trait CliConfigurationExt: SubstrateCliConfigurationProvider {
}
});

let evm = self.evm_params().map(|params| configuration::Evm {
max_past_logs: params.max_past_logs,
max_stored_filters: params.max_stored_filters,
target_gas_price: params.target_gas_price,
fee_history_limit: params.fee_history_limit,
});

Ok(Configuration {
substrate,
bioauth_flow,
bioauth_perform_enroll: self.bioauth_perform_enroll(),
evm,
})
}

Expand All @@ -60,6 +68,11 @@ pub trait CliConfigurationExt: SubstrateCliConfigurationProvider {
fn bioauth_perform_enroll(&self) -> bool {
false
}

/// Provide the evm params, if available.
fn evm_params(&self) -> Option<&params::EvmParams> {
None
}
}

/// Indirect relation to the [`sc_cli::CliConfiguration`] for any type.
Expand Down
21 changes: 21 additions & 0 deletions crates/humanode-peer/src/cli/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,24 @@ pub struct BioauthFlowParams {
#[structopt(long, value_name = "ROBONODE_URL")]
pub robonode_url: Option<String>,
}

/// Shared CLI parameters used to configure evm.
#[derive(Debug, StructOpt, Clone)]
pub struct EvmParams {
/// Maximum number of logs to keep from the latest block;
/// it is not possible to query logs older than this amount from the latest block in the past.
#[structopt(long, default_value = "10000")]
pub max_past_logs: u32,

/// Maximum number of stored filters.
#[structopt(long, default_value = "500")]
pub max_stored_filters: usize,

/// The dynamic-fee pallet target gas price set by block author.
#[structopt(long, default_value = "1")]
pub target_gas_price: u64,

/// Maximum fee history cache size.
#[structopt(long, default_value = "2048")]
pub fee_history_limit: u64,
}
8 changes: 8 additions & 0 deletions crates/humanode-peer/src/cli/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ pub struct RunCmd {
/// Run the bioauth enroll flow before the authentication.
#[structopt(long = "bioauth-enroll")]
bioauth_perform_enroll: bool,

#[allow(missing_docs, clippy::missing_docs_in_private_items)]
#[structopt(flatten)]
pub evm_params: params::EvmParams,
}

impl SubstrateCliConfigurationProvider for RunCmd {
Expand All @@ -37,4 +41,8 @@ impl CliConfigurationExt for RunCmd {
fn bioauth_perform_enroll(&self) -> bool {
self.bioauth_perform_enroll
}

fn evm_params(&self) -> Option<&params::EvmParams> {
Some(&self.evm_params)
}
}
19 changes: 19 additions & 0 deletions crates/humanode-peer/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub struct Configuration {

/// Whether to perform the bioauth enroll before the authentication or not.
pub bioauth_perform_enroll: bool,

/// EVM configuration,
pub evm: Option<Evm>,
}

/// Bioauth flow configuration parameters.
Expand Down Expand Up @@ -47,3 +50,19 @@ impl BioauthFlow {
Ok((webapp_url, rpc_url))
}
}

/// EVM configuration parameters.
pub struct Evm {
/// Maximum number of blocks to keep the log information available
/// for querying via the RPC (from the latest block).
pub max_past_logs: u32,

/// Maximum number of stored filters.
pub max_stored_filters: usize,

/// The dynamic-fee pallet target gas price set by block author.
pub target_gas_price: u64,

/// Maximum fee history cache size.
pub fee_history_limit: u64,
}
28 changes: 28 additions & 0 deletions crates/humanode-peer/src/service/frontier.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! The Frontier related stuff.

use super::Block;
use sc_cli::SubstrateCli;
use sc_service::BasePath;

/// Create frontier dir.
pub fn database_dir(config: &sc_service::Configuration) -> std::path::PathBuf {
let config_dir = config
.base_path
.as_ref()
.map(|base_path| base_path.config_dir(config.chain_spec.id()))
.unwrap_or_else(|| {
BasePath::from_project("", "", &crate::cli::Root::executable_name())
.config_dir(config.chain_spec.id())
});
config_dir.join("frontier").join("db")
}

/// Construct frontier backend.
pub fn open_backend(config: &sc_service::Configuration) -> Result<fc_db::Backend<Block>, String> {
fc_db::Backend::<Block>::new(&fc_db::DatabaseSettings {
source: fc_db::DatabaseSettingsSrc::RocksDb {
path: database_dir(config),
cache_size: 0,
},
})
}
Loading