Skip to content

Commit

Permalink
twoxtx: Double transaction size
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque committed Dec 19, 2022
1 parent 753975d commit 821da80
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4488,8 +4488,8 @@ pub mod rpc_obsolete_v1_7 {
// These values need to be updated if TransactionPacket::DATA_SIZE changes. The
// correct values can be found by hand or by simply encoding `TransactionPacket::DATA_SIZE`
// bytes and checking length. `test_max_encoded_tx_goldens` ensures these values are correct.
const MAX_BASE58_SIZE: usize = 1683; // Golden, bump if TransactionPacket::DATA_SIZE changes
const MAX_BASE64_SIZE: usize = 1644; // Golden, bump if TransactionPacket::DATA_SIZE changes
const MAX_BASE58_SIZE: usize = 3365; // Golden, bump if TransactionPacket::DATA_SIZE changes
const MAX_BASE64_SIZE: usize = 3288; // Golden, bump if TransactionPacket::DATA_SIZE changes
fn decode_and_deserialize<T>(
encoded: String,
encoding: TransactionBinaryEncoding,
Expand Down Expand Up @@ -8831,7 +8831,7 @@ pub mod tests {
assert_eq!(
decode_and_deserialize::<Transaction>(tx64, TransactionBinaryEncoding::Base64)
.unwrap_err(),
Error::invalid_params("invalid base64 encoding: InvalidByte(1640, 33)".to_string())
Error::invalid_params("invalid base64 encoding: InvalidByte(3284, 33)".to_string())
);

let mut tx58 = bs58::encode(&tx_ser).into_string();
Expand All @@ -8850,7 +8850,7 @@ pub mod tests {
decode_and_deserialize::<Transaction>(tx58, TransactionBinaryEncoding::Base58)
.unwrap_err(),
Error::invalid_params(
"invalid base58 encoding: InvalidCharacter { character: '!', index: 1680 }"
"invalid base58 encoding: InvalidCharacter { character: '!', index: 3363 }"
.to_string(),
)
);
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18266,7 +18266,7 @@ pub(crate) mod tests {
}
// Big transaction.
{
let tx = make_transaction(25);
let tx = make_transaction(50);
assert!(bincode::serialized_size(&tx).unwrap() > TransactionPacket::DATA_SIZE as u64);
assert_eq!(
bank.verify_transaction(tx.into(), TransactionVerificationMode::FullVerification)
Expand All @@ -18276,7 +18276,7 @@ pub(crate) mod tests {
}
// Assert that verify fails as soon as serialized
// size exceeds packet data size.
for size in 1..30 {
for size in 1..60 {
let tx = make_transaction(size);
assert_eq!(
bincode::serialized_size(&tx).unwrap() <= TransactionPacket::DATA_SIZE as u64,
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ static_assertions::const_assert_eq!(PACKET_DATA_SIZE, 1232);
/// 8 bytes is the size of the fragment header
pub const PACKET_DATA_SIZE: usize = 1280 - 40 - 8;
#[cfg(test)]
static_assertions::const_assert_eq!(TRANSACTION_DATA_SIZE, 1232);
static_assertions::const_assert_eq!(TRANSACTION_DATA_SIZE, 2464);
/// Maximum over-the-wire size of a transaction, currently two packets
pub const TRANSACTION_DATA_SIZE: usize = PACKET_DATA_SIZE;
pub const TRANSACTION_DATA_SIZE: usize = PACKET_DATA_SIZE * 2;

bitflags! {
#[repr(C)]
Expand Down
3 changes: 3 additions & 0 deletions web3.js/src/transaction/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
export const PACKET_DATA_SIZE = 1280 - 40 - 8;

// Maximum over-the-wire size of a large transaction, currently two packets
export const TRANSACTION_PACKET_DATA_SIZE = PACKET_DATA_SIZE * 2;

export const VERSION_PREFIX_MASK = 0x7f;

export const SIGNATURE_LENGTH_IN_BYTES = 64;

0 comments on commit 821da80

Please sign in to comment.