Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verification by root and not by slot #6243

Merged
merged 3 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cl/cltypes/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
all:
go run github.com/ferranbt/fastssz/sszgen -path types.go
go run github.com/ferranbt/fastssz/sszgen -path network.go
go run github.com/prysmaticlabs/fastssz/sszgen -path types.go
go run github.com/prysmaticlabs/fastssz/sszgen -path network.go
clean:
rm lightrpc/*.pb.go
2 changes: 1 addition & 1 deletion cl/cltypes/custom_types.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cltypes

import (
ssz "github.com/ferranbt/fastssz"
"github.com/pkg/errors"
ssz "github.com/prysmaticlabs/fastssz"
)

const (
Expand Down
137 changes: 63 additions & 74 deletions cl/cltypes/network_encoding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 19 additions & 2 deletions cl/cltypes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ type Checkpoint struct {
*/
type AggregateAndProof struct {
AggregatorIndex uint64
Aggregate Attestation
Aggregate *Attestation
SelectionProof [96]byte `ssz-size:"96"`
}

type SignedAggregateAndProof struct {
Message AggregateAndProof
Message *AggregateAndProof
Signature [96]byte `ssz-size:"96"`
}

Expand Down Expand Up @@ -338,6 +338,23 @@ type BeaconState struct {
LatestExecutionPayloadHeader *ExecutionHeader
}

// BlockRoot retrieves a the state block root from the state.
func (b *BeaconState) BlockRoot() ([32]byte, error) {
stateRoot, err := b.HashTreeRoot()
if err != nil {
return [32]byte{}, nil
}
// We make a temporary header for block root computation
tempHeader := &BeaconBlockHeader{
Slot: b.LatestBlockHeader.Slot,
ProposerIndex: b.LatestBlockHeader.ProposerIndex,
ParentRoot: b.LatestBlockHeader.ParentRoot,
BodyRoot: b.LatestBlockHeader.BodyRoot,
Root: stateRoot,
}
return tempHeader.HashTreeRoot()
}

type ObjectSSZ interface {
ssz.Marshaler
ssz.Unmarshaler
Expand Down
Loading