Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions canister/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ pub trait Storable {

impl StableStructuresStorable for OutPoint {
fn to_bytes(&self) -> std::borrow::Cow<[u8]> {
let mut v: Vec<u8> = self.txid.clone().to_vec(); // Store the txid (32 bytes)
v.append(&mut self.vout.to_le_bytes().to_vec()); // Then the vout (4 bytes)
let v = [self.txid.0.as_slice(), self.vout.to_le_bytes().as_slice()].concat();

// An outpoint is always exactly 36 bytes.
assert_eq!(v.len(), OUTPOINT_SIZE as usize);
Expand Down Expand Up @@ -592,14 +591,11 @@ impl Default for BlockHash {
type PageNumber = u8;

#[derive(Clone, Deserialize, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize)]
pub struct Txid {
#[serde(with = "serde_bytes")]
bytes: Vec<u8>,
}
pub struct Txid([u8; 32]);

impl From<Vec<u8>> for Txid {
fn from(bytes: Vec<u8>) -> Self {
Self { bytes }
Self(bytes.try_into().unwrap())
}
}

Expand All @@ -615,11 +611,11 @@ impl FromStr for Txid {

impl Txid {
pub fn as_bytes(&self) -> &[u8] {
self.bytes.as_slice()
self.0.as_slice()
}

pub fn to_vec(self) -> Vec<u8> {
self.bytes
self.0.to_vec()
}
}

Expand All @@ -631,7 +627,7 @@ impl std::fmt::Debug for Txid {

impl std::fmt::Display for Txid {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let mut bytes = self.bytes.clone();
let mut bytes = self.0.to_vec();
bytes.reverse();
write!(f, "{}", hex::encode(bytes))
}
Expand Down
22 changes: 11 additions & 11 deletions e2e-tests/profiling/scenario-1.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Ingest Block 0: BlockIngestionStats { num_rounds: 1, ins_total: 33819, ins_remove_inputs: 1104, ins_insert_outputs: 30260, ins_txids: 792, ins_insert_utxos: 28354 }
Ingest Block 1: BlockIngestionStats { num_rounds: 2, ins_total: 6282521235, ins_remove_inputs: 2208, ins_insert_outputs: 6282514161, ins_txids: 7975432, ins_insert_utxos: 6265678068 }
Ingest Block 2: BlockIngestionStats { num_rounds: 5, ins_total: 16152823696, ins_remove_inputs: 10447725075, ins_insert_outputs: 5700397209, ins_txids: 9893319, ins_insert_utxos: 5679362597 }
Ingest Block 3: BlockIngestionStats { num_rounds: 1, ins_total: 591782, ins_remove_inputs: 1104, ins_insert_outputs: 588223, ins_txids: 792, ins_insert_utxos: 586317 }
GetBalanceRequest { address: "bcrt1qg4cvn305es3k8j69x06t9hf4v5yx4mxdaeazl8", min_confirmations: None }: Stats { ins_total: 462219, ins_apply_unstable_blocks: 9413 }
GetBalanceRequest { address: "bcrt1qxp8ercrmfxlu0s543najcj6fe6267j97tv7rgf", min_confirmations: Some(2) }: Stats { ins_total: 417370, ins_apply_unstable_blocks: 5624 }
GetUtxosRequest { address: "bcrt1qxp8ercrmfxlu0s543najcj6fe6267j97tv7rgf", filter: None }: Stats { ins_total: 198688490, ins_apply_unstable_blocks: 33858015, ins_build_utxos_vec: 164183940 }
GetUtxosRequest { address: "bcrt1qenhfslne5vdqld0djs0h0tfw225tkkzzc60exh", filter: None }: Stats { ins_total: 75672654, ins_apply_unstable_blocks: 70700023, ins_build_utxos_vec: 4335770 }
GetBalanceRequest { address: "bcrt1qenhfslne5vdqld0djs0h0tfw225tkkzzc60exh", min_confirmations: None }: Stats { ins_total: 26833873, ins_apply_unstable_blocks: 26426465 }
get_current_fee_percentiles: 40518685
get_current_fee_percentiles: 279870
Ingest Block 0: BlockIngestionStats { num_rounds: 1, ins_total: 32147, ins_remove_inputs: 1092, ins_insert_outputs: 28600, ins_txids: 296, ins_insert_utxos: 27147 }
Ingest Block 1: BlockIngestionStats { num_rounds: 2, ins_total: 6161919247, ins_remove_inputs: 2184, ins_insert_outputs: 6161912197, ins_txids: 2960000, ins_insert_utxos: 6149661536 }
Ingest Block 2: BlockIngestionStats { num_rounds: 5, ins_total: 16007697086, ins_remove_inputs: 10382435056, ins_insert_outputs: 5620560618, ins_txids: 2960000, ins_insert_utxos: 5606029325 }
Ingest Block 3: BlockIngestionStats { num_rounds: 1, ins_total: 586645, ins_remove_inputs: 1092, ins_insert_outputs: 583098, ins_txids: 296, ins_insert_utxos: 581645 }
GetBalanceRequest { address: "bcrt1qg4cvn305es3k8j69x06t9hf4v5yx4mxdaeazl8", min_confirmations: None }: Stats { ins_total: 471052, ins_apply_unstable_blocks: 8864 }
GetBalanceRequest { address: "bcrt1qxp8ercrmfxlu0s543najcj6fe6267j97tv7rgf", min_confirmations: Some(2) }: Stats { ins_total: 424919, ins_apply_unstable_blocks: 5093 }
GetUtxosRequest { address: "bcrt1qxp8ercrmfxlu0s543najcj6fe6267j97tv7rgf", filter: None }: Stats { ins_total: 183810400, ins_apply_unstable_blocks: 28519909, ins_build_utxos_vec: 154637350 }
GetUtxosRequest { address: "bcrt1qenhfslne5vdqld0djs0h0tfw225tkkzzc60exh", filter: None }: Stats { ins_total: 63497730, ins_apply_unstable_blocks: 59704081, ins_build_utxos_vec: 3149712 }
GetBalanceRequest { address: "bcrt1qenhfslne5vdqld0djs0h0tfw225tkkzzc60exh", min_confirmations: None }: Stats { ins_total: 23681525, ins_apply_unstable_blocks: 23265020 }
get_current_fee_percentiles: 37788411
get_current_fee_percentiles: 285434
12 changes: 6 additions & 6 deletions e2e-tests/profiling/scenario-2.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Ingest Block 0: BlockIngestionStats { num_rounds: 1, ins_total: 35117, ins_remove_inputs: 1104, ins_insert_outputs: 31558, ins_txids: 792, ins_insert_utxos: 29652 }
Ingest Block 1: BlockIngestionStats { num_rounds: 2, ins_total: 5043440588, ins_remove_inputs: 11041104, ins_insert_outputs: 5027705085, ins_txids: 8210716, ins_insert_utxos: 5008353938 }
Ingest Block 2: BlockIngestionStats { num_rounds: 2, ins_total: 5574207259, ins_remove_inputs: 11041104, ins_insert_outputs: 5558471756, ins_txids: 8210716, ins_insert_utxos: 5539120609 }
Ingest Block 3: BlockIngestionStats { num_rounds: 2, ins_total: 5796075388, ins_remove_inputs: 11041104, ins_insert_outputs: 5780339885, ins_txids: 8210716, ins_insert_utxos: 5760988738 }
GetBalanceRequest { address: "bcrt1qg4cvn305es3k8j69x06t9hf4v5yx4mxdaeazl8", min_confirmations: None }: Stats { ins_total: 26665265, ins_apply_unstable_blocks: 26252664 }
GetUtxosRequest { address: "bcrt1qg4cvn305es3k8j69x06t9hf4v5yx4mxdaeazl8", filter: None }: Stats { ins_total: 75304530, ins_apply_unstable_blocks: 69892044, ins_build_utxos_vec: 4801894 }
Ingest Block 0: BlockIngestionStats { num_rounds: 1, ins_total: 32765, ins_remove_inputs: 1092, ins_insert_outputs: 29218, ins_txids: 296, ins_insert_utxos: 27765 }
Ingest Block 1: BlockIngestionStats { num_rounds: 2, ins_total: 4990285803, ins_remove_inputs: 10921092, ins_insert_outputs: 4974670312, ins_txids: 2960000, ins_insert_utxos: 4960139881 }
Ingest Block 2: BlockIngestionStats { num_rounds: 2, ins_total: 5516528603, ins_remove_inputs: 10921092, ins_insert_outputs: 5500913112, ins_txids: 2960000, ins_insert_utxos: 5486382681 }
Ingest Block 3: BlockIngestionStats { num_rounds: 2, ins_total: 5737832186, ins_remove_inputs: 10921092, ins_insert_outputs: 5722216695, ins_txids: 2960000, ins_insert_utxos: 5707686264 }
GetBalanceRequest { address: "bcrt1qg4cvn305es3k8j69x06t9hf4v5yx4mxdaeazl8", min_confirmations: None }: Stats { ins_total: 23497179, ins_apply_unstable_blocks: 23081058 }
GetUtxosRequest { address: "bcrt1qg4cvn305es3k8j69x06t9hf4v5yx4mxdaeazl8", filter: None }: Stats { ins_total: 63386399, ins_apply_unstable_blocks: 59388709, ins_build_utxos_vec: 3437258 }