Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
944e1a0f
Unverified
Commit
944e1a0f
authored
May 19, 2023
by
Felix Lange
Committed by
GitHub
May 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beacon/types: auto-generate SyncCommittee marshaling methods (#27296)
parent
3223950a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
30 deletions
+58
-30
committee.go
beacon/types/committee.go
+7
-30
gen_syncaggregate_json.go
beacon/types/gen_syncaggregate_json.go
+51
-0
No files found.
beacon/types/committee.go
View file @
944e1a0f
...
@@ -164,44 +164,21 @@ func (sc *SyncCommittee) VerifySignature(signingRoot common.Hash, signature *Syn
...
@@ -164,44 +164,21 @@ func (sc *SyncCommittee) VerifySignature(signingRoot common.Hash, signature *Syn
return
bls
.
FastAggregateVerify
(
keys
,
signingRoot
[
:
],
&
sig
)
return
bls
.
FastAggregateVerify
(
keys
,
signingRoot
[
:
],
&
sig
)
}
}
//go:generate go run github.com/fjl/gencodec -type SyncAggregate -field-override syncAggregateMarshaling -out gen_syncaggregate_json.go
// SyncAggregate represents an aggregated BLS signature with Signers referring
// SyncAggregate represents an aggregated BLS signature with Signers referring
// to a subset of the corresponding sync committee.
// to a subset of the corresponding sync committee.
//
//
// See data structure definition here:
// See data structure definition here:
// https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#syncaggregate
// https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#syncaggregate
type
SyncAggregate
struct
{
type
SyncAggregate
struct
{
Signers
[
params
.
SyncCommitteeBitmaskSize
]
byte
Signers
[
params
.
SyncCommitteeBitmaskSize
]
byte
`gencodec:"required" json:"sync_committee_bits"`
Signature
[
params
.
BLSSignatureSize
]
byte
Signature
[
params
.
BLSSignatureSize
]
byte
`gencodec:"required" json:"sync_committee_signature"`
}
type
jsonSyncAggregate
struct
{
Signers
hexutil
.
Bytes
`json:"sync_committee_bits"`
Signature
hexutil
.
Bytes
`json:"sync_committee_signature"`
}
}
// MarshalJSON implements json.Marshaler.
type
syncAggregateMarshaling
struct
{
func
(
s
*
SyncAggregate
)
MarshalJSON
()
([]
byte
,
error
)
{
Signers
hexutil
.
Bytes
return
json
.
Marshal
(
&
jsonSyncAggregate
{
Signature
hexutil
.
Bytes
Signers
:
s
.
Signers
[
:
],
Signature
:
s
.
Signature
[
:
],
})
}
// UnmarshalJSON implements json.Marshaler.
func
(
s
*
SyncAggregate
)
UnmarshalJSON
(
input
[]
byte
)
error
{
var
sc
jsonSyncAggregate
if
err
:=
json
.
Unmarshal
(
input
,
&
sc
);
err
!=
nil
{
return
err
}
if
len
(
sc
.
Signers
)
!=
params
.
SyncCommitteeBitmaskSize
{
return
fmt
.
Errorf
(
"invalid signature bitmask size %d"
,
len
(
sc
.
Signers
))
}
if
len
(
sc
.
Signature
)
!=
params
.
BLSSignatureSize
{
return
fmt
.
Errorf
(
"invalid signature size %d"
,
len
(
sc
.
Signature
))
}
copy
(
s
.
Signers
[
:
],
sc
.
Signers
)
copy
(
s
.
Signature
[
:
],
sc
.
Signature
)
return
nil
}
}
// SignerCount returns the number of signers in the aggregate signature.
// SignerCount returns the number of signers in the aggregate signature.
...
...
beacon/types/gen_syncaggregate_json.go
0 → 100644
View file @
944e1a0f
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package
types
import
(
"encoding/json"
"errors"
"github.com/ethereum/go-ethereum/common/hexutil"
)
var
_
=
(
*
syncAggregateMarshaling
)(
nil
)
// MarshalJSON marshals as JSON.
func
(
s
SyncAggregate
)
MarshalJSON
()
([]
byte
,
error
)
{
type
SyncAggregate
struct
{
Signers
hexutil
.
Bytes
`gencodec:"required" json:"sync_committee_bits"`
Signature
hexutil
.
Bytes
`gencodec:"required" json:"sync_committee_signature"`
}
var
enc
SyncAggregate
enc
.
Signers
=
s
.
Signers
[
:
]
enc
.
Signature
=
s
.
Signature
[
:
]
return
json
.
Marshal
(
&
enc
)
}
// UnmarshalJSON unmarshals from JSON.
func
(
s
*
SyncAggregate
)
UnmarshalJSON
(
input
[]
byte
)
error
{
type
SyncAggregate
struct
{
Signers
*
hexutil
.
Bytes
`gencodec:"required" json:"sync_committee_bits"`
Signature
*
hexutil
.
Bytes
`gencodec:"required" json:"sync_committee_signature"`
}
var
dec
SyncAggregate
if
err
:=
json
.
Unmarshal
(
input
,
&
dec
);
err
!=
nil
{
return
err
}
if
dec
.
Signers
==
nil
{
return
errors
.
New
(
"missing required field 'sync_committee_bits' for SyncAggregate"
)
}
if
len
(
*
dec
.
Signers
)
!=
len
(
s
.
Signers
)
{
return
errors
.
New
(
"field 'sync_committee_bits' has wrong length, need 64 items"
)
}
copy
(
s
.
Signers
[
:
],
*
dec
.
Signers
)
if
dec
.
Signature
==
nil
{
return
errors
.
New
(
"missing required field 'sync_committee_signature' for SyncAggregate"
)
}
if
len
(
*
dec
.
Signature
)
!=
len
(
s
.
Signature
)
{
return
errors
.
New
(
"field 'sync_committee_signature' has wrong length, need 96 items"
)
}
copy
(
s
.
Signature
[
:
],
*
dec
.
Signature
)
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment