@@ -10,21 +10,20 @@ Subject: [PATCH] Multiply packet size by 2
10
10
ledger/src/shred/shred_code.rs | 2 +-
11
11
rpc/src/rpc.rs | 16 +++++++++++-----
12
12
sdk/src/packet.rs | 3 ++-
13
- web3.js/src/transaction/constants.ts | 2 +-
14
- 7 files changed, 20 insertions(+), 13 deletions(-)
13
+ 6 files changed, 19 insertions(+), 12 deletions(-)
15
14
16
15
diff --git a/ledger/src/shred.rs b/ledger/src/shred.rs
17
16
index 0695236214..1c52b164a9 100644
18
17
--- a/ledger/src/shred.rs
19
18
+++ b/ledger/src/shred.rs
20
19
@@ -112,7 +112,7 @@ const OFFSET_OF_SHRED_INDEX: usize = OFFSET_OF_SHRED_SLOT + SIZE_OF_SHRED_SLOT;
21
20
pub const DATA_SHREDS_PER_FEC_BLOCK: usize = 32;
22
-
21
+
23
22
// For legacy tests and benchmarks.
24
23
- const_assert_eq!(LEGACY_SHRED_DATA_CAPACITY, 1051);
25
24
+ const_assert_eq!(LEGACY_SHRED_DATA_CAPACITY, 2283);
26
25
pub const LEGACY_SHRED_DATA_CAPACITY: usize = legacy::ShredData::CAPACITY;
27
-
26
+
28
27
// LAST_SHRED_IN_SLOT also implies DATA_COMPLETE_SHRED.
29
28
diff --git a/ledger/src/shred/legacy.rs b/ledger/src/shred/legacy.rs
30
29
index ca6310bdcb..c0ab2b1de4 100644
@@ -38,14 +37,14 @@ index ca6310bdcb..c0ab2b1de4 100644
38
37
- const_assert_eq!(ShredData::CAPACITY, 1051);
39
38
+ const_assert_eq!(ShredData::SIZE_OF_PAYLOAD, 2460);
40
39
+ const_assert_eq!(ShredData::CAPACITY, 2283);
41
-
40
+
42
41
// ShredCode::SIZE_OF_HEADERS bytes at the end of data shreds
43
42
// is never used and is not part of erasure coding.
44
43
- const_assert_eq!(SIZE_OF_ERASURE_ENCODED_SLICE, 1139);
45
44
+ const_assert_eq!(SIZE_OF_ERASURE_ENCODED_SLICE, 2371);
46
45
pub(super) const SIZE_OF_ERASURE_ENCODED_SLICE: usize =
47
46
ShredCode::SIZE_OF_PAYLOAD - ShredCode::SIZE_OF_HEADERS;
48
-
47
+
49
48
diff --git a/ledger/src/shred/merkle.rs b/ledger/src/shred/merkle.rs
50
49
index 90b686f5c8..ff47c745d1 100644
51
50
--- a/ledger/src/shred/merkle.rs
@@ -56,7 +55,7 @@ index 90b686f5c8..ff47c745d1 100644
56
55
const SIZE_OF_MERKLE_PROOF_ENTRY: usize = std::mem::size_of::<MerkleProofEntry>();
57
56
- const_assert_eq!(ShredData::SIZE_OF_PAYLOAD, 1203);
58
57
+ const_assert_eq!(ShredData::SIZE_OF_PAYLOAD, 2435);
59
-
58
+
60
59
// Defense against second preimage attack:
61
60
// https://en.wikipedia.org/wiki/Merkle_tree#Second_preimage_attack
62
61
diff --git a/ledger/src/shred/shred_code.rs b/ledger/src/shred/shred_code.rs
@@ -66,10 +65,10 @@ index 3b01b8826d..3e3ebfbf78 100644
66
65
@@ -17,7 +17,7 @@ const_assert_eq!(MAX_CODE_SHREDS_PER_SLOT, 32_768 * 17);
67
66
pub(crate) const MAX_CODE_SHREDS_PER_SLOT: usize =
68
67
MAX_DATA_SHREDS_PER_SLOT * (ERASURE_BATCH_SIZE[1] - 1);
69
-
68
+
70
69
- const_assert_eq!(ShredCode::SIZE_OF_PAYLOAD, 1228);
71
70
+ const_assert_eq!(ShredCode::SIZE_OF_PAYLOAD, 2460);
72
-
71
+
73
72
#[derive(Clone, Debug, Eq, PartialEq)]
74
73
pub enum ShredCode {
75
74
diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs
@@ -79,7 +78,7 @@ index 1167b21eaf..c9689f7039 100644
79
78
@@ -4478,8 +4478,11 @@ pub mod rpc_obsolete_v1_7 {
80
79
}
81
80
}
82
-
81
+
83
82
- const MAX_BASE58_SIZE: usize = 1683; // Golden, bump if PACKET_DATA_SIZE changes
84
83
- const MAX_BASE64_SIZE: usize = 1644; // Golden, bump if PACKET_DATA_SIZE changes
85
84
+ // These values need to be updated if PACKET_DATA_SIZE changes. The correct values can
@@ -92,15 +91,15 @@ index 1167b21eaf..c9689f7039 100644
92
91
encoding: TransactionBinaryEncoding,
93
92
@@ -8773,7 +8776,7 @@ pub mod tests {
94
93
}
95
-
94
+
96
95
#[test]
97
96
- fn test_worst_case_encoded_tx_goldens() {
98
97
+ fn test_max_encoded_tx_goldens() {
99
98
let ff_tx = vec![0xffu8; PACKET_DATA_SIZE];
100
99
let tx58 = bs58::encode(&ff_tx).into_string();
101
100
assert_eq!(tx58.len(), MAX_BASE58_SIZE);
102
101
@@ -8783,8 +8786,11 @@ pub mod tests {
103
-
102
+
104
103
#[test]
105
104
fn test_decode_and_deserialize_too_large_payloads_fail() {
106
105
- // +2 because +1 still fits in base64 encoded worst-case
@@ -111,7 +110,7 @@ index 1167b21eaf..c9689f7039 100644
111
110
+ let extra_bytes = 4 - (PACKET_DATA_SIZE % 3);
112
111
+ let too_big = PACKET_DATA_SIZE + extra_bytes;
113
112
let tx_ser = vec![0xffu8; too_big];
114
-
113
+
115
114
let tx58 = bs58::encode(&tx_ser).into_string();
116
115
diff --git a/sdk/src/packet.rs b/sdk/src/packet.rs
117
116
index 08389860f9..12714028d7 100644
@@ -124,22 +123,9 @@ index 08389860f9..12714028d7 100644
124
123
- pub const PACKET_DATA_SIZE: usize = 1280 - 40 - 8;
125
124
+ /// Double the minimum to support larger than MTU transactions
126
125
+ pub const PACKET_DATA_SIZE: usize = 2 * (1280 - 40 - 8);
127
-
126
+
128
127
bitflags! {
129
128
#[repr(C)]
130
- diff --git a/web3.js/src/transaction/constants.ts b/web3.js/src/transaction/constants.ts
131
- index 075337e8dc..618d48cdfd 100644
132
- --- a/web3.js/src/transaction/constants.ts
133
- +++ b/web3.js/src/transaction/constants.ts
134
- @@ -5,7 +5,7 @@
135
- * 40 bytes is the size of the IPv6 header
136
- * 8 bytes is the size of the fragment header
137
- */
138
- - export const PACKET_DATA_SIZE = 1280 - 40 - 8;
139
- + export const PACKET_DATA_SIZE = 2464;
140
-
141
- export const VERSION_PREFIX_MASK = 0x7f;
142
-
143
- - -
129
+ - -
144
130
2.38.1
145
131
0 commit comments