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

feat: state chain upgraded to substrate 2022-05 #1650

Merged
merged 34 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b8df7b8
feat: state chain upgraded to substrate 2022-05
dandanlen May 9, 2022
83b28a2
feat: merge monthly-2022-05 changes into Cfe
dandanlen May 9, 2022
bc8e541
feat: remove subxt
dandanlen May 9, 2022
017cf37
chore: update benchmarks template
dandanlen May 9, 2022
34e333b
fix: benchmarking and try-runtime compiles
dandanlen May 9, 2022
ee9a482
chore: updatre state chain mocks and tests
dandanlen May 9, 2022
dd0d713
chore: update more tests
dandanlen May 9, 2022
0bca1af
fix call
dandanlen May 10, 2022
2917f33
fix: dependency conflict in signing
dandanlen May 9, 2022
9f3070f
fix: validator tests session keys
dandanlen May 9, 2022
80fc06f
chore: clippy
dandanlen May 9, 2022
f179874
feat: grandpa rpcs
dandanlen May 10, 2022
bb4185f
chore: remove types.json 💥
dandanlen May 10, 2022
2d3d545
feat: new construct_runtime syntax for mocks
dandanlen May 10, 2022
ed4b02d
fix: remove unused dependencies.
dandanlen May 10, 2022
650dd1c
fix: no expected authorship slot at genesis
dandanlen May 10, 2022
8d3d8d5
fix: spelling
dandanlen May 10, 2022
361dc2d
fix: panic if no author is provided.
dandanlen May 10, 2022
207b9db
feat: add a test for SigData MaxEncodedLen impl.
dandanlen May 10, 2022
727083a
fix: integration tests
dandanlen May 11, 2022
e8a0b2f
fix: remove pointless assertion context.
dandanlen May 11, 2022
7608433
fix: unsigned extrinsic submission logs pallet call
dandanlen May 11, 2022
9850c3b
fix: test all MaxEncodedLen impls
dandanlen May 11, 2022
c8f6e66
fix: revert weight template
dandanlen May 11, 2022
7de785c
fix: correctly formatted hbs template
dandanlen May 11, 2022
fcabb06
fix: update benchmark.sh
dandanlen May 11, 2022
47b9c2f
Merge branch 'develop' into feat/integrate-substrate-monthly-2022-05
dandanlen May 11, 2022
762810b
fix: expected_hash encoding
dandanlen May 11, 2022
e74f005
fix: integration tests
dandanlen May 11, 2022
0566f6e
fix: missed authorship slot tests.
dandanlen May 11, 2022
7b78c96
feat: additional cfe logging on failed signing attempt.
dandanlen May 12, 2022
e8692a9
feat: extra loggin on keygen failures.
dandanlen May 12, 2022
675ad51
chore: add comment re. tx fee tip
dandanlen May 12, 2022
7a5f938
chore: add TODO for issue #1657
dandanlen May 12, 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
4,536 changes: 2,437 additions & 2,099 deletions Cargo.lock

Large diffs are not rendered by default.

41 changes: 20 additions & 21 deletions engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ section = "rust"

[dependencies]
anyhow = "1.0"
async-stream = "0.3.0"
async-trait = "0.1.49"
bincode = "1.3.3"
bs58 = "0.4"
Expand All @@ -42,12 +41,11 @@ jsonrpc-http-server = "18.0.0"
jsonrpc-ws-server = "18.0.0"

websocket = "0.24"
ethbloom = "0.11.1"
ethbloom = "0.12.1"
dyn-clone = "1.0.4"
kvdb-rocksdb = "0.14.0"
kvdb-rocksdb = "0.15.2"
lazy_static = "1.4"
num = "0.4.0"
parking_lot = "0.11"
parking_lot = "0.12"
regex = "1"
reqwest = {version = "0.11.4", features = ["json"]}
secp256k1 = "0.20"
Expand All @@ -61,9 +59,11 @@ thiserror = "1.0.26"
tokio = {version = "1.13.1", features = ["full"]}
tokio-stream = "0.1.5"
url = "1.7.2"
web3 = {git = 'https://github.com/tomusdrw/rust-web3.git', rev = 'a425fa7'}
web3 = {git = 'https://github.com/tomusdrw/rust-web3.git', rev = '8796c88', features = ['signing']}
# Required so that we can create a web3-compatilble secret key.
web3-secp256k1 = {package = 'secp256k1', version = '0.21'}
zeroize = "1.4.3"
libp2p = "0.39.1"
libp2p = "0.40"
generic-array= "0.14"
public-ip = "0.2.2"
lazy_format = "1.10.0"
Expand All @@ -88,7 +88,7 @@ state-chain-runtime = {path = "../state-chain/runtime"}
utilities = {path = "../utilities"}

