Skip to content

Commit

Permalink
update object mapping offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhavyas committed Feb 20, 2025
1 parent b9f51e0 commit 7510936
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
16 changes: 4 additions & 12 deletions crates/subspace-runtime/src/object_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,12 @@ pub(crate) fn extract_block_object_mapping(block: Block) -> BlockObjectMapping {
let mut base_offset =
block.header.encoded_size() + Compact::compact_len(&(block.extrinsics.len() as u32));
for extrinsic in block.extrinsics {
let signature_size = extrinsic
.preamble
.clone()
.to_signed()
.map(|(_, signature, _)| signature.encoded_size())
.unwrap_or_default();
// Extrinsic starts with vector length and version byte, followed by optional signature and
let preamble_size = extrinsic.preamble.encoded_size();
// Extrinsic starts with vector length followed by preamble and
// `function` encoding.
let base_extrinsic_offset = base_offset
+ Compact::compact_len(
&((1 + signature_size + extrinsic.function.encoded_size()) as u32),
)
+ 1
+ signature_size;
+ Compact::compact_len(&((preamble_size + extrinsic.function.encoded_size()) as u32))
+ preamble_size;

extract_call_block_object_mapping(
base_extrinsic_offset as u32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ where
continue;
}

// Skip the tx if is already bundled by a recent bundle
// Skip the tx if it is already bundled by a recent bundle
if self
.previous_bundled_tx
.already_bundled(&self.transaction_pool.hash_of(pending_tx_data))
Expand Down
1 change: 1 addition & 0 deletions domains/primitives/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use sp_weights::constants::WEIGHT_REF_TIME_PER_SECOND;
use sp_weights::Weight;
pub use subspace_runtime_primitives::HoldIdentifier;
use subspace_runtime_primitives::{MAX_BLOCK_LENGTH, SHANNON};

/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = MultiSignature;

Expand Down
16 changes: 4 additions & 12 deletions test/subspace-test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,20 +1083,12 @@ fn extract_block_object_mapping(block: Block) -> BlockObjectMapping {
let mut base_offset =
block.header.encoded_size() + Compact::compact_len(&(block.extrinsics.len() as u32));
for extrinsic in block.extrinsics {
let signature_size = extrinsic
.preamble
.clone()
.to_signed()
.map(|(_, signature, _)| signature.encoded_size())
.unwrap_or_default();
// Extrinsic starts with vector length and version byte, followed by optional signature and
let preamble_size = extrinsic.preamble.encoded_size();
// Extrinsic starts with vector length followed by preamble and
// `function` encoding.
let base_extrinsic_offset = base_offset
+ Compact::compact_len(
&((1 + signature_size + extrinsic.function.encoded_size()) as u32),
)
+ 1
+ signature_size;
+ Compact::compact_len(&((preamble_size + extrinsic.function.encoded_size()) as u32))
+ preamble_size;

extract_call_block_object_mapping(
base_extrinsic_offset as u32,
Expand Down

0 comments on commit 7510936

Please sign in to comment.