Check the genesis hash in transactions regardless of era. (#3286)

* Check the genesis hash in transactions regardless of era.

* Fix check-fees, too.

* Undo.

* Subkey supports new signing.

* Remove unneeded type param.

* Bump tx version

* Build.

* Another build fix

* Build again

* Cleanup

* Another fix.

* Fix

* Fixes

* 6 second blocks.

* Fixes

* Build fix

* Fix

* Fix.
This commit is contained in:
Gavin Wood
2019-08-02 18:30:20 +02:00
committed by GitHub
parent ae6c2f7f8c
commit 7927e80bc6
16 changed files with 102 additions and 116 deletions
+19 -9
View File
@@ -92,9 +92,10 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
{
let extra = |i: Index, f: Balance| {
(
system::CheckGenesis::<Runtime>::new(),
system::CheckEra::<Runtime>::from(Era::Immortal),
system::CheckNonce::<Runtime>::from(i),
system::CheckWeight::<Runtime>::from(),
system::CheckWeight::<Runtime>::new(),
balances::TakeFees::<Runtime>::from(f),
)
};
@@ -170,7 +171,11 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
println!("Using a genesis hash of {}", HexDisplay::from(&genesis_hash.as_ref()));
let raw_payload = (function, extra(index, 0), genesis_hash);
let raw_payload = (
function,
extra(index, 0),
(&genesis_hash, &genesis_hash),
);
let signature = raw_payload.using_encoded(|payload| if payload.len() > 256 {
signer.sign(&blake2_256(payload)[..])
} else {
@@ -200,15 +205,20 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
let function: Call = hex::decode(&call).ok()
.and_then(|x| Decode::decode(&mut &x[..])).unwrap();
let h = matches.value_of("prior-block-hash")
.expect("prior-block-hash is required; thus it can't be None; qed");
let prior_block_hash: Hash = hex::decode(h).ok()
.and_then(|x| Decode::decode(&mut &x[..]))
.expect("Invalid prior block hash");
let genesis_hash: Hash = match matches.value_of("genesis").unwrap_or("alex") {
"elm" => hex!["10c08714a10c7da78f40a60f6f732cf0dba97acfb5e2035445b032386157d5c3"].into(),
"alex" => hex!["dcd1346701ca8396496e52aa2785b1748deb6db09551b72159dcb3e08991025b"].into(),
h => hex::decode(h).ok().and_then(|x| Decode::decode(&mut &x[..]))
.expect("Invalid genesis hash or unrecognised chain identifier"),
};
let era = Era::immortal();
println!("Using a genesis hash of {}", HexDisplay::from(&genesis_hash.as_ref()));
let raw_payload = (function, era, prior_block_hash, extra(index, 0));
let raw_payload = (
function,
extra(index, 0),
(&genesis_hash, &genesis_hash),
);
let signature = raw_payload.using_encoded(|payload|
if payload.len() > 256 {
signer.sign(&blake2_256(payload)[..])