@@ -52,6 +52,7 @@ unsafe impl GlobalAlloc for LimitedAllocator {
52
52
const MAX_ALLOC : usize = 10 * 1024 * 1024 ; // 10 MB
53
53
54
54
if layout. size ( ) > MAX_ALLOC {
55
+ println ! ( "ASDF ALLOCATION OF {} BYTES EXCEEDS LIMIT OF {} BYTES" , layout. size( ) , MAX_ALLOC ) ;
55
56
panic ! (
56
57
"Allocation of {} bytes exceeds limit of {} bytes" ,
57
58
layout. size( ) ,
@@ -105,15 +106,19 @@ fn process_type<T: Serialize + serde::de::DeserializeOwned>(
105
106
// Create bincode configuration with size limits
106
107
let config = bincode:: config:: DefaultOptions :: new ( )
107
108
. with_limit ( 10_000_000 ) // Limit to 10MB (adjust as needed)
108
- . with_fixint_encoding ( ) ;
109
-
110
- let typ: T = if let Ok ( h) = config. deserialize ( & bincode_slice[ 1 ..] ) {
111
- h
112
- } else {
113
- return Some ( TypeEffects {
114
- result : 1 ,
115
- ..Default :: default ( )
116
- } ) ;
109
+ . with_fixint_encoding ( )
110
+ . allow_trailing_bytes ( ) ;
111
+
112
+ let res = config. deserialize :: < T > ( & bincode_slice[ 1 ..] ) ;
113
+ let typ = match res {
114
+ Ok ( h) => { h }
115
+ Err ( err) => {
116
+ println ! ( "ASDF TYPE SERIALIZE FAILED: {}" , err) ;
117
+ return Some ( TypeEffects {
118
+ result : 1 ,
119
+ ..Default :: default ( )
120
+ } ) ;
121
+ }
117
122
} ;
118
123
119
124
let mut ser = MemoryRepresentationSerializer :: new ( ) ;
@@ -146,6 +151,9 @@ pub fn execute_type(input: TypeContext) -> Option<TypeEffects> {
146
151
let bincode_slice: & [ u8 ] =
147
152
unsafe { std:: slice:: from_raw_parts ( input. content . as_ptr ( ) , input. content . len ( ) ) } ;
148
153
154
+ println ! ( "ASDF TYPE ID: {} {:?}" , bincode_slice[ 0 ] , bincode_slice. len( ) ) ;
155
+ /* FIXME: This type lookup table is AWFUL and needs to be
156
+ replaced with something that doesn't have hardcoded indices. */
149
157
match bincode_slice[ 0 ] {
150
158
0 => process_type :: < Hash > ( bincode_slice) ,
151
159
2 => process_type :: < Signature > ( bincode_slice) ,
@@ -159,26 +167,26 @@ pub fn execute_type(input: TypeContext) -> Option<TypeEffects> {
159
167
16 => process_type :: < EpochSchedule > ( bincode_slice) ,
160
168
17 => process_type :: < RentCollector > ( bincode_slice) ,
161
169
18 => process_type :: < StakeHistoryEntry > ( bincode_slice) ,
162
- 19 => process_type :: < StakeHistory > ( bincode_slice) ,
163
- 22 => process_type :: < VoteAccounts > ( bincode_slice) ,
164
- 33 => process_type :: < BankIncrementalSnapshotPersistence > ( bincode_slice) ,
165
- 34 => process_type :: < NodeVoteAccounts > ( bincode_slice) ,
166
- 37 => process_type :: < EpochStakes > ( bincode_slice) ,
167
- 42 => process_type :: < BankHashStats > ( bincode_slice) ,
168
- 50 => process_type :: < VersionedEpochStakes > ( bincode_slice) ,
169
- 56 => process_type :: < PohConfig > ( bincode_slice) ,
170
- 60 => process_type :: < Clock > ( bincode_slice) ,
171
- 61 => process_type :: < LastRestartSlot > ( bincode_slice) ,
172
- 94 => process_type :: < EpochRewards > ( bincode_slice) ,
173
- 155 => process_type :: < ConfigKeys > ( bincode_slice) ,
174
- 171 => process_type :: < FrozenHashStatus > ( bincode_slice) ,
175
- 172 => process_type :: < FrozenHashVersioned > ( bincode_slice) ,
176
- 213 => process_type :: < CrdsData > ( bincode_slice) ,
177
- 215 => process_type :: < CrdsFilter > ( bincode_slice) ,
178
- 216 => process_type :: < CrdsValue > ( bincode_slice) ,
179
- 225 => process_type :: < RepairRequestHeader > ( bincode_slice) ,
180
- 230 => process_type :: < RepairProtocol > ( bincode_slice) ,
181
- 245 => process_type :: < DuplicateSlotProof > ( bincode_slice) ,
170
+ 20 => process_type :: < StakeHistory > ( bincode_slice) ,
171
+ 21 => process_type :: < VoteAccounts > ( bincode_slice) ,
172
+ 34 => process_type :: < BankIncrementalSnapshotPersistence > ( bincode_slice) ,
173
+ 35 => process_type :: < NodeVoteAccounts > ( bincode_slice) ,
174
+ 38 => process_type :: < EpochStakes > ( bincode_slice) ,
175
+ 43 => process_type :: < BankHashStats > ( bincode_slice) ,
176
+ 51 => process_type :: < VersionedEpochStakes > ( bincode_slice) ,
177
+ 57 => process_type :: < PohConfig > ( bincode_slice) ,
178
+ 61 => process_type :: < Clock > ( bincode_slice) ,
179
+ 62 => process_type :: < LastRestartSlot > ( bincode_slice) ,
180
+ 95 => process_type :: < EpochRewards > ( bincode_slice) ,
181
+ 156 => process_type :: < ConfigKeys > ( bincode_slice) ,
182
+ 172 => process_type :: < FrozenHashStatus > ( bincode_slice) ,
183
+ 173 => process_type :: < FrozenHashVersioned > ( bincode_slice) ,
184
+ 214 => process_type :: < CrdsData > ( bincode_slice) ,
185
+ 216 => process_type :: < CrdsFilter > ( bincode_slice) ,
186
+ 217 => process_type :: < CrdsValue > ( bincode_slice) ,
187
+ 226 => process_type :: < RepairRequestHeader > ( bincode_slice) ,
188
+ 231 => process_type :: < RepairProtocol > ( bincode_slice) ,
189
+ 246 => process_type :: < DuplicateSlotProof > ( bincode_slice) ,
182
190
_ => {
183
191
eprintln ! ( "Invalid type ID: {}" , bincode_slice[ 0 ] ) ;
184
192
None
0 commit comments