Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor eth-offchain #382

Merged
merged 26 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
25 changes: 24 additions & 1 deletion .maintain/types/types.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
{
"DigestItem": {
"_enum": {
"Other": "Bytes",
"AuthoritiesChange": "Vec<AuthorityId>",
"ChangesTrieRoot": "Hash",
"SealV0": "SealV0",
"Consensus": "Consensus",
"Seal": "Seal",
"PreRuntime": "PreRuntime",
"Unknown7": "Bytes",
"Unknown8": "Bytes",
"Unknown9": "Bytes",
"Unknown10": "Bytes",
"Unknown11": "Bytes",
"Unknown12": "Bytes",
"Unknown13": "Bytes",
"Unknown14": "Bytes",
"Unknown15": "Bytes",
"Unknown16": "Bytes",
"Unknown17": "Bytes",
"MerkleMountainRangeRoot": "Hash"
}
},
"RingBalance": "Balance",
"KtonBalance": "Balance",
"MomentT": "Moment",
Expand Down Expand Up @@ -117,7 +140,7 @@
"parent_hash": "H256",
"timestamp": "u64",
"number": "EthBlockNumber",
"auth": "EthAddress",
"author": "EthAddress",
"transaction_root": "H256",
"uncles_hash": "H256",
"extra_data": "Bytes",
Expand Down
13 changes: 12 additions & 1 deletion .maintain/types/types.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
title = "Darwinia Node Runtime Types"

[system]
[system.complex]
Digest._enum.Others = "Bytes"
Digest._enum.AuthoritiesChange = "AuthoritiesChange"
Digest._enum.ChangesTrieRoot = "Hash"
Digest._enum.SealV0 = "SealV0"
Digest._enum.Consensus = "Consensus"
Digest._enum.Seal = "Seal"
Digest._enum.PreRuntime = "PreRuntime"
Digest._enum.MerkleMontainRangeRoot = "Hash"

[staking]
[staking.basic]
RingBalance = "Balance"
Expand Down Expand Up @@ -84,7 +95,7 @@ title = "Darwinia Node Runtime Types"
EthHeader.parent_hash = "H256"
EthHeader.timestamp = "u64"
EthHeader.number = "EthBlockNumber"
EthHeader.auth = "EthAddress"
EthHeader.author = "EthAddress"
EthHeader.transaction_root = "H256"
EthHeader.uncles_hash = "H256"
EthHeader.extra_data = "Bytes"
Expand Down
25 changes: 10 additions & 15 deletions Cargo.lock

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

13,179 changes: 6,592 additions & 6,587 deletions bin/node/cli/res/crab.json

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,36 @@ pub fn darwinia_genesis(
}),
pallet_eth_relay: Some(EthRelayConfig {
authorities: eth_relay_authorities,
genesis: Some((
vec![
249, 2, 21, 160, 110, 20, 148, 173, 142, 2, 161, 38, 251, 134, 207, 130, 177, 54, 39, 196, 94, 110,
143, 30, 171, 5, 225, 66, 112, 166, 154, 5, 215, 254, 94, 38, 160, 134, 82, 165, 254, 194, 63, 139,
211, 63, 152, 152, 192, 92, 205, 149, 60, 44, 31, 174, 176, 211, 222, 145, 140, 150, 122, 36, 183,
9, 37, 72, 20, 148, 90, 11, 84, 213, 220, 23, 224, 170, 220, 56, 61, 45, 180, 59, 10, 13, 62, 2,
156, 76, 160, 83, 252, 235, 143, 137, 30, 50, 28, 81, 36, 65, 74, 155, 253, 151, 238, 57, 171, 185,
117, 6, 105, 54, 189, 34, 5, 151, 165, 120, 199, 101, 90, 160, 102, 26, 255, 46, 202, 108, 87, 179,
203, 15, 11, 85, 212, 71, 97, 212, 38, 156, 101, 72, 237, 18, 189, 235, 170, 55, 223, 54, 210, 229,
183, 88, 160, 75, 87, 116, 76, 217, 125, 35, 122, 135, 81, 169, 99, 23, 174, 203, 231, 219, 82,
243, 2, 222, 211, 98, 70, 212, 23, 130, 250, 206, 129, 193, 124, 185, 1, 0, 120, 144, 204, 128,
145, 92, 164, 64, 81, 198, 224, 193, 1, 80, 80, 132, 237, 201, 128, 225, 81, 1, 32, 16, 180, 108,
0, 98, 62, 64, 32, 168, 58, 88, 19, 89, 208, 139, 9, 94, 173, 1, 22, 164, 8, 218, 11, 156, 55, 130,
96, 80, 136, 33, 8, 38, 19, 52, 64, 234, 104, 36, 152, 28, 120, 37, 0, 96, 246, 74, 163, 166, 200,
144, 16, 40, 0, 194, 53, 231, 32, 65, 100, 37, 38, 72, 164, 229, 162, 64, 230, 231, 32, 104, 0, 0,
48, 50, 1, 4, 4, 92, 65, 45, 224, 174, 68, 138, 18, 108, 16, 64, 14, 36, 72, 100, 80, 11, 44, 36,
158, 0, 174, 176, 97, 20, 48, 100, 183, 184, 16, 212, 230, 1, 160, 24, 84, 37, 66, 192, 149, 136,
12, 82, 27, 137, 133, 59, 69, 132, 0, 24, 97, 107, 8, 22, 206, 144, 242, 192, 26, 100, 33, 36, 178,
12, 61, 0, 140, 251, 224, 135, 2, 96, 123, 164, 242, 104, 32, 12, 41, 78, 28, 32, 2, 179, 40, 15,
58, 174, 147, 18, 17, 148, 33, 226, 87, 8, 64, 187, 64, 35, 49, 49, 6, 75, 64, 141, 58, 0, 51, 120,
153, 64, 5, 193, 9, 10, 128, 115, 193, 80, 20, 147, 176, 83, 236, 196, 128, 202, 80, 24, 94, 129,
5, 210, 64, 118, 42, 103, 12, 164, 58, 96, 54, 64, 138, 180, 98, 4, 210, 30, 12, 146, 61, 26, 135,
7, 219, 22, 241, 164, 64, 46, 131, 148, 110, 239, 131, 152, 131, 190, 131, 152, 55, 7, 132, 94,
120, 169, 245, 148, 115, 112, 97, 114, 107, 112, 111, 111, 108, 45, 101, 116, 104, 45, 99, 110, 45,
104, 122, 51, 160, 28, 248, 29, 120, 88, 139, 237, 244, 239, 138, 13, 176, 7, 187, 163, 27, 23,
193, 8, 107, 234, 217, 185, 186, 222, 202, 141, 52, 177, 93, 180, 32, 136, 169, 141, 24, 64, 4, 34,
198, 78,
],
0x7db16f1a4402e,
)),
..Default::default()
}),
pallet_kton: Some(KtonConfig {
Expand Down
46 changes: 21 additions & 25 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub use pallet_timestamp::Call as TimestampCall;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

use pallet_eth_offchain;
pub use pallet_ring::Call as RingCall;
pub use pallet_staking::StakerStatus;

Expand Down Expand Up @@ -100,27 +99,6 @@ impl OnUnbalanced<NegativeImbalance> for DealWithFees {
}
}

type SubmitPFTransaction =
frame_system::offchain::TransactionSubmitter<pallet_eth_offchain::crypto::Public, Runtime, UncheckedExtrinsic>;

parameter_types! {
pub const BlockFetchDur: BlockNumber = 3;
// TODO: pass this from command line
// this a poc versiona, build with following command to launch the poc binary
// `APIKEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX cargo build`
pub const EthScanAPIKey: Option<Vec<u8>> = match option_env!("APIKEY"){
Some(s) => Some(s.as_bytes().to_vec()),
None => None,
};
}

impl pallet_eth_offchain::Trait for Runtime {
type Event = Event;
type Call = Call;
type SubmitSignedTransaction = SubmitPFTransaction;
type BlockFetchDur = BlockFetchDur;
type APIKey = EthScanAPIKey;
}
parameter_types! {
pub const BlockHashCount: BlockNumber = 250;
pub const MaximumBlockWeight: Weight = 1_000_000_000;
Expand Down Expand Up @@ -388,7 +366,6 @@ impl pallet_sudo::Trait for Runtime {

/// A runtime transaction submitter.
type SubmitTransaction = TransactionSubmitter<ImOnlineId, Runtime, UncheckedExtrinsic>;

parameter_types! {
pub const SessionDuration: BlockNumber = SESSION_DURATION;
}
Expand Down Expand Up @@ -557,10 +534,29 @@ impl pallet_eth_relay::Trait for Runtime {
type EthNetwork = EthRopsten;
}

impl pallet_header_mmr::Trait for Runtime {
type SubmitPFTransaction =
frame_system::offchain::TransactionSubmitter<pallet_eth_offchain::crypto::Public, Runtime, UncheckedExtrinsic>;
parameter_types! {
pub const FetchInterval: BlockNumber = 3;
// TODO: pass this from command line
// this a poc versiona, build with following command to launch the poc binary
// `ETHER_SCAN_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX cargo build`
pub const EtherScanAPIKey: Option<Vec<u8>> = match option_env!("ETHER_SCAN_API_KEY"){
Some(s) => Some(s.as_bytes().to_vec()),
None => None,
};
}
impl pallet_eth_offchain::Trait for Runtime {
type Event = Event;
type Time = Timestamp;
type Call = Call;
type SubmitSignedTransaction = SubmitPFTransaction;
type FetchInterval = FetchInterval;
type EtherScanAPIKey = EtherScanAPIKey;
}

impl pallet_header_mmr::Trait for Runtime {}

parameter_types! {
pub const ExistentialDeposit: Balance = 1 * COIN;
}
Expand Down Expand Up @@ -694,7 +690,7 @@ construct_runtime!(
EthBacking: pallet_eth_backing::{Module, Call, Storage, Config<T>, Event<T>},
EthRelay: pallet_eth_relay::{Module, Call, Storage, Config<T>, Event<T>},
EthOffchain: pallet_eth_offchain::{Module, Call, Storage, Event<T>},
HeaderMMR: pallet_header_mmr::{Module, Call, Storage, Event<T>},
HeaderMMR: pallet_header_mmr::{Module, Call, Storage},
Kton: pallet_kton::{Module, Call, Storage, Config<T>, Event<T>},
Balances: pallet_ring::{Module, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Module, Call, Storage, Config<T>, Event<T>},
Expand Down
2 changes: 1 addition & 1 deletion frame/chainrelay/eth/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ decl_error! {
/// *RING* Locked - NO SUFFICIENT BACKING ASSETS
RingLockedNSBA,

/// Log Entry - NOT EXISTS
/// Log Entry - NOT EXISTED
LogEntryNE,
}
}
Expand Down
78 changes: 39 additions & 39 deletions frame/chainrelay/eth/offchain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
[package]
name = "darwinia-eth-offchain"
version = "0.1.0"
authors = ["yanganto <yanganto@gmail.com>"]
authors = ["Darwinia Network <hello@darwinia.network>"]
description = "FRAME pallet to relay Ethereum header automactically"
edition = "2018"
license = "GPL-3.0"
homepage = "https://darwinia.network/"
repository = "https://github.com/darwinia-network/darwinia/"

[dependencies]
num-traits = { default-features = false, version = "0.2.8" }

sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }
sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }
sp-io = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }
sp-session = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }
# crates.io
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
hex = { version = "0.4.2", default-features = false }
simple-json = { version = '0.1.5', default_features = false, git = 'https://github.com/jimmychu0807/simple-json' }