[dependencies.rocksdb]
version = "0.17.0"
version = "0.18.0"
# Disabling of default features, and using lz4 compression is primarily to avoid linker issues
# resulting from the default compression using libs that conflict with the system libs
# https://github.com/rust-rocksdb/rust-rocksdb/pull/555
Expand All @@ -97,46 +97,45 @@ features = ["lz4"]


# substrate deps
[dependencies.substrate-subxt]
tag = 'chainflip-monthly-2021-09'
git = 'https://github.com/chainflip-io/substrate-subxt.git'

[dependencies.codec]
features = ['derive', 'full']
package = 'parity-scale-codec'
version = '2.3.1'
version = '3.0.0'

[dependencies.frame-metadata]
version = "15.0.0"

[dependencies.frame-support]
git = 'https://github.com/chainflip-io/substrate.git'
tag = 'chainflip-monthly-2021-09+1'
tag = 'chainflip-monthly-2022-05'

[dependencies.frame-system]
git = 'https://github.com/chainflip-io/substrate.git'
tag = 'chainflip-monthly-2021-09+1'
tag = 'chainflip-monthly-2022-05'

[dependencies.sc-rpc-api]
git = 'https://github.com/chainflip-io/substrate.git'
tag = 'chainflip-monthly-2021-09+1'
tag = 'chainflip-monthly-2022-05'

[dependencies.sp-core]
git = 'https://github.com/chainflip-io/substrate.git'
tag = 'chainflip-monthly-2021-09+1'
tag = 'chainflip-monthly-2022-05'

[dependencies.sp-keyring]
git = 'https://github.com/chainflip-io/substrate.git'
tag = 'chainflip-monthly-2021-09+1'
tag = 'chainflip-monthly-2022-05'

[dependencies.sp-rpc]
git = 'https://github.com/chainflip-io/substrate.git'
tag = 'chainflip-monthly-2021-09+1'
tag = 'chainflip-monthly-2022-05'

[dependencies.sp-runtime]
git = 'https://github.com/chainflip-io/substrate.git'
tag = 'chainflip-monthly-2021-09+1'
tag = 'chainflip-monthly-2022-05'

[dependencies.sp-version]
git = 'https://github.com/chainflip-io/substrate.git'
tag = 'chainflip-monthly-2021-09+1'
tag = 'chainflip-monthly-2022-05'

