Mention every account on-chain before they publish a transaction

`CheckNonce` required accounts have a provider in order to even have their
nonce considered. This shims that by claiming every account has a provider at
the start of a block, if it signs a transaction.

The actual execution could presumably diverge between block building (which
sets the provider before each transaction) and execution (which sets the
providers at the start of the block). It doesn't diverge in our current
configuration and it won't be propagated to `next` (which doesn't use
`CheckNonce`).

Also uses explicit indexes for the `serai_abi::{Call, Event}` `enum`s.
This commit is contained in:
Luke Parker
2025-09-23 18:04:46 -04:00
parent 0b377f3c4e
commit e1671dd71b
3 changed files with 45 additions and 3 deletions

View File

@@ -36,15 +36,25 @@ pub mod tx;
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
pub enum Call {
#[codec(index = 1)]
Timestamp(timestamp::Call),
#[codec(index = 3)]
Coins(coins::Call),
#[codec(index = 4)]
LiquidityTokens(liquidity_tokens::Call),
#[codec(index = 5)]
Dex(dex::Call),
#[codec(index = 6)]
ValidatorSets(validator_sets::Call),
#[codec(index = 7)]
GenesisLiquidity(genesis_liquidity::Call),
#[codec(index = 10)]
InInstructions(in_instructions::Call),
#[codec(index = 11)]
Signals(signals::Call),
#[codec(index = 12)]
Babe(babe::Call),
#[codec(index = 13)]
Grandpa(grandpa::Call),
}
@@ -60,19 +70,27 @@ pub enum TransactionPaymentEvent {
Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale::DecodeWithMemTracking,
)]
pub enum Event {
#[codec(index = 0)]
System(system::Event),
Timestamp,
#[codec(index = 2)]
TransactionPayment(TransactionPaymentEvent),
#[codec(index = 3)]
Coins(coins::Event),
#[codec(index = 4)]
LiquidityTokens(liquidity_tokens::Event),
#[codec(index = 5)]
Dex(dex::Event),
#[codec(index = 6)]
ValidatorSets(validator_sets::Event),
#[codec(index = 7)]
GenesisLiquidity(genesis_liquidity::Event),
Emissions,
#[codec(index = 9)]
EconomicSecurity(economic_security::Event),
#[codec(index = 10)]
InInstructions(in_instructions::Event),
#[codec(index = 11)]
Signals(signals::Event),
Babe,
#[codec(index = 13)]
Grandpa(grandpa::Event),
}

View File

@@ -45,6 +45,10 @@ impl<Call: 'static + TransactionMember + From<crate::Call>, Extra: 'static + Tra
pub fn call(&self) -> &crate::Call {
&self.call
}
pub fn signer(&self) -> Option<SeraiAddress> {
self.signature.as_ref().map(|(address, _sig, _extra)| *address)
}
}
impl<Call: 'static + TransactionMember + From<crate::Call>, Extra: 'static + TransactionMember>

View File

@@ -381,6 +381,14 @@ sp_api::impl_runtime_apis! {
}
fn execute_block(block: Block) {
for tx in &block.extrinsics {
if let Some(signer) = tx.signer() {
let signer = signer.0.into();
if System::providers(&signer) == 0 {
System::inc_providers(&signer);
}
}
}
Executive::execute_block(block);
}
@@ -392,6 +400,12 @@ sp_api::impl_runtime_apis! {
impl sp_block_builder::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
if let Some(signer) = extrinsic.signer() {
let signer = signer.0.into();
if System::providers(&signer) == 0 {
System::inc_providers(&signer);
}
}
Executive::apply_extrinsic(extrinsic)
}
@@ -417,6 +431,12 @@ sp_api::impl_runtime_apis! {
tx: <Block as BlockT>::Extrinsic,
block_hash: <Block as BlockT>::Hash,
) -> TransactionValidity {
if let Some(signer) = tx.signer() {
let signer = signer.0.into();
if System::providers(&signer) == 0 {
System::inc_providers(&signer);
}
}
Executive::validate_transaction(source, tx, block_hash)
}
}