@@ -64,6 +64,7 @@ pub struct BeaconState {
64
64
#[ superstruct( getter( copy) ) ]
65
65
pub genesis_validators_root : B256 ,
66
66
#[ superstruct( getter( copy) ) ]
67
+ #[ serde( deserialize_with = "as_u64" ) ]
67
68
pub slot : u64 ,
68
69
#[ superstruct( getter( copy) ) ]
69
70
pub fork : Fork ,
@@ -84,12 +85,14 @@ pub struct BeaconState {
84
85
85
86
// Registry
86
87
pub validators : VariableList < Validator , ValidatorRegistryLimit > ,
88
+ #[ serde( deserialize_with = "ssz_types::serde_utils::quoted_u64_var_list::deserialize" ) ]
87
89
pub balances : VariableList < u64 , ValidatorRegistryLimit > ,
88
90
89
91
// Randomness
90
92
pub randao_mixes : FixedVector < B256 , EpochsPerHistoricalVector > ,
91
93
92
94
// Slashings
95
+ #[ serde( deserialize_with = "ssz_types::serde_utils::quoted_u64_fixed_vec::deserialize" ) ]
93
96
pub slashings : FixedVector < u64 , EpochsPerSlashingsVector > ,
94
97
95
98
// Participation (Altair and later)
@@ -109,6 +112,7 @@ pub struct BeaconState {
109
112
110
113
// Inactivity
111
114
#[ superstruct( only( Bellatrix , Capella , Deneb ) ) ]
115
+ #[ serde( deserialize_with = "ssz_types::serde_utils::quoted_u64_var_list::deserialize" ) ]
112
116
pub inactivity_scores : VariableList < u64 , ValidatorRegistryLimit > ,
113
117
114
118
// Light-client sync committees
@@ -366,9 +370,7 @@ mod test {
366
370
"../test_assets/beacon/bellatrix/BeaconState/ssz_random/{case}/value.yaml"
367
371
) )
368
372
. expect ( "cannot find test asset" ) ;
369
- let value: Value = serde_yaml:: from_str ( & value) . unwrap ( ) ;
370
- let content: BeaconStateBellatrix = serde_json:: from_value ( value) . unwrap ( ) ;
371
-
373
+ let content: BeaconStateBellatrix = serde_yaml:: from_str ( & value) . unwrap ( ) ;
372
374
let compressed = std:: fs:: read ( format ! (
373
375
"../test_assets/beacon/bellatrix/BeaconState/ssz_random/{case}/serialized.ssz_snappy"
374
376
) )
@@ -401,9 +403,7 @@ mod test {
401
403
"../test_assets/beacon/capella/BeaconState/ssz_random/{case}/value.yaml"
402
404
) )
403
405
. expect ( "cannot find test asset" ) ;
404
- let value: Value = serde_yaml:: from_str ( & value) . unwrap ( ) ;
405
- let content: BeaconStateCapella = serde_json:: from_value ( value) . unwrap ( ) ;
406
-
406
+ let content: BeaconStateCapella = serde_yaml:: from_str ( & value) . unwrap ( ) ;
407
407
let compressed = std:: fs:: read ( format ! (
408
408
"../test_assets/beacon/capella/BeaconState/ssz_random/{case}/serialized.ssz_snappy"
409
409
) )
@@ -432,8 +432,13 @@ mod test {
432
432
"../test_assets/beacon/deneb/BeaconState/ssz_random/case_0/value.yaml" ,
433
433
)
434
434
. expect ( "cannot find test asset" ) ;
435
- let value: Value = serde_yaml:: from_str ( & value) . unwrap ( ) ;
436
- let content: BeaconStateDeneb = serde_json:: from_value ( value) . unwrap ( ) ;
435
+ let content: BeaconStateDeneb = serde_yaml:: from_str ( & value) . unwrap ( ) ;
436
+ let pandaops_value = std:: fs:: read_to_string (
437
+ "../test_assets/beacon/deneb/BeaconState/ssz_random/case_0/pandaops_value.yaml" ,
438
+ )
439
+ . expect ( "cannot find test asset" ) ;
440
+ let pandaops_content: BeaconStateDeneb = serde_yaml:: from_str ( & pandaops_value) . unwrap ( ) ;
441
+ assert_eq ! ( content, pandaops_content) ;
437
442
438
443
let compressed = std:: fs:: read (
439
444
"../test_assets/beacon/deneb/BeaconState/ssz_random/case_0/serialized.ssz_snappy" ,
@@ -467,9 +472,7 @@ mod test {
467
472
"../test_assets/beacon/bellatrix/HistoricalBatch/ssz_random/{case}/value.yaml"
468
473
) )
469
474
. expect ( "cannot find test asset" ) ;
470
- let value: Value = serde_yaml:: from_str ( & value) . unwrap ( ) ;
471
- let content: HistoricalBatch = serde_json:: from_value ( value) . unwrap ( ) ;
472
-
475
+ let content: HistoricalBatch = serde_yaml:: from_str ( & value) . unwrap ( ) ;
473
476
let compressed = std:: fs:: read ( format ! (
474
477
"../test_assets/beacon/bellatrix/HistoricalBatch/ssz_random/{case}/serialized.ssz_snappy"
475
478
) )
@@ -486,9 +489,7 @@ mod test {
486
489
"../test_assets/beacon/bellatrix/HistoricalBatch/ssz_random/case_0/value.yaml" ,
487
490
)
488
491
. expect ( "cannot find test asset" ) ;
489
- let value: Value = serde_yaml:: from_str ( & value) . unwrap ( ) ;
490
- let content: HistoricalBatch = serde_json:: from_value ( value) . unwrap ( ) ;
491
-
492
+ let content: HistoricalBatch = serde_yaml:: from_str ( & value) . unwrap ( ) ;
492
493
let expected_proof = [
493
494
"0xad500369fa624b7bb451bf1c5119bb6e5e623bab76a0d06948d04a38f35a740d" ,
494
495
"0x222151dcdfbace03dd6f2428ee1a12acffaa1ce03e6966aefd4a48282a776e8e" ,
@@ -519,8 +520,7 @@ mod test {
519
520
"../test_assets/beacon/deneb/BeaconState/ssz_random/case_0/value.yaml" ,
520
521
)
521
522
. expect ( "cannot find test asset" ) ;
522
- let value: Value = serde_yaml:: from_str ( & value) . unwrap ( ) ;
523
- let beacon_state: BeaconStateDeneb = serde_json:: from_value ( value) . unwrap ( ) ;
523
+ let beacon_state: BeaconStateDeneb = serde_yaml:: from_str ( & value) . unwrap ( ) ;
524
524
let historical_summaries_proof = beacon_state. build_historical_summaries_proof ( ) ;
525
525
assert_eq ! ( historical_summaries_proof. len( ) , 5 ) ;
526
526
}
0 commit comments