[dependencies.curv-kzen]
version = "0.9"
Expand Down
8 changes: 4 additions & 4 deletions engine/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ slog = {version = "2.7.0", features = ["max_level_trace", "release_max_level_tra
structopt = "0.3.23"
tokio = {version = "1.13.1", features = ["full"]}
utilities = {path = "../../utilities"}
web3 = {git = 'https://github.com/tomusdrw/rust-web3.git', rev = 'a425fa7'}
web3 = {git = 'https://github.com/tomusdrw/rust-web3.git', rev = '8796c88'}

# State chain
pallet-cf-staking = {path = "../../state-chain/pallets/cf-staking"}
Expand All @@ -27,6 +27,6 @@ cf-chains = {path = "../../state-chain/chains"}
chainflip-node = {path = "../../state-chain/node"}

# Substrate key types
sp-core = {git='https://github.com/chainflip-io/substrate.git', tag='chainflip-monthly-2021-09+1'}
sp-consensus-aura = {git='https://github.com/chainflip-io/substrate.git', tag='chainflip-monthly-2021-09+1'}
sp-finality-grandpa = {git='https://github.com/chainflip-io/substrate.git', tag='chainflip-monthly-2021-09+1'}
sp-core = {git='https://github.com/chainflip-io/substrate.git', tag='chainflip-monthly-2022-05'}
sp-consensus-aura = {git='https://github.com/chainflip-io/substrate.git', tag='chainflip-monthly-2022-05'}
sp-finality-grandpa = {git='https://github.com/chainflip-io/substrate.git', tag='chainflip-monthly-2022-05'}
14 changes: 10 additions & 4 deletions engine/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ async fn request_claim(

let tx_hash = state_chain_client
.submit_signed_extrinsic(
pallet_cf_staking::Call::claim(atomic_amount, eth_address),
pallet_cf_staking::Call::claim {
amount: atomic_amount,
address: eth_address,
},
logger,
)
.await?;
Expand Down Expand Up @@ -263,7 +266,10 @@ async fn rotate_keys(settings: &CLISettings, logger: &slog::Logger) -> Result<()

let tx_hash = state_chain_client
.submit_signed_extrinsic(
pallet_cf_validator::Call::set_keys(new_session_key, [0; 1].to_vec()),
pallet_cf_validator::Call::set_keys {
keys: new_session_key,
proof: [0; 1].to_vec(),
},
logger,
)
.await
Expand All @@ -277,7 +283,7 @@ async fn retire_account(settings: &CLISettings, logger: &slog::Logger) -> Result
let (_, _, state_chain_client) =
connect_to_state_chain(&settings.state_chain, false, logger).await?;
let tx_hash = state_chain_client
.submit_signed_extrinsic(pallet_cf_staking::Call::retire_account(), logger)
.submit_signed_extrinsic(pallet_cf_staking::Call::retire_account {}, logger)
.await
.expect("Could not retire account");
println!("Account retired at tx {:#x}.", tx_hash);
Expand All @@ -288,7 +294,7 @@ async fn activate_account(settings: &CLISettings, logger: &slog::Logger) -> Resu
let (_, _, state_chain_client) =
connect_to_state_chain(&settings.state_chain, false, logger).await?;
let tx_hash = state_chain_client
.submit_signed_extrinsic(pallet_cf_staking::Call::activate_account(), logger)
.submit_signed_extrinsic(pallet_cf_staking::Call::activate_account {}, logger)
.await
.expect("Could not activate account");
println!("Account activated at tx {:#x}.", tx_hash);
Expand Down
2 changes: 1 addition & 1 deletion engine/insert-genesis-keyshare/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ chainflip-engine = {path = "../../engine/"}
hex = "0.4.3"

[dependencies.rocksdb]
version = "0.17.0"
version = "0.18.0"
# Disabling of default features, and using lz4 compression is primarily to avoid linker issues
# resulting from the default compression using libs that conflict with the system libs
# https://github.com/rust-rocksdb/rust-rocksdb/pull/555
Expand Down
46 changes: 26 additions & 20 deletions engine/src/eth/key_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,33 +205,39 @@ impl EthObserver for KeyManager {
| KeyManagerEvent::AggKeySetByGovKey { new_key, .. } => {
let _result = state_chain_client
.submit_signed_extrinsic(
pallet_cf_witnesser::Call::witness(Box::new(
pallet_cf_vaults::Call::vault_key_rotated(
cf_chains::eth::AggKey::from_pubkey_compressed(new_key.serialize()),
event.block_number,
event.tx_hash,
)
.into(),
)),
pallet_cf_witnesser::Call::witness {
call: Box::new(
pallet_cf_vaults::Call::vault_key_rotated {
new_public_key: cf_chains::eth::AggKey::from_pubkey_compressed(
new_key.serialize(),
),
block_number: event.block_number,
tx_hash: event.tx_hash,
}
.into(),
),
},
logger,
)
.await;
}
KeyManagerEvent::SignatureAccepted { sig_data, signer } => {
let _result = state_chain_client
.submit_signed_extrinsic(
pallet_cf_witnesser::Call::witness(Box::new(
pallet_cf_broadcast::Call::signature_accepted(
SchnorrVerificationComponents {
s: sig_data.sig.into(),
k_times_g_address: sig_data.k_times_g_address.into(),
},
signer,
event.block_number,
event.tx_hash,
)
.into(),
)),
pallet_cf_witnesser::Call::witness {
call: Box::new(
pallet_cf_broadcast::Call::signature_accepted {
payload: SchnorrVerificationComponents {
s: sig_data.sig.into(),
k_times_g_address: sig_data.k_times_g_address.into(),
},
tx_signer: signer,
block_number: event.block_number,
tx_hash: event.tx_hash,
}
.into(),
),
},
logger,
)
.await;
Expand Down
8 changes: 4 additions & 4 deletions engine/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use futures::{
stream::{self},
StreamExt, TryFutureExt,
};
use secp256k1::SecretKey;
use slog::o;
use sp_core::{H160, U256};
use std::{
Expand All @@ -55,6 +54,7 @@ use web3::{
},
Web3,
};
use web3_secp256k1::SecretKey;

use tokio_stream::Stream;

Expand Down Expand Up @@ -536,10 +536,10 @@ where
data: unsigned_tx.data.clone().into(),
chain_id: Some(unsigned_tx.chain_id),
value: unsigned_tx.value,
transaction_type: Some(web3::types::U64::from(2)),
transaction_type: Some(web3::types::U64::from(2u64)),
// Set the gas really high (~half gas in a block) for the estimate, since the estimation call requires you to
// input at least as much gas as the estimate will return (stupid? yes)
gas: U256::from(15_000_000),
gas: U256::from(15_000_000u64),
..Default::default()
};
// query for the gas estimate if the SC didn't provide it
Expand All @@ -554,7 +554,7 @@ where
};

// increase the estimate by 50%
let uint256_2 = U256::from(2);
let uint256_2 = U256::from(2u64);
tx_params.gas = gas_estimate
.saturating_mul(uint256_2)
.saturating_sub(gas_estimate.checked_div(uint256_2).unwrap());
Expand Down
32 changes: 16 additions & 16 deletions engine/src/eth/stake_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,36 +112,36 @@ impl EthObserver for StakeManager {
} => {
let _result = state_chain_client
.submit_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch(
Box::new(
pallet_cf_staking::Call::staked(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_staking::Call::staked {
account_id,
amount,
return_addr.0,
event.tx_hash.into(),
)
withdrawal_address: return_addr.0,
tx_hash: event.tx_hash.into(),
}
.into(),
),
epoch,
),
epoch_index: epoch,
},
logger,
)
.await;
}
StakeManagerEvent::ClaimExecuted { account_id, amount } => {
let _result = state_chain_client
.submit_signed_extrinsic(
pallet_cf_witnesser::Call::witness_at_epoch(
Box::new(
pallet_cf_staking::Call::claimed(
pallet_cf_witnesser::Call::witness_at_epoch {
call: Box::new(
pallet_cf_staking::Call::claimed {
account_id,
amount,
event.tx_hash.to_fixed_bytes(),
)
claimed_amount: amount,
tx_hash: event.tx_hash.to_fixed_bytes(),
}
.into(),
),
epoch,
),
epoch_index: epoch,
},
logger,
)
.await;
Expand Down
12 changes: 7 additions & 5 deletions engine/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ async fn main() {

state_chain_client
.submit_signed_extrinsic(
pallet_cf_validator::Call::cfe_version(SemVer {
major: env!("CARGO_PKG_VERSION_MAJOR").parse::<u8>().unwrap(),
minor: env!("CARGO_PKG_VERSION_MINOR").parse::<u8>().unwrap(),
patch: env!("CARGO_PKG_VERSION_PATCH").parse::<u8>().unwrap(),
}),
pallet_cf_validator::Call::cfe_version {
version: SemVer {
major: env!("CARGO_PKG_VERSION_MAJOR").parse::<u8>().unwrap(),
minor: env!("CARGO_PKG_VERSION_MINOR").parse::<u8>().unwrap(),
patch: env!("CARGO_PKG_VERSION_PATCH").parse::<u8>().unwrap(),
},
},
&root_logger,
)
.await
Expand Down
7 changes: 6 additions & 1 deletion engine/src/multisig/client/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ impl KeygenResult {
/// Gets the serialized compressed public key (33 bytes - 32 bytes + a y parity byte)
pub fn get_public_key_bytes(&self) -> Vec<u8> {
use crate::multisig::crypto::ECPoint;
self.key_share.y.0.serialize_compressed().as_ref().into()
self.key_share
.y
.0
.serialize_compressed()
.as_slice()
.to_vec()
}
}

Expand Down
2 changes: 1 addition & 1 deletion engine/src/multisig/client/keygen/keygen_stages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ derive_display_as_type_name!(VerifyCommitmentsBroadcast2);
/// Check if the public key's x coordinate is smaller than "half secp256k1's order",
/// which is a requirement imposed by the Key Manager contract
pub fn is_contract_compatible(pk: &secp256k1::PublicKey) -> bool {
let pubkey = cf_chains::eth::AggKey::from(pk);
let pubkey = cf_chains::eth::AggKey::from_pubkey_compressed(pk.serialize());

let x = BigInt::from_bytes(&pubkey.pub_key_x);
let half_order = BigInt::from_bytes(&secp256k1::constants::CURVE_ORDER) / 2 + 1;
Expand Down
4 changes: 2 additions & 2 deletions engine/src/multisig/client/signing/frost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ fn build_challenge(
.try_into()
.expect("Should never fail, the `message` argument should always be a valid hash");

let e =
AggKey::from(&pubkey).message_challenge(&msg_hash, &pubkey_to_eth_addr(nonce_commitment));
let e = AggKey::from_pubkey_compressed(pubkey.serialize())
.message_challenge(&msg_hash, &pubkey_to_eth_addr(nonce_commitment));

Scalar::from_bytes(&e)
}
Loading