Skip to content

Commit e441ebc

Browse files
committed
use a mortal era
1 parent a52b15f commit e441ebc

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

node/src/mev_shield/author.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ where
332332
use sp_runtime::{
333333
BoundedVec, MultiSignature,
334334
generic::Era,
335-
traits::{ConstU32, TransactionExtension},
335+
traits::{ConstU32, TransactionExtension, SaturatedConversion},
336336
};
337337

338338
fn to_h256<H: AsRef<[u8]>>(h: H) -> H256 {
@@ -367,13 +367,23 @@ where
367367

368368
// 2) Build the transaction extensions exactly like the runtime.
369369
type Extra = runtime::TransactionExtensions;
370+
371+
let info = client.info();
372+
let at_hash = info.best_hash;
373+
let at_hash_h256: H256 = to_h256(at_hash);
374+
let genesis_h256: H256 = to_h256(info.genesis_hash);
375+
376+
const ERA_PERIOD: u64 = 12;
377+
let current_block: u64 = info.best_number.saturated_into();
378+
let era = Era::mortal(ERA_PERIOD, current_block);
379+
370380
let extra: Extra =
371381
(
372382
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
373383
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
374384
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
375385
frame_system::CheckGenesis::<runtime::Runtime>::new(),
376-
frame_system::CheckEra::<runtime::Runtime>::from(Era::Immortal),
386+
frame_system::CheckEra::<runtime::Runtime>::from(era),
377387
node_subtensor_runtime::check_nonce::CheckNonce::<runtime::Runtime>::from(nonce).into(),
378388
frame_system::CheckWeight::<runtime::Runtime>::new(),
379389
node_subtensor_runtime::transaction_payment_wrapper::ChargeTransactionPaymentWrapper::<
@@ -391,10 +401,6 @@ where
391401
// 3) Manually construct the `Implicit` tuple that the runtime will also derive.
392402
type Implicit = <Extra as TransactionExtension<RuntimeCall>>::Implicit;
393403

394-
let info = client.info();
395-
let genesis_h256: H256 = to_h256(info.genesis_hash);
396-
let at_hash = info.best_hash;
397-
398404
// Try to get the *current* runtime version from on-chain WASM; if that fails,
399405
// fall back to the compiled runtime::VERSION.
400406
let (spec_version, tx_version) = match client.runtime_api().version(at_hash) {
@@ -418,8 +424,8 @@ where
418424
(), // CheckNonZeroSender
419425
spec_version, // dynamic or fallback spec_version
420426
tx_version, // dynamic or fallback transaction_version
421-
genesis_h256, // CheckGenesis::Implicit = Hash
422427
genesis_h256, // CheckEra::Implicit (Immortal => genesis hash)
428+
at_hash_h256, // CheckEra::Implicit = hash of the block the tx is created at
423429
(), // CheckNonce::Implicit = ()
424430
(), // CheckWeight::Implicit = ()
425431
(), // ChargeTransactionPaymentWrapper::Implicit = ()
@@ -455,12 +461,13 @@ where
455461
let opaque: sp_runtime::OpaqueExtrinsic = uxt.into();
456462
let xt: <B as sp_runtime::traits::Block>::Extrinsic = opaque.into();
457463

458-
pool.submit_one(at_hash, TransactionSource::Local, xt)
459-
.await?;
464+
pool.submit_one(at_hash, TransactionSource::Local, xt).await?;
460465

461466
log::debug!(
462467
target: "mev-shield",
463-
"announce_next_key submitted: xt=0x{xt_hash_hex}, nonce={nonce:?}, spec_version={spec_version}, tx_version={tx_version}",
468+
"announce_next_key submitted: xt=0x{xt_hash_hex}, nonce={nonce:?}, \
469+
spec_version={spec_version}, tx_version={tx_version}, era={:?}",
470+
era,
464471
);
465472

466473
Ok(())

0 commit comments

Comments
 (0)