mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 14:11:09 +00:00
Make node-template in sync with node. (#3422)
* Make node-template in sync with node. * Update service.rs * Updated babe constants. * Added SignedExtra for CheckVersion in node-template and subkey. * Added CheckVersion SignedExtra for node. * Fixed tests. * Try fix integration test. * Attempt 2 at fixing integration test. * Update node-template/runtime/src/lib.rs
This commit is contained in:
committed by
Gavin Wood
parent
8eacdb54de
commit
0bb44f5024
@@ -51,6 +51,7 @@ type Number = <<node_primitives::Block as BlockT>::Header as HeaderT>::Number;
|
||||
impl<Number> FactoryState<Number> {
|
||||
fn build_extra(index: node_primitives::Index, phase: u64) -> node_runtime::SignedExtra {
|
||||
(
|
||||
system::CheckVersion::new(),
|
||||
system::CheckGenesis::new(),
|
||||
system::CheckEra::from(Era::mortal(256, phase)),
|
||||
system::CheckNonce::from(index),
|
||||
@@ -132,12 +133,12 @@ impl RuntimeAdapter for FactoryState<Number> {
|
||||
key: &Self::Secret,
|
||||
destination: &Self::AccountId,
|
||||
amount: &Self::Balance,
|
||||
version: u32,
|
||||
genesis_hash: &<Self::Block as BlockT>::Hash,
|
||||
prior_block_hash: &<Self::Block as BlockT>::Hash,
|
||||
) -> <Self::Block as BlockT>::Extrinsic {
|
||||
let index = self.extract_index(&sender, prior_block_hash);
|
||||
let phase = self.extract_phase(*prior_block_hash);
|
||||
|
||||
sign::<Self>(CheckedExtrinsic {
|
||||
signed: Some((sender.clone(), Self::build_extra(index, phase))),
|
||||
function: Call::Balances(
|
||||
@@ -146,7 +147,7 @@ impl RuntimeAdapter for FactoryState<Number> {
|
||||
(*amount).into()
|
||||
)
|
||||
)
|
||||
}, key, (genesis_hash.clone(), prior_block_hash.clone(), (), (), ()))
|
||||
}, key, (version, genesis_hash.clone(), prior_block_hash.clone(), (), (), ()))
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(&self) -> InherentData {
|
||||
|
||||
@@ -454,18 +454,21 @@ mod tests {
|
||||
let to = AddressPublic::from_raw(bob.public().0);
|
||||
let from = AddressPublic::from_raw(charlie.public().0);
|
||||
let genesis_hash = service.get().client().block_hash(0).unwrap().unwrap();
|
||||
let best_block_id = BlockId::number(service.get().client().info().chain.best_number);
|
||||
let version = service.get().client().runtime_version_at(&best_block_id).unwrap().spec_version;
|
||||
let signer = charlie.clone();
|
||||
|
||||
let function = Call::Balances(BalancesCall::transfer(to.into(), amount));
|
||||
|
||||
let check_version = system::CheckVersion::new();
|
||||
let check_genesis = system::CheckGenesis::new();
|
||||
let check_era = system::CheckEra::from(Era::Immortal);
|
||||
let check_nonce = system::CheckNonce::from(index);
|
||||
let check_weight = system::CheckWeight::new();
|
||||
let take_fees = balances::TakeFees::from(0);
|
||||
let extra = (check_genesis, check_era, check_nonce, check_weight, take_fees);
|
||||
let extra = (check_version, check_genesis, check_era, check_nonce, check_weight, take_fees);
|
||||
|
||||
let raw_payload = (function, extra.clone(), genesis_hash, genesis_hash);
|
||||
let raw_payload = (function, extra.clone(), version, genesis_hash, genesis_hash);
|
||||
let signature = raw_payload.using_encoded(|payload| if payload.len() > 256 {
|
||||
signer.sign(&blake2_256(payload)[..])
|
||||
} else {
|
||||
|
||||
@@ -44,7 +44,7 @@ mod tests {
|
||||
use keyring::{AccountKeyring, Ed25519Keyring, Sr25519Keyring};
|
||||
use runtime_support::{Hashable, StorageValue, StorageMap, assert_eq_error_rate, traits::Currency};
|
||||
use state_machine::{CodeExecutor, Externalities, TestExternalities as CoreTestExternalities};
|
||||
use primitives::{ twox_128, blake2_256, Blake2Hasher, ChangesTrieConfiguration, NeverNativeValue, NativeOrEncoded};
|
||||
use primitives::{twox_128, blake2_256, Blake2Hasher, ChangesTrieConfiguration, NeverNativeValue, NativeOrEncoded};
|
||||
use node_primitives::{Hash, BlockNumber, AccountId, Balance, Index};
|
||||
use sr_primitives::traits::{Header as HeaderT, Hash as HashT, Convert};
|
||||
use sr_primitives::{generic::Era, ApplyOutcome, ApplyError, ApplyResult, Perbill};
|
||||
@@ -55,7 +55,7 @@ mod tests {
|
||||
Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances, BuildStorage,
|
||||
GenesisConfig, BalancesConfig, SessionConfig, StakingConfig, System, SystemConfig,
|
||||
GrandpaConfig, IndicesConfig, ContractsConfig, Event, SessionKeys, SignedExtra,
|
||||
TransferFee, TransactionBaseFee, TransactionByteFee,
|
||||
TransferFee, TransactionBaseFee, TransactionByteFee
|
||||
};
|
||||
use node_runtime::constants::currency::*;
|
||||
use node_runtime::impls::WeightToFee;
|
||||
@@ -79,6 +79,8 @@ mod tests {
|
||||
|
||||
const GENESIS_HASH: [u8; 32] = [69u8; 32];
|
||||
|
||||
const VERSION: u32 = node_runtime::VERSION.spec_version;
|
||||
|
||||
type TestExternalities<H> = CoreTestExternalities<H, u64>;
|
||||
|
||||
/// Default transfer fee
|
||||
@@ -122,7 +124,7 @@ mod tests {
|
||||
fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic {
|
||||
match xt.signed {
|
||||
Some((signed, extra)) => {
|
||||
let payload = (xt.function, extra.clone(), GENESIS_HASH, GENESIS_HASH);
|
||||
let payload = (xt.function, extra.clone(), VERSION, GENESIS_HASH, GENESIS_HASH);
|
||||
let key = AccountKeyring::from_public(&signed).unwrap();
|
||||
let signature = payload.using_encoded(|b| {
|
||||
if b.len() > 256 {
|
||||
@@ -145,6 +147,7 @@ mod tests {
|
||||
|
||||
fn signed_extra(nonce: Index, extra_fee: Balance) -> SignedExtra {
|
||||
(
|
||||
system::CheckVersion::new(),
|
||||
system::CheckGenesis::new(),
|
||||
system::CheckEra::from(Era::mortal(256, 0)),
|
||||
system::CheckNonce::from(nonce),
|
||||
|
||||
@@ -463,6 +463,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
/// The SignedExtension to the basic transaction logic.
|
||||
pub type SignedExtra = (
|
||||
system::CheckVersion<Runtime>,
|
||||
system::CheckGenesis<Runtime>,
|
||||
system::CheckEra<Runtime>,
|
||||
system::CheckNonce<Runtime>,
|
||||
|
||||
Reference in New Issue
Block a user