1
- From 1899e603ebf036b2d0ea0728907bd6f8ffc26406 Mon Sep 17 00:00:00 2001
1
+ From e5f7a7a9584edd4eef3c06df2d33069b78770c4a Mon Sep 17 00:00:00 2001
2
2
From: Jon Cinque <
[email protected] >
3
- Date: Mon, 24 Oct 2022 20:19:43 -0400
4
- Subject: [PATCH] feat: double PACKET_DATA_SIZE
3
+ Date: Wed, 31 Aug 2022 01:44:22 +0200
4
+ Subject: [PATCH] Multiply packet size by 2
5
5
6
6
---
7
- rpc/src/rpc.rs | 17 ++++++++++++-----
7
+ ledger/src/shred.rs | 2 +-
8
+ ledger/src/shred/legacy.rs | 6 +++---
9
+ ledger/src/shred/merkle.rs | 2 +-
10
+ ledger/src/shred/shred_code.rs | 2 +-
11
+ rpc/src/rpc.rs | 16 +++++++++++-----
8
12
sdk/src/packet.rs | 3 ++-
9
- web3.js/src/transaction/constants.ts | 4 ++ +-
10
- 3 files changed, 17 insertions(+), 7 deletions(-)
13
+ web3.js/src/transaction/constants.ts | 2 +-
14
+ 7 files changed, 20 insertions(+), 13 deletions(-)
11
15
16
+ diff --git a/ledger/src/shred.rs b/ledger/src/shred.rs
17
+ index 0695236214..1c52b164a9 100644
18
+ --- a/ledger/src/shred.rs
19
+ +++ b/ledger/src/shred.rs
20
+ @@ -112,7 +112,7 @@ const OFFSET_OF_SHRED_INDEX: usize = OFFSET_OF_SHRED_SLOT + SIZE_OF_SHRED_SLOT;
21
+ pub const DATA_SHREDS_PER_FEC_BLOCK: usize = 32;
22
+
23
+ // For legacy tests and benchmarks.
24
+ - const_assert_eq!(LEGACY_SHRED_DATA_CAPACITY, 1051);
25
+ + const_assert_eq!(LEGACY_SHRED_DATA_CAPACITY, 2283);
26
+ pub const LEGACY_SHRED_DATA_CAPACITY: usize = legacy::ShredData::CAPACITY;
27
+
28
+ // LAST_SHRED_IN_SLOT also implies DATA_COMPLETE_SHRED.
29
+ diff --git a/ledger/src/shred/legacy.rs b/ledger/src/shred/legacy.rs
30
+ index ca6310bdcb..c0ab2b1de4 100644
31
+ --- a/ledger/src/shred/legacy.rs
32
+ +++ b/ledger/src/shred/legacy.rs
33
+ @@ -17,12 +17,12 @@ use {
34
+ // Code and data shreds have the same payload size.
35
+ pub(super) const SIGNED_MESSAGE_RANGE: Range<usize> = SIZE_OF_SIGNATURE..ShredData::SIZE_OF_PAYLOAD;
36
+ const_assert_eq!(ShredData::SIZE_OF_PAYLOAD, ShredCode::SIZE_OF_PAYLOAD);
37
+ - const_assert_eq!(ShredData::SIZE_OF_PAYLOAD, 1228);
38
+ - const_assert_eq!(ShredData::CAPACITY, 1051);
39
+ + const_assert_eq!(ShredData::SIZE_OF_PAYLOAD, 2460);
40
+ + const_assert_eq!(ShredData::CAPACITY, 2283);
41
+
42
+ // ShredCode::SIZE_OF_HEADERS bytes at the end of data shreds
43
+ // is never used and is not part of erasure coding.
44
+ - const_assert_eq!(SIZE_OF_ERASURE_ENCODED_SLICE, 1139);
45
+ + const_assert_eq!(SIZE_OF_ERASURE_ENCODED_SLICE, 2371);
46
+ pub(super) const SIZE_OF_ERASURE_ENCODED_SLICE: usize =
47
+ ShredCode::SIZE_OF_PAYLOAD - ShredCode::SIZE_OF_HEADERS;
48
+
49
+ diff --git a/ledger/src/shred/merkle.rs b/ledger/src/shred/merkle.rs
50
+ index 90b686f5c8..ff47c745d1 100644
51
+ --- a/ledger/src/shred/merkle.rs
52
+ +++ b/ledger/src/shred/merkle.rs
53
+ @@ -39,7 +39,7 @@ const_assert_eq!(SIZE_OF_MERKLE_ROOT, 20);
54
+ const SIZE_OF_MERKLE_ROOT: usize = std::mem::size_of::<MerkleRoot>();
55
+ const_assert_eq!(SIZE_OF_MERKLE_PROOF_ENTRY, 20);
56
+ const SIZE_OF_MERKLE_PROOF_ENTRY: usize = std::mem::size_of::<MerkleProofEntry>();
57
+ - const_assert_eq!(ShredData::SIZE_OF_PAYLOAD, 1203);
58
+ + const_assert_eq!(ShredData::SIZE_OF_PAYLOAD, 2435);
59
+
60
+ // Defense against second preimage attack:
61
+ // https://en.wikipedia.org/wiki/Merkle_tree#Second_preimage_attack
62
+ diff --git a/ledger/src/shred/shred_code.rs b/ledger/src/shred/shred_code.rs
63
+ index 3b01b8826d..3e3ebfbf78 100644
64
+ --- a/ledger/src/shred/shred_code.rs
65
+ +++ b/ledger/src/shred/shred_code.rs
66
+ @@ -17,7 +17,7 @@ const_assert_eq!(MAX_CODE_SHREDS_PER_SLOT, 32_768 * 17);
67
+ pub(crate) const MAX_CODE_SHREDS_PER_SLOT: usize =
68
+ MAX_DATA_SHREDS_PER_SLOT * (ERASURE_BATCH_SIZE[1] - 1);
69
+
70
+ - const_assert_eq!(ShredCode::SIZE_OF_PAYLOAD, 1228);
71
+ + const_assert_eq!(ShredCode::SIZE_OF_PAYLOAD, 2460);
72
+
73
+ #[derive(Clone, Debug, Eq, PartialEq)]
74
+ pub enum ShredCode {
12
75
diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs
13
- index 11838cf1bc..f429fc5abb 100644
76
+ index 1167b21eaf..c9689f7039 100644
14
77
--- a/rpc/src/rpc.rs
15
78
+++ b/rpc/src/rpc.rs
16
- @@ -4415 ,8 +4415 ,11 @@ pub mod rpc_obsolete_v1_7 {
79
+ @@ -4478 ,8 +4478 ,11 @@ pub mod rpc_obsolete_v1_7 {
17
80
}
18
81
}
19
82
@@ -27,7 +90,7 @@ index 11838cf1bc..f429fc5abb 100644
27
90
fn decode_and_deserialize<T>(
28
91
encoded: String,
29
92
encoding: TransactionBinaryEncoding,
30
- @@ -8376 ,7 +8379 ,7 @@ pub mod tests {
93
+ @@ -8773 ,7 +8776 ,7 @@ pub mod tests {
31
94
}
32
95
33
96
#[test]
@@ -36,7 +99,7 @@ index 11838cf1bc..f429fc5abb 100644
36
99
let ff_tx = vec![0xffu8; PACKET_DATA_SIZE];
37
100
let tx58 = bs58::encode(&ff_tx).into_string();
38
101
assert_eq!(tx58.len(), MAX_BASE58_SIZE);
39
- @@ -8386 ,8 +8389,12 @@ pub mod tests {
102
+ @@ -8783 ,8 +8786,11 @@ pub mod tests {
40
103
41
104
#[test]
42
105
fn test_decode_and_deserialize_too_large_payloads_fail() {
@@ -47,7 +110,6 @@ index 11838cf1bc..f429fc5abb 100644
47
110
+ // So, we need 4 - (PACKET_DATA_SIZE % 3) extra bytes to ensure we'll spill over
48
111
+ let extra_bytes = 4 - (PACKET_DATA_SIZE % 3);
49
112
+ let too_big = PACKET_DATA_SIZE + extra_bytes;
50
- +
51
113
let tx_ser = vec![0xffu8; too_big];
52
114
53
115
let tx58 = bs58::encode(&tx_ser).into_string();
@@ -66,18 +128,15 @@ index 08389860f9..12714028d7 100644
66
128
bitflags! {
67
129
#[repr(C)]
68
130
diff --git a/web3.js/src/transaction/constants.ts b/web3.js/src/transaction/constants.ts
69
- index 075337e8dc..3d4960464f 100644
131
+ index 075337e8dc..618d48cdfd 100644
70
132
--- a/web3.js/src/transaction/constants.ts
71
133
+++ b/web3.js/src/transaction/constants.ts
72
- @@ -4,8 +4,10 @@
73
- * 1280 is IPv6 minimum MTU
134
+ @@ -5,7 +5,7 @@
74
135
* 40 bytes is the size of the IPv6 header
75
136
* 8 bytes is the size of the fragment header
76
- + *
77
- + * Double the minimum for larger transactions
78
137
*/
79
138
- export const PACKET_DATA_SIZE = 1280 - 40 - 8;
80
- + export const PACKET_DATA_SIZE = 2 * (1280 - 40 - 8) ;
139
+ + export const PACKET_DATA_SIZE = 2464 ;
81
140
82
141
export const VERSION_PREFIX_MASK = 0x7f;
83
142
0 commit comments