Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
shasper
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
shasper
Commits
3507c389
Commit
3507c389
authored
5 years ago
by
Wei Tang
Browse files
Options
Downloads
Patches
Plain Diff
Pass all ssz tests
parent
e28cf59a
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beacon/src/types/state.rs
+3
-1
3 additions, 1 deletion
beacon/src/types/state.rs
utils/ssz/src/fixed.rs
+44
-0
44 additions, 0 deletions
utils/ssz/src/fixed.rs
with
47 additions
and
1 deletion
beacon/src/types/state.rs
+
3
−
1
View file @
3507c389
...
...
@@ -30,6 +30,7 @@ pub struct BeaconState<C: Config> {
// == Registry ==
pub
validators
:
MaxVec
<
Validator
,
C
::
ValidatorRegistryLimit
>
,
#[bm(compact)]
pub
balances
:
MaxVec
<
Uint
,
C
::
ValidatorRegistryLimit
>
,
// == Shuffling ==
...
...
@@ -39,6 +40,7 @@ pub struct BeaconState<C: Config> {
pub
compact_committees_roots
:
VecArray
<
H256
,
C
::
EpochsPerHistoricalVector
>
,
// == Slashings ==
#[bm(compact)]
pub
slashings
:
VecArray
<
Uint
,
C
::
EpochsPerSlashingsVector
>
,
// == Attestations ==
...
...
@@ -53,7 +55,7 @@ pub struct BeaconState<C: Config> {
#[bm(compact)]
#[cfg_attr(feature
=
"serde"
,
serde(serialize_with
=
"crate::utils::serialize_bitvector"
))]
#[cfg_attr(feature
=
"serde"
,
serde(deserialize_with
=
"crate::utils::deserialize_bitvector"
))]
pub
justification_bits
:
generic_array
::
Generi
cArray
<
bool
,
consts
::
JustificationBitsLength
>
,
pub
justification_bits
:
Ve
cArray
<
bool
,
consts
::
JustificationBitsLength
>
,
pub
previous_justified_checkpoint
:
Checkpoint
,
pub
current_justified_checkpoint
:
Checkpoint
,
pub
finalized_checkpoint
:
Checkpoint
,
...
...
This diff is collapsed.
Click to expand it.
utils/ssz/src/fixed.rs
+
44
−
0
View file @
3507c389
...
...
@@ -52,6 +52,50 @@ macro_rules! impl_builtin_fixed_uint_vector {
Ok
(
Compact
(
ret
))
}
}
impl
<
L
:
Unsigned
>
Codec
for
Compact
<
VecArray
<
$t
,
L
>>
{
type
Size
=
Mul
<<
$t
as
Codec
>
::
Size
,
L
>
;
}
impl
<
'a
,
L
:
Unsigned
>
Codec
for
CompactRef
<
'a
,
VecArray
<
$t
,
L
>>
where
Compact
<
VecArray
<
$t
,
L
>>
:
Codec
,
{
type
Size
=
<
Compact
<
VecArray
<
$t
,
L
>>
as
Codec
>
::
Size
;
}
impl
<
'a
,
L
:
Unsigned
>
Encode
for
CompactRef
<
'a
,
VecArray
<
$t
,
L
>>
where
CompactRef
<
'a
,
VecArray
<
$t
,
L
>>
:
Codec
{
fn
encode
(
&
self
)
->
Vec
<
u8
>
{
encode_list
(
self
.0
)
}
}
impl
<
L
:
Unsigned
>
Encode
for
Compact
<
VecArray
<
$t
,
L
>>
where
Compact
<
VecArray
<
$t
,
L
>>
:
Codec
,
for
<
'a
>
CompactRef
<
'a
,
GenericArray
<
$t
,
L
>>
:
Encode
{
fn
encode
(
&
self
)
->
Vec
<
u8
>
{
CompactRef
(
&
self
.0
)
.encode
()
}
}
impl
<
L
:
Unsigned
>
Decode
for
Compact
<
VecArray
<
$t
,
L
>>
where
Compact
<
VecArray
<
$t
,
L
>>
:
Codec
,
{
fn
decode
(
value
:
&
[
u8
])
->
Result
<
Self
,
Error
>
{
let
decoded
=
decode_list
::
<
$t
>
(
value
)
?
;
if
decoded
.len
()
!=
L
::
to_usize
()
{
return
Err
(
Error
::
InvalidLength
)
}
let
mut
ret
=
VecArray
::
default
();
for
i
in
0
..
decoded
.len
()
{
ret
[
i
]
=
decoded
[
i
];
}
Ok
(
Compact
(
ret
))
}
}
)
*
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment