Skip to content

Commit

Permalink
Verification by root and not by slot (#6243)
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulio2002 authored Dec 7, 2022
1 parent 7eab12d commit 0da12e4
Show file tree
Hide file tree
Showing 16 changed files with 623 additions and 517 deletions.
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

0 comments on commit 0da12e4

Please sign in to comment.