From 3b6e795dfb9be041107a926b223ed91d2e234867 Mon Sep 17 00:00:00 2001 From: ethanoroshiba Date: Mon, 16 Sep 2024 10:37:05 -0500 Subject: [PATCH 01/10] Calculate deposit byte length based only on asset and dest. chain address --- ...ransaction_with_every_action_snapshot.snap | 60 ++++++------ ..._changes__app_finalize_block_snapshot.snap | 58 ++++++------ .../src/bridge/bridge_lock_action.rs | 92 ++++++++++++++++++- 3 files changed, 148 insertions(+), 62 deletions(-) diff --git a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap index 3e900c242..878ff33e9 100644 --- a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap +++ b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap @@ -3,36 +3,36 @@ source: crates/astria-sequencer/src/app/tests_breaking_changes.rs expression: app.app_hash.as_bytes() --- [ - 18, - 206, - 200, - 101, - 160, - 129, - 124, - 188, - 249, - 181, - 44, - 218, - 209, + 207, + 102, + 134, + 26, + 97, + 53, + 94, + 237, + 179, 251, - 208, - 119, - 122, - 211, - 105, - 201, - 75, - 214, - 56, - 145, - 239, - 132, - 48, - 0, - 79, + 54, + 164, 13, - 53, - 156 + 56, + 173, + 33, + 104, + 64, + 64, + 107, + 197, + 111, + 224, + 229, + 137, + 253, + 37, + 102, + 68, + 164, + 63, + 31 ] diff --git a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap index 2c96d3d3b..a9a815b88 100644 --- a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap +++ b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap @@ -3,36 +3,36 @@ source: crates/astria-sequencer/src/app/tests_breaking_changes.rs expression: app.app_hash.as_bytes() --- [ - 113, - 62, - 40, - 174, - 69, - 178, + 183, 27, - 49, - 166, - 136, - 209, - 163, - 103, - 135, - 254, - 99, - 63, - 197, - 35, - 165, - 202, - 177, + 46, + 79, + 164, + 56, + 185, + 245, + 116, + 191, + 28, + 164, + 108, + 167, + 140, + 198, 78, - 238, - 106, - 144, - 250, - 69, - 90, - 192, + 201, + 211, + 243, + 226, + 46, + 199, + 33, + 198, + 182, + 87, + 200, 129, - 187 + 252, + 159, + 66 ] diff --git a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs index 14c3af5e6..340df8382 100644 --- a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs +++ b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs @@ -1,4 +1,12 @@ use astria_core::{ + primitive::v1::{ + Address, + RollupId, + TransactionId, + ADDRESS_LEN, + ROLLUP_ID_LEN, + TRANSACTION_ID_LEN, + }, protocol::transaction::v1alpha1::action::{ BridgeLockAction, TransferAction, @@ -145,17 +153,36 @@ impl ActionHandler for BridgeLockAction { } } -/// returns the length of a serialized `Deposit` message. +/// Returns a modified byte length of the deposit event. Length is calculated with constants for all +/// fields except `asset` and `destination_chain_address`, ergo it may not be representative of +/// on-wire length. This should always return a byte length greater than or equal to the actual size +/// of the serialized `Deposit`, but never less. pub(crate) fn get_deposit_byte_len(deposit: &Deposit) -> u128 { use prost::Message as _; - let raw = deposit.clone().into_raw(); + let bridge_address = Address::builder() + .prefix("astria") + .slice(&[0; ADDRESS_LEN]) + .try_build() + .unwrap(); + let deposit = Deposit::new( + bridge_address, + RollupId::from_unhashed_bytes([0; ROLLUP_ID_LEN]), + u128::MAX, + deposit.asset().clone(), + deposit.destination_chain_address().to_string(), + TransactionId::new([0; TRANSACTION_ID_LEN]), + u64::MAX, + ); + let raw = deposit.into_raw(); raw.encoded_len() as u128 } #[cfg(test)] mod tests { use astria_core::primitive::v1::{ - asset, + asset::{ + self, + }, RollupId, TransactionId, }; @@ -240,4 +267,63 @@ mod tests { .unwrap(); bridge_lock.check_and_execute(&mut state).await.unwrap(); } + + #[test] + fn test_get_deposit_byte_len() { + use prost::Message as _; + + // Test for deposit length at maximum int values + let deposit = Deposit::new( + astria_address(&[1; 20]), + RollupId::from_unhashed_bytes(b"test_rollup_id"), + u128::MAX, + test_asset(), + "someaddress".to_string(), + TransactionId::new([0; 32]), + u64::MAX, + ); + let calculated_len = get_deposit_byte_len(&deposit); + let expected_len = deposit.into_raw().encoded_len() as u128; + assert_eq!(calculated_len, expected_len); + + // Test for deposit length at minimum int values + let deposit = Deposit::new( + astria_address(&[1; 20]), + RollupId::from_unhashed_bytes(b"test_rollup_id"), + 0, + test_asset(), + "someaddress".to_string(), + TransactionId::new([0; 32]), + 0, + ); + let calculated_len = get_deposit_byte_len(&deposit); + let expected_len = deposit.into_raw().encoded_len() as u128; + assert!(calculated_len >= expected_len); + + // Ensure longer asset name results in longer byte length. + let deposit = Deposit::new( + astria_address(&[1; 20]), + RollupId::from_unhashed_bytes(b"test_rollup_id"), + 0, + "test_asset".parse().unwrap(), + "someaddress".to_string(), + TransactionId::new([0; 32]), + 0, + ); + let calculated_len_2 = get_deposit_byte_len(&deposit); + assert!(calculated_len_2 >= calculated_len); + + // Ensure longer destination chain address results in longer byte length. + let deposit = Deposit::new( + astria_address(&[1; 20]), + RollupId::from_unhashed_bytes(b"test_rollup_id"), + 0, + "test_asset".parse().unwrap(), + "someaddresslonger".to_string(), + TransactionId::new([0; 32]), + 0, + ); + let calculated_len_3 = get_deposit_byte_len(&deposit); + assert!(calculated_len_3 >= calculated_len_2); + } } From df2f7015780ec7284988547c5d25a1d0efd5c729 Mon Sep 17 00:00:00 2001 From: ethanoroshiba Date: Mon, 16 Sep 2024 11:03:07 -0500 Subject: [PATCH 02/10] Fix compile? --- crates/astria-sequencer/src/bridge/bridge_lock_action.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs index 340df8382..898e82f66 100644 --- a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs +++ b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs @@ -161,7 +161,7 @@ pub(crate) fn get_deposit_byte_len(deposit: &Deposit) -> u128 { use prost::Message as _; let bridge_address = Address::builder() .prefix("astria") - .slice(&[0; ADDRESS_LEN]) + .slice(&[0u8; ADDRESS_LEN]) .try_build() .unwrap(); let deposit = Deposit::new( From b1c855b25d6ce31e2a5da4bdfdaa147ed7d71c0c Mon Sep 17 00:00:00 2001 From: ethanoroshiba Date: Mon, 16 Sep 2024 11:19:15 -0500 Subject: [PATCH 03/10] Fix slice issue for rust 1.76 --- crates/astria-sequencer/src/bridge/bridge_lock_action.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs index 898e82f66..45b836fdb 100644 --- a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs +++ b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs @@ -161,7 +161,7 @@ pub(crate) fn get_deposit_byte_len(deposit: &Deposit) -> u128 { use prost::Message as _; let bridge_address = Address::builder() .prefix("astria") - .slice(&[0u8; ADDRESS_LEN]) + .slice(&[0u8; ADDRESS_LEN][..]) .try_build() .unwrap(); let deposit = Deposit::new( From 9c7090b6dce175eb1df080ee286ef8b412d0b2ee Mon Sep 17 00:00:00 2001 From: ethanoroshiba Date: Wed, 18 Sep 2024 09:31:36 -0500 Subject: [PATCH 04/10] requested changes --- ...ransaction_with_every_action_snapshot.snap | 56 +++++------ ..._changes__app_finalize_block_snapshot.snap | 60 ++++++------ .../src/bridge/bridge_lock_action.rs | 95 +++++++++++++------ 3 files changed, 123 insertions(+), 88 deletions(-) diff --git a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap index 878ff33e9..77ed03faa 100644 --- a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap +++ b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap @@ -3,36 +3,36 @@ source: crates/astria-sequencer/src/app/tests_breaking_changes.rs expression: app.app_hash.as_bytes() --- [ - 207, - 102, - 134, - 26, - 97, - 53, - 94, - 237, - 179, - 251, - 54, - 164, - 13, - 56, + 199, 173, - 33, - 104, - 64, - 64, 107, - 197, - 111, + 0, + 72, + 51, + 39, + 125, 224, - 229, - 137, + 175, + 189, + 197, + 244, + 143, + 20, + 119, 253, - 37, - 102, - 68, - 164, - 63, - 31 + 18, + 135, + 213, + 109, + 84, + 134, + 160, + 15, + 87, + 25, + 170, + 0, + 142, + 120, + 137 ] diff --git a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap index a9a815b88..d8c6e433f 100644 --- a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap +++ b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap @@ -3,36 +3,36 @@ source: crates/astria-sequencer/src/app/tests_breaking_changes.rs expression: app.app_hash.as_bytes() --- [ - 183, - 27, - 46, - 79, - 164, - 56, - 185, - 245, - 116, - 191, - 28, - 164, - 108, - 167, - 140, - 198, + 115, + 98, + 31, + 196, + 100, 78, - 201, - 211, + 178, + 212, 243, - 226, - 46, - 199, - 33, - 198, - 182, - 87, - 200, - 129, - 252, - 159, - 66 + 78, + 17, + 133, + 149, + 40, + 14, + 254, + 172, + 247, + 251, + 69, + 128, + 233, + 195, + 57, + 138, + 69, + 137, + 3, + 72, + 201, + 234, + 185 ] diff --git a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs index 45b836fdb..bd41c7741 100644 --- a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs +++ b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs @@ -1,12 +1,4 @@ use astria_core::{ - primitive::v1::{ - Address, - RollupId, - TransactionId, - ADDRESS_LEN, - ROLLUP_ID_LEN, - TRANSACTION_ID_LEN, - }, protocol::transaction::v1alpha1::action::{ BridgeLockAction, TransferAction, @@ -153,28 +145,24 @@ impl ActionHandler for BridgeLockAction { } } -/// Returns a modified byte length of the deposit event. Length is calculated with constants for all -/// fields except `asset` and `destination_chain_address`, ergo it may not be representative of -/// on-wire length. This should always return a byte length greater than or equal to the actual size -/// of the serialized `Deposit`, but never less. +/// Returns a modified byte length of the deposit event. Length is calculated with maximum possible +/// constants for all fields except `asset` and `destination_chain_address`, ergo it may not be +/// representative of on-wire length. This should always return a byte length greater than or equal +/// to the actual size of the serialized `Deposit`, but never less. pub(crate) fn get_deposit_byte_len(deposit: &Deposit) -> u128 { - use prost::Message as _; - let bridge_address = Address::builder() - .prefix("astria") - .slice(&[0u8; ADDRESS_LEN][..]) - .try_build() - .unwrap(); - let deposit = Deposit::new( - bridge_address, - RollupId::from_unhashed_bytes([0; ROLLUP_ID_LEN]), - u128::MAX, - deposit.asset().clone(), - deposit.destination_chain_address().to_string(), - TransactionId::new([0; TRANSACTION_ID_LEN]), - u64::MAX, - ); - let raw = deposit.into_raw(); - raw.encoded_len() as u128 + // This is the base byte length of a deposit, as determined by the unit test + // `get_base_deposit_byte_length()` below. + let base_deposit_byte_length: u128 = 265; + + let variable_length = deposit + .asset() + .to_string() + .len() + .checked_add(deposit.destination_chain_address().len()) + .expect("deposit byte length overflowed usize") as u128; + base_deposit_byte_length + .checked_add(variable_length) + .expect("deposit byte length overflowed u128") } #[cfg(test)] @@ -183,8 +171,12 @@ mod tests { asset::{ self, }, + Address, RollupId, TransactionId, + ADDRESS_LEN, + ROLLUP_ID_LEN, + TRANSACTION_ID_LEN, }; use cnidarium::StateDelta; @@ -268,6 +260,7 @@ mod tests { bridge_lock.check_and_execute(&mut state).await.unwrap(); } + // Test that `get_deposit_byte_len()` returns a byte length greater than or equal to actual size #[test] fn test_get_deposit_byte_len() { use prost::Message as _; @@ -284,7 +277,7 @@ mod tests { ); let calculated_len = get_deposit_byte_len(&deposit); let expected_len = deposit.into_raw().encoded_len() as u128; - assert_eq!(calculated_len, expected_len); + assert!(calculated_len >= expected_len); // Test for deposit length at minimum int values let deposit = Deposit::new( @@ -325,5 +318,47 @@ mod tests { ); let calculated_len_3 = get_deposit_byte_len(&deposit); assert!(calculated_len_3 >= calculated_len_2); + + // Ensure calculated length is still greater than or equal to actual with absurd string + // lengths (have tested up to 99999999, but this makes testing very slow) + let absurd_string: String = ['a'; u16::MAX as usize].iter().collect(); + let deposit = Deposit::new( + astria_address(&[1; 20]), + RollupId::from_unhashed_bytes(b"test_rollup_id"), + u128::MAX, + absurd_string.parse().unwrap(), + absurd_string, + TransactionId::new([0; 32]), + u64::MAX, + ); + let calculated_len = get_deposit_byte_len(&deposit); + let expected_len = deposit.into_raw().encoded_len() as u128; + assert!(calculated_len >= expected_len); + } + + /// Used to determine the base deposit byte length for `get_deposit_byte_len()`. This is based + /// on usage of the longest allowed values for `bridge_address`, `amount`, and + /// `source_action_index`. `asset` and `destination_chain_address` are empty strings, whose + /// length will be added to the base cost at the time of calculation. + #[test] + #[ignore] + fn get_base_deposit_byte_length() { + use prost::Message as _; + let prefix: String = ['0'; 83].iter().collect(); + let bridge_address = Address::builder() + .prefix(prefix) + .slice(&[0u8; ADDRESS_LEN][..]) + .try_build() + .unwrap(); + let raw_deposit = astria_core::generated::sequencerblock::v1alpha1::Deposit { + bridge_address: Some(bridge_address.to_raw()), + rollup_id: Some(RollupId::from_unhashed_bytes([0; ROLLUP_ID_LEN]).to_raw()), + amount: Some(u128::MAX.into()), + asset: String::new(), + destination_chain_address: String::new(), + source_transaction_id: Some(TransactionId::new([0; TRANSACTION_ID_LEN]).to_raw()), + source_action_index: u64::MAX, + }; + println!("Deposit byte length: {}", raw_deposit.encoded_len()); } } From 00da52a715a5abe7d12605e248c8be3397ab2441 Mon Sep 17 00:00:00 2001 From: ethanoroshiba Date: Wed, 18 Sep 2024 12:26:54 -0500 Subject: [PATCH 05/10] Changes from offline discussion --- ...ransaction_with_every_action_snapshot.snap | 58 +++++++------- ..._changes__app_finalize_block_snapshot.snap | 60 +++++++-------- .../src/bridge/bridge_lock_action.rs | 77 +++++++++++-------- ...sts__get_deposit_byte_length_snapshot.snap | 5 ++ 4 files changed, 108 insertions(+), 92 deletions(-) create mode 100644 crates/astria-sequencer/src/bridge/snapshots/astria_sequencer__bridge__bridge_lock_action__tests__get_deposit_byte_length_snapshot.snap diff --git a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap index 77ed03faa..8828a39ad 100644 --- a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap +++ b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_execute_transaction_with_every_action_snapshot.snap @@ -3,36 +3,36 @@ source: crates/astria-sequencer/src/app/tests_breaking_changes.rs expression: app.app_hash.as_bytes() --- [ + 223, + 34, + 80, + 101, + 209, + 214, + 82, + 86, + 3, + 65, + 117, + 84, + 67, + 250, + 90, + 90, + 232, 199, - 173, - 107, - 0, - 72, - 51, 39, - 125, - 224, - 175, - 189, + 173, + 9, + 58, + 116, 197, - 244, - 143, - 20, - 119, - 253, - 18, - 135, - 213, - 109, - 84, - 134, - 160, - 15, - 87, - 25, - 170, - 0, - 142, - 120, - 137 + 172, + 132, + 63, + 121, + 66, + 17, + 108, + 196 ] diff --git a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap index d8c6e433f..5a4d1cb39 100644 --- a/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap +++ b/crates/astria-sequencer/src/app/snapshots/astria_sequencer__app__tests_breaking_changes__app_finalize_block_snapshot.snap @@ -3,36 +3,36 @@ source: crates/astria-sequencer/src/app/tests_breaking_changes.rs expression: app.app_hash.as_bytes() --- [ - 115, - 98, - 31, - 196, + 111, + 25, + 76, + 238, + 112, + 77, + 102, + 234, + 8, + 97, + 24, 100, - 78, - 178, - 212, - 243, - 78, - 17, - 133, - 149, - 40, - 14, - 254, - 172, - 247, - 251, - 69, + 73, 128, - 233, - 195, - 57, - 138, - 69, - 137, - 3, - 72, - 201, - 234, - 185 + 228, + 106, + 82, + 255, + 119, + 93, + 248, + 224, + 51, + 239, + 115, + 58, + 9, + 149, + 86, + 23, + 248, + 114 ] diff --git a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs index bd41c7741..e42e331d2 100644 --- a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs +++ b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs @@ -34,6 +34,10 @@ use crate::{ utils::create_deposit_event, }; +// The base byte length of a deposit, as determined by the unit test +// `get_base_deposit_byte_length()` below. +const DEPOSIT_BASE_BYTE_LENGTH: u128 = 16; + #[async_trait::async_trait] impl ActionHandler for BridgeLockAction { async fn check_stateless(&self) -> Result<()> { @@ -145,22 +149,17 @@ impl ActionHandler for BridgeLockAction { } } -/// Returns a modified byte length of the deposit event. Length is calculated with maximum possible -/// constants for all fields except `asset` and `destination_chain_address`, ergo it may not be -/// representative of on-wire length. This should always return a byte length greater than or equal -/// to the actual size of the serialized `Deposit`, but never less. +/// Returns a modified byte length of the deposit event. Length is calculated with reasonable values +/// for all fields except `asset` and `destination_chain_address`, ergo it may not be representative +/// of on-wire length. pub(crate) fn get_deposit_byte_len(deposit: &Deposit) -> u128 { - // This is the base byte length of a deposit, as determined by the unit test - // `get_base_deposit_byte_length()` below. - let base_deposit_byte_length: u128 = 265; - let variable_length = deposit .asset() .to_string() .len() .checked_add(deposit.destination_chain_address().len()) .expect("deposit byte length overflowed usize") as u128; - base_deposit_byte_length + DEPOSIT_BASE_BYTE_LENGTH .checked_add(variable_length) .expect("deposit byte length overflowed u128") } @@ -179,6 +178,7 @@ mod tests { TRANSACTION_ID_LEN, }; use cnidarium::StateDelta; + use insta::assert_json_snapshot; use super::*; use crate::{ @@ -236,7 +236,7 @@ mod tests { // not enough balance; should fail state - .put_account_balance(from_address, &asset, 100 + transfer_fee) + .put_account_balance(from_address, &asset, transfer_fee) .unwrap(); assert_eyre_error( &bridge_lock.check_and_execute(&mut state).await.unwrap_err(), @@ -260,12 +260,9 @@ mod tests { bridge_lock.check_and_execute(&mut state).await.unwrap(); } - // Test that `get_deposit_byte_len()` returns a byte length greater than or equal to actual size #[test] fn test_get_deposit_byte_len() { - use prost::Message as _; - - // Test for deposit length at maximum int values + // Test for length equality with drastically different int values let deposit = Deposit::new( astria_address(&[1; 20]), RollupId::from_unhashed_bytes(b"test_rollup_id"), @@ -275,11 +272,8 @@ mod tests { TransactionId::new([0; 32]), u64::MAX, ); - let calculated_len = get_deposit_byte_len(&deposit); - let expected_len = deposit.into_raw().encoded_len() as u128; - assert!(calculated_len >= expected_len); + let calculated_len_0 = get_deposit_byte_len(&deposit); - // Test for deposit length at minimum int values let deposit = Deposit::new( astria_address(&[1; 20]), RollupId::from_unhashed_bytes(b"test_rollup_id"), @@ -289,9 +283,8 @@ mod tests { TransactionId::new([0; 32]), 0, ); - let calculated_len = get_deposit_byte_len(&deposit); - let expected_len = deposit.into_raw().encoded_len() as u128; - assert!(calculated_len >= expected_len); + let calculated_len_1 = get_deposit_byte_len(&deposit); + assert_eq!(calculated_len_0, calculated_len_1); // Ensure longer asset name results in longer byte length. let deposit = Deposit::new( @@ -304,7 +297,7 @@ mod tests { 0, ); let calculated_len_2 = get_deposit_byte_len(&deposit); - assert!(calculated_len_2 >= calculated_len); + assert!(calculated_len_2 >= calculated_len_1); // Ensure longer destination chain address results in longer byte length. let deposit = Deposit::new( @@ -319,7 +312,7 @@ mod tests { let calculated_len_3 = get_deposit_byte_len(&deposit); assert!(calculated_len_3 >= calculated_len_2); - // Ensure calculated length is still greater than or equal to actual with absurd string + // Ensure calculated length is as expected with absurd string // lengths (have tested up to 99999999, but this makes testing very slow) let absurd_string: String = ['a'; u16::MAX as usize].iter().collect(); let deposit = Deposit::new( @@ -327,37 +320,55 @@ mod tests { RollupId::from_unhashed_bytes(b"test_rollup_id"), u128::MAX, absurd_string.parse().unwrap(), - absurd_string, + absurd_string.clone(), TransactionId::new([0; 32]), u64::MAX, ); let calculated_len = get_deposit_byte_len(&deposit); - let expected_len = deposit.into_raw().encoded_len() as u128; - assert!(calculated_len >= expected_len); + let expected_len = 16 + u128::from(u16::MAX) * 2; + assert_eq!(calculated_len, expected_len); + } + + #[test] + fn get_deposit_byte_length_snapshot() { + let deposit = Deposit::new( + astria_address(&[1; 20]), + RollupId::from_unhashed_bytes(b"test_rollup_id"), + u128::MAX, + test_asset(), + "someaddress".to_string(), + TransactionId::new([0; 32]), + u64::MAX, + ); + assert_json_snapshot!(get_deposit_byte_len(&deposit)); } /// Used to determine the base deposit byte length for `get_deposit_byte_len()`. This is based - /// on usage of the longest allowed values for `bridge_address`, `amount`, and - /// `source_action_index`. `asset` and `destination_chain_address` are empty strings, whose - /// length will be added to the base cost at the time of calculation. + /// on "reasonable" values for all fields except `asset` and `destination_chain_address`. These + /// are empty strings, whose length will be added to the base cost at the time of + /// calculation. + /// + /// This test determines 165 bytes for an average deposit with empty `asset` and + /// `destination_chain_address`, which is divided by 10 to get our base byte length of 16. This + /// is to allow for more flexibility in overall fees (we have more flexibility multiplying by a + /// lower number, and if we want fees to be higher we can just raise the multiplier). #[test] #[ignore] fn get_base_deposit_byte_length() { use prost::Message as _; - let prefix: String = ['0'; 83].iter().collect(); let bridge_address = Address::builder() - .prefix(prefix) + .prefix("astria-bridge") .slice(&[0u8; ADDRESS_LEN][..]) .try_build() .unwrap(); let raw_deposit = astria_core::generated::sequencerblock::v1alpha1::Deposit { bridge_address: Some(bridge_address.to_raw()), rollup_id: Some(RollupId::from_unhashed_bytes([0; ROLLUP_ID_LEN]).to_raw()), - amount: Some(u128::MAX.into()), + amount: Some(1000.into()), asset: String::new(), destination_chain_address: String::new(), source_transaction_id: Some(TransactionId::new([0; TRANSACTION_ID_LEN]).to_raw()), - source_action_index: u64::MAX, + source_action_index: 0, }; println!("Deposit byte length: {}", raw_deposit.encoded_len()); } diff --git a/crates/astria-sequencer/src/bridge/snapshots/astria_sequencer__bridge__bridge_lock_action__tests__get_deposit_byte_length_snapshot.snap b/crates/astria-sequencer/src/bridge/snapshots/astria_sequencer__bridge__bridge_lock_action__tests__get_deposit_byte_length_snapshot.snap new file mode 100644 index 000000000..f01ec5cbc --- /dev/null +++ b/crates/astria-sequencer/src/bridge/snapshots/astria_sequencer__bridge__bridge_lock_action__tests__get_deposit_byte_length_snapshot.snap @@ -0,0 +1,5 @@ +--- +source: crates/astria-sequencer/src/bridge/bridge_lock_action.rs +expression: get_deposit_byte_len(&deposit) +--- +31 From 10d1007a5acc4c25c3be60d3c596da43be446a9c Mon Sep 17 00:00:00 2001 From: ethanoroshiba Date: Thu, 19 Sep 2024 15:31:50 -0500 Subject: [PATCH 06/10] Requested changes --- .../src/app/tests_block_fees.rs | 4 +- .../src/app/tests_execute_transaction.rs | 2 +- .../src/bridge/bridge_lock_action.rs | 55 ++++++++----------- crates/astria-sequencer/src/bridge/mod.rs | 2 +- .../src/transaction/checks.rs | 3 +- 5 files changed, 28 insertions(+), 38 deletions(-) diff --git a/crates/astria-sequencer/src/app/tests_block_fees.rs b/crates/astria-sequencer/src/app/tests_block_fees.rs index 29c2292c0..94e1554f1 100644 --- a/crates/astria-sequencer/src/app/tests_block_fees.rs +++ b/crates/astria-sequencer/src/app/tests_block_fees.rs @@ -31,7 +31,7 @@ use crate::{ }, assets::StateReadExt as _, bridge::{ - get_deposit_byte_len, + calculate_base_deposit_fee, StateWriteExt as _, }, sequence::{ @@ -281,7 +281,7 @@ async fn ensure_correct_block_fees_bridge_lock() { .map(|(_, fee)| fee) .sum(); let expected_fees = transfer_base_fee - + (get_deposit_byte_len(&test_deposit) * bridge_lock_byte_cost_multiplier); + + (calculate_base_deposit_fee(&test_deposit).unwrap() * bridge_lock_byte_cost_multiplier); assert_eq!(total_block_fees, expected_fees); } diff --git a/crates/astria-sequencer/src/app/tests_execute_transaction.rs b/crates/astria-sequencer/src/app/tests_execute_transaction.rs index 0be551232..8c700a2c9 100644 --- a/crates/astria-sequencer/src/app/tests_execute_transaction.rs +++ b/crates/astria-sequencer/src/app/tests_execute_transaction.rs @@ -756,7 +756,7 @@ async fn app_execute_transaction_bridge_lock_action_ok() { .get_bridge_lock_byte_cost_multiplier() .await .unwrap() - * crate::bridge::get_deposit_byte_len(&expected_deposit); + * crate::bridge::calculate_base_deposit_fee(&expected_deposit).unwrap(); assert_eq!( app.state .get_account_balance(alice_address, nria()) diff --git a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs index e42e331d2..df77b7f22 100644 --- a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs +++ b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs @@ -36,7 +36,7 @@ use crate::{ // The base byte length of a deposit, as determined by the unit test // `get_base_deposit_byte_length()` below. -const DEPOSIT_BASE_BYTE_LENGTH: u128 = 16; +const DEPOSIT_BASE_FEE: u128 = 16; #[async_trait::async_trait] impl ActionHandler for BridgeLockAction { @@ -103,7 +103,10 @@ impl ActionHandler for BridgeLockAction { .await .wrap_err("failed to get byte cost multiplier")?; let fee = byte_cost_multiplier - .saturating_mul(get_deposit_byte_len(&deposit)) + .saturating_mul( + calculate_base_deposit_fee(&deposit) + .expect("deposit fee calculation should not fail"), + ) .saturating_add(transfer_fee); ensure!(from_balance >= fee, "insufficient funds for fee payment"); @@ -130,7 +133,9 @@ impl ActionHandler for BridgeLockAction { .get_bridge_lock_byte_cost_multiplier() .await .wrap_err("failed to get byte cost multiplier")?; - let fee = byte_cost_multiplier.saturating_mul(get_deposit_byte_len(&deposit)); + let fee = byte_cost_multiplier.saturating_mul( + calculate_base_deposit_fee(&deposit).expect("deposit fee calculation should not fail"), + ); state .get_and_increase_block_fees(&self.fee_asset, fee, Self::full_name()) .await @@ -152,16 +157,14 @@ impl ActionHandler for BridgeLockAction { /// Returns a modified byte length of the deposit event. Length is calculated with reasonable values /// for all fields except `asset` and `destination_chain_address`, ergo it may not be representative /// of on-wire length. -pub(crate) fn get_deposit_byte_len(deposit: &Deposit) -> u128 { +pub(crate) fn calculate_base_deposit_fee(deposit: &Deposit) -> Option { let variable_length = deposit .asset() .to_string() .len() .checked_add(deposit.destination_chain_address().len()) .expect("deposit byte length overflowed usize") as u128; - DEPOSIT_BASE_BYTE_LENGTH - .checked_add(variable_length) - .expect("deposit byte length overflowed u128") + DEPOSIT_BASE_FEE.checked_add(variable_length) } #[cfg(test)] @@ -178,7 +181,6 @@ mod tests { TRANSACTION_ID_LEN, }; use cnidarium::StateDelta; - use insta::assert_json_snapshot; use super::*; use crate::{ @@ -245,7 +247,7 @@ mod tests { // enough balance; should pass let expected_deposit_fee = transfer_fee - + get_deposit_byte_len(&Deposit::new( + + calculate_base_deposit_fee(&Deposit::new( bridge_address, rollup_id, 100, @@ -253,7 +255,9 @@ mod tests { "someaddress".to_string(), transaction_id, 0, - )) * 2; + )) + .unwrap() + * 2; state .put_account_balance(from_address, &asset, 100 + expected_deposit_fee) .unwrap(); @@ -261,7 +265,7 @@ mod tests { } #[test] - fn test_get_deposit_byte_len() { + fn test_calculate_base_deposit_fee() { // Test for length equality with drastically different int values let deposit = Deposit::new( astria_address(&[1; 20]), @@ -272,7 +276,7 @@ mod tests { TransactionId::new([0; 32]), u64::MAX, ); - let calculated_len_0 = get_deposit_byte_len(&deposit); + let calculated_len_0 = calculate_base_deposit_fee(&deposit).unwrap(); let deposit = Deposit::new( astria_address(&[1; 20]), @@ -283,7 +287,7 @@ mod tests { TransactionId::new([0; 32]), 0, ); - let calculated_len_1 = get_deposit_byte_len(&deposit); + let calculated_len_1 = calculate_base_deposit_fee(&deposit).unwrap(); assert_eq!(calculated_len_0, calculated_len_1); // Ensure longer asset name results in longer byte length. @@ -296,7 +300,7 @@ mod tests { TransactionId::new([0; 32]), 0, ); - let calculated_len_2 = get_deposit_byte_len(&deposit); + let calculated_len_2 = calculate_base_deposit_fee(&deposit).unwrap(); assert!(calculated_len_2 >= calculated_len_1); // Ensure longer destination chain address results in longer byte length. @@ -309,7 +313,7 @@ mod tests { TransactionId::new([0; 32]), 0, ); - let calculated_len_3 = get_deposit_byte_len(&deposit); + let calculated_len_3 = calculate_base_deposit_fee(&deposit).unwrap(); assert!(calculated_len_3 >= calculated_len_2); // Ensure calculated length is as expected with absurd string @@ -324,25 +328,11 @@ mod tests { TransactionId::new([0; 32]), u64::MAX, ); - let calculated_len = get_deposit_byte_len(&deposit); + let calculated_len = calculate_base_deposit_fee(&deposit).unwrap(); let expected_len = 16 + u128::from(u16::MAX) * 2; assert_eq!(calculated_len, expected_len); } - #[test] - fn get_deposit_byte_length_snapshot() { - let deposit = Deposit::new( - astria_address(&[1; 20]), - RollupId::from_unhashed_bytes(b"test_rollup_id"), - u128::MAX, - test_asset(), - "someaddress".to_string(), - TransactionId::new([0; 32]), - u64::MAX, - ); - assert_json_snapshot!(get_deposit_byte_len(&deposit)); - } - /// Used to determine the base deposit byte length for `get_deposit_byte_len()`. This is based /// on "reasonable" values for all fields except `asset` and `destination_chain_address`. These /// are empty strings, whose length will be added to the base cost at the time of @@ -353,8 +343,7 @@ mod tests { /// is to allow for more flexibility in overall fees (we have more flexibility multiplying by a /// lower number, and if we want fees to be higher we can just raise the multiplier). #[test] - #[ignore] - fn get_base_deposit_byte_length() { + fn get_base_deposit_fee() { use prost::Message as _; let bridge_address = Address::builder() .prefix("astria-bridge") @@ -370,6 +359,6 @@ mod tests { source_transaction_id: Some(TransactionId::new([0; TRANSACTION_ID_LEN]).to_raw()), source_action_index: 0, }; - println!("Deposit byte length: {}", raw_deposit.encoded_len()); + assert_eq!(DEPOSIT_BASE_FEE, raw_deposit.encoded_len() as u128 / 10); } } diff --git a/crates/astria-sequencer/src/bridge/mod.rs b/crates/astria-sequencer/src/bridge/mod.rs index f322762bc..98a9dab3d 100644 --- a/crates/astria-sequencer/src/bridge/mod.rs +++ b/crates/astria-sequencer/src/bridge/mod.rs @@ -6,7 +6,7 @@ pub(crate) mod init_bridge_account_action; pub(crate) mod query; mod state_ext; -pub(crate) use bridge_lock_action::get_deposit_byte_len; +pub(crate) use bridge_lock_action::calculate_base_deposit_fee; pub(crate) use state_ext::{ StateReadExt, StateWriteExt, diff --git a/crates/astria-sequencer/src/transaction/checks.rs b/crates/astria-sequencer/src/transaction/checks.rs index 8eac5f520..94dd81f1b 100644 --- a/crates/astria-sequencer/src/transaction/checks.rs +++ b/crates/astria-sequencer/src/transaction/checks.rs @@ -275,7 +275,7 @@ fn bridge_lock_update_fees( use astria_core::sequencerblock::v1alpha1::block::Deposit; let expected_deposit_fee = transfer_fee.saturating_add( - crate::bridge::get_deposit_byte_len(&Deposit::new( + crate::bridge::calculate_base_deposit_fee(&Deposit::new( act.to, // rollup ID doesn't matter here, as this is only used as a size-check RollupId::from_unhashed_bytes([0; 32]), @@ -285,6 +285,7 @@ fn bridge_lock_update_fees( TransactionId::new([0; 32]), tx_index_of_action, )) + .unwrap() .saturating_mul(bridge_lock_byte_cost_multiplier), ); From c9e3cdfdd2c5bb691e6bf85624d247670235a324 Mon Sep 17 00:00:00 2001 From: ethanoroshiba Date: Thu, 19 Sep 2024 15:41:28 -0500 Subject: [PATCH 07/10] Fix changes from merge --- .../src/bridge/bridge_lock_action.rs | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs index 460b84eb9..fda22f680 100644 --- a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs +++ b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs @@ -159,10 +159,10 @@ impl ActionHandler for BridgeLockAction { /// of on-wire length. pub(crate) fn calculate_base_deposit_fee(deposit: &Deposit) -> Option { let variable_length = deposit - .asset() + .asset .to_string() .len() - .checked_add(deposit.destination_chain_address().len()) + .checked_add(deposit.destination_chain_address.len()) .expect("deposit byte length overflowed usize") as u128; DEPOSIT_BASE_FEE.checked_add(variable_length) } @@ -267,67 +267,67 @@ mod tests { #[test] fn test_calculate_base_deposit_fee() { // Test for length equality with drastically different int values - let deposit = Deposit::new( - astria_address(&[1; 20]), - RollupId::from_unhashed_bytes(b"test_rollup_id"), - u128::MAX, - test_asset(), - "someaddress".to_string(), - TransactionId::new([0; 32]), - u64::MAX, - ); + let deposit = Deposit { + bridge_address: astria_address(&[1; 20]), + rollup_id: RollupId::from_unhashed_bytes(b"test_rollup_id"), + amount: u128::MAX, + asset: test_asset(), + destination_chain_address: "someaddress".to_string(), + source_transaction_id: TransactionId::new([0; 32]), + source_action_index: u64::MAX, + }; let calculated_len_0 = calculate_base_deposit_fee(&deposit).unwrap(); - let deposit = Deposit::new( - astria_address(&[1; 20]), - RollupId::from_unhashed_bytes(b"test_rollup_id"), - 0, - test_asset(), - "someaddress".to_string(), - TransactionId::new([0; 32]), - 0, - ); + let deposit = Deposit { + bridge_address: astria_address(&[1; 20]), + rollup_id: RollupId::from_unhashed_bytes(b"test_rollup_id"), + amount: 0, + asset: test_asset(), + destination_chain_address: "someaddress".to_string(), + source_transaction_id: TransactionId::new([0; 32]), + source_action_index: 0, + }; let calculated_len_1 = calculate_base_deposit_fee(&deposit).unwrap(); assert_eq!(calculated_len_0, calculated_len_1); // Ensure longer asset name results in longer byte length. - let deposit = Deposit::new( - astria_address(&[1; 20]), - RollupId::from_unhashed_bytes(b"test_rollup_id"), - 0, - "test_asset".parse().unwrap(), - "someaddress".to_string(), - TransactionId::new([0; 32]), - 0, - ); + let deposit = Deposit { + bridge_address: astria_address(&[1; 20]), + rollup_id: RollupId::from_unhashed_bytes(b"test_rollup_id"), + amount: 0, + asset: "test_asset".parse().unwrap(), + destination_chain_address: "someaddress".to_string(), + source_transaction_id: TransactionId::new([0; 32]), + source_action_index: 0, + }; let calculated_len_2 = calculate_base_deposit_fee(&deposit).unwrap(); assert!(calculated_len_2 >= calculated_len_1); // Ensure longer destination chain address results in longer byte length. - let deposit = Deposit::new( - astria_address(&[1; 20]), - RollupId::from_unhashed_bytes(b"test_rollup_id"), - 0, - "test_asset".parse().unwrap(), - "someaddresslonger".to_string(), - TransactionId::new([0; 32]), - 0, - ); + let deposit = Deposit { + bridge_address: astria_address(&[1; 20]), + rollup_id: RollupId::from_unhashed_bytes(b"test_rollup_id"), + amount: 0, + asset: "test_asset".parse().unwrap(), + destination_chain_address: "someaddresslonger".to_string(), + source_transaction_id: TransactionId::new([0; 32]), + source_action_index: 0, + }; let calculated_len_3 = calculate_base_deposit_fee(&deposit).unwrap(); assert!(calculated_len_3 >= calculated_len_2); // Ensure calculated length is as expected with absurd string // lengths (have tested up to 99999999, but this makes testing very slow) let absurd_string: String = ['a'; u16::MAX as usize].iter().collect(); - let deposit = Deposit::new( - astria_address(&[1; 20]), - RollupId::from_unhashed_bytes(b"test_rollup_id"), - u128::MAX, - absurd_string.parse().unwrap(), - absurd_string.clone(), - TransactionId::new([0; 32]), - u64::MAX, - ); + let deposit = Deposit { + bridge_address: astria_address(&[1; 20]), + rollup_id: RollupId::from_unhashed_bytes(b"test_rollup_id"), + amount: 0, + asset: absurd_string.parse().unwrap(), + destination_chain_address: absurd_string.to_string(), + source_transaction_id: TransactionId::new([0; 32]), + source_action_index: 0, + }; let calculated_len = calculate_base_deposit_fee(&deposit).unwrap(); let expected_len = 16 + u128::from(u16::MAX) * 2; assert_eq!(calculated_len, expected_len); From c46fa8a6fc4f5015da01712285ae1b1e6bfa00cb Mon Sep 17 00:00:00 2001 From: ethanoroshiba Date: Fri, 20 Sep 2024 11:12:45 -0500 Subject: [PATCH 08/10] Requested changes --- .../src/primitive/v1/asset/denom.rs | 32 +++++++++++++++++++ .../src/bridge/bridge_lock_action.rs | 15 ++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/crates/astria-core/src/primitive/v1/asset/denom.rs b/crates/astria-core/src/primitive/v1/asset/denom.rs index 6fd40e8f4..3cd10083b 100644 --- a/crates/astria-core/src/primitive/v1/asset/denom.rs +++ b/crates/astria-core/src/primitive/v1/asset/denom.rs @@ -75,6 +75,24 @@ impl Denom { }; trace } + + /// Calculates the length of the display formatted [Denom] without allocating a String. + #[must_use] + pub fn display_len(&self) -> Option { + match self { + Denom::TracePrefixed(trace) => { + let mut len: usize = 0; + for segment in &trace.trace.inner { + len = len + .checked_add(segment.port.len()) + .and_then(|len| len.checked_add(segment.channel.len())) + .and_then(|len| len.checked_add(2))?; + } + len.checked_add(trace.base_denom.len()) + } + Denom::IbcPrefixed(_) => Some(68), // "ibc/" + 64 hex characters + } + } } impl From for Denom { @@ -691,4 +709,18 @@ mod tests { assert_eq!(None, denom.pop_leading_port_and_channel()); } + + #[test] + fn display_len_ok() { + let trace_denom = Denom::from("a/long/path/to/denom".parse::().unwrap()); + assert_eq!( + trace_denom.to_string().len(), + trace_denom.display_len().unwrap() + ); + let ibc_denom = Denom::from(IbcPrefixed::new([42u8; 32])); + assert_eq!( + ibc_denom.to_string().len(), + ibc_denom.display_len().unwrap() + ); + } } diff --git a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs index fda22f680..fd747b936 100644 --- a/crates/astria-sequencer/src/bridge/bridge_lock_action.rs +++ b/crates/astria-sequencer/src/bridge/bridge_lock_action.rs @@ -105,7 +105,7 @@ impl ActionHandler for BridgeLockAction { let fee = byte_cost_multiplier .saturating_mul( calculate_base_deposit_fee(&deposit) - .expect("deposit fee calculation should not fail"), + .ok_or_eyre("deposit fee calculation overflowed u128")?, ) .saturating_add(transfer_fee); ensure!(from_balance >= fee, "insufficient funds for fee payment"); @@ -134,7 +134,8 @@ impl ActionHandler for BridgeLockAction { .await .wrap_err("failed to get byte cost multiplier")?; let fee = byte_cost_multiplier.saturating_mul( - calculate_base_deposit_fee(&deposit).expect("deposit fee calculation should not fail"), + calculate_base_deposit_fee(&deposit) + .ok_or_eyre("deposit fee calculation overflowed u128")?, ); state .get_and_increase_block_fees(&self.fee_asset, fee, Self::full_name()) @@ -158,13 +159,11 @@ impl ActionHandler for BridgeLockAction { /// for all fields except `asset` and `destination_chain_address`, ergo it may not be representative /// of on-wire length. pub(crate) fn calculate_base_deposit_fee(deposit: &Deposit) -> Option { - let variable_length = deposit + deposit .asset - .to_string() - .len() - .checked_add(deposit.destination_chain_address.len()) - .expect("deposit byte length overflowed usize") as u128; - DEPOSIT_BASE_FEE.checked_add(variable_length) + .display_len() + .and_then(|asset_len| asset_len.checked_add(deposit.destination_chain_address.len())) + .and_then(|var_len| DEPOSIT_BASE_FEE.checked_add(var_len as u128)) } #[cfg(test)] From e7a9820fe7dc6090bbf11239252b7871c78919cf Mon Sep 17 00:00:00 2001 From: ethanoroshiba Date: Fri, 20 Sep 2024 11:16:15 -0500 Subject: [PATCH 09/10] minor clarification --- crates/astria-core/src/primitive/v1/asset/denom.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/astria-core/src/primitive/v1/asset/denom.rs b/crates/astria-core/src/primitive/v1/asset/denom.rs index 3cd10083b..7ff363c11 100644 --- a/crates/astria-core/src/primitive/v1/asset/denom.rs +++ b/crates/astria-core/src/primitive/v1/asset/denom.rs @@ -86,7 +86,7 @@ impl Denom { len = len .checked_add(segment.port.len()) .and_then(|len| len.checked_add(segment.channel.len())) - .and_then(|len| len.checked_add(2))?; + .and_then(|len| len.checked_add(2))?; // 2 additional "/" characters } len.checked_add(trace.base_denom.len()) } From 40d28dcfa87e5d2e808d83db2580c7496b99bf7d Mon Sep 17 00:00:00 2001 From: ethanoroshiba Date: Fri, 20 Sep 2024 11:20:09 -0500 Subject: [PATCH 10/10] Delete unused snapshot --- ...lock_action__tests__get_deposit_byte_length_snapshot.snap | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 crates/astria-sequencer/src/bridge/snapshots/astria_sequencer__bridge__bridge_lock_action__tests__get_deposit_byte_length_snapshot.snap diff --git a/crates/astria-sequencer/src/bridge/snapshots/astria_sequencer__bridge__bridge_lock_action__tests__get_deposit_byte_length_snapshot.snap b/crates/astria-sequencer/src/bridge/snapshots/astria_sequencer__bridge__bridge_lock_action__tests__get_deposit_byte_length_snapshot.snap deleted file mode 100644 index f01ec5cbc..000000000 --- a/crates/astria-sequencer/src/bridge/snapshots/astria_sequencer__bridge__bridge_lock_action__tests__get_deposit_byte_length_snapshot.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: crates/astria-sequencer/src/bridge/bridge_lock_action.rs -expression: get_deposit_byte_len(&deposit) ---- -31