# github.com
frame-support = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }
frame-system = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }

pallet-timestamp = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }
pallet-eth-relay = { default-features = false, package = "darwinia-eth-relay", path = "../relay" }
sp-runtime = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }
sp-std = { default-features = false, git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }

rlp = { default-features = false, git = "https://github.com/darwinia-network/parity-common.git" }

parity-scale-codec = { version = "1.0.0", default-features = false, features = ["derive"] }
simple-json = { git = 'https://github.com/jimmychu0807/simple-json', version = '0.1.5', default_features = false }
primitive-types = { default-features = false, features = ["codec", "rlp"], git = "https://github.com/darwinia-network/parity-common.git" }
hex = { default-features = false, version = "0.4.2" }
# darwinia
eth-primitives = { default-features = false, path = "../../../../primitives/eth-primitives" }
ethereum-types = { default-features = false, git = "https://github.com/darwinia-network/parity-common.git" }
ethbloom = { default-features = false, git ="https://github.com/darwinia-network/parity-common.git" }
rlp = { default-features = false, git = "https://github.com/darwinia-network/parity-common.git" }

[build-dependencies]
wasm-builder-runner = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2", package = "substrate-wasm-builder-runner", version = "1.0.4" }
pallet-eth-relay = { package = "darwinia-eth-relay", default-features = false, path = "../relay" }

[dev-dependencies]
pallet-timestamp = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }

sp-core = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.2" }

pallet-eth-relay = { package = "darwinia-eth-relay", path = "../relay" }
pallet-support = { package = "darwinia-support", path = "../../../../frame/support" }

[features]
default = ["std"]
std = [
"num-traits/std",

"sp-std/std",
"sp-io/std",
"sp-runtime/std",
"sp-session/std",

"frame-support/std",
"frame-system/std",

"pallet-timestamp/std",
"pallet-eth-relay/std",

"parity-scale-codec/std",
"simple-json/std",
"primitive-types/std",
"hex/std",
"eth-primitives/std",
"ethereum-types/std",
"ethbloom/std",
"rlp/std",
"codec/std",
"hex/std",
"simple-json/std",

"frame-support/std",
"frame-system/std",

"sp-std/std",
"sp-runtime/std",

"rlp/std",

"eth-primitives/std",

"pallet-eth-relay/std",
]
Loading