Skip to content
Open
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
14 changes: 14 additions & 0 deletions pkg/beacon/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@

d.log.WithFields(
logrus.Fields{
"epoch": checkpoint.Finalized.Epoch,

Check failure on line 71 in pkg/beacon/download.go

View workflow job for this annotation

GitHub Actions / lint

string `epoch` has 3 occurrences, make it a constant (goconst)
"root": fmt.Sprintf("%#x", checkpoint.Finalized.Root),

Check failure on line 72 in pkg/beacon/download.go

View workflow job for this annotation

GitHub Actions / lint

string `root` has 4 occurrences, make it a constant (goconst)
},
).Info("Serving a new finalized checkpoint bundle")

Expand Down Expand Up @@ -272,7 +272,7 @@
"slot": slot,
"root": eth.RootAsString(root),
"state_root": eth.RootAsString(stateRoot),
"node": upstream.Config.Name,

Check failure on line 275 in pkg/beacon/download.go

View workflow job for this annotation

GitHub Actions / lint

string `node` has 4 occurrences, make it a constant (goconst)
}).
Infof("Downloaded and stored block for slot %d", slot)

Expand Down Expand Up @@ -389,6 +389,20 @@
return errors.New("beacon state is nil")
}

// Verify that the state the node returned for this slot actually hashes to the
// state root committed to in the block. Nodes that are behind can otherwise
// respond to a by-slot state request with a state from a different chain (e.g.
// their stale head dialed forward through empty slots), which would then be
// stored and served under a state root it does not match.
computedRoot, err := d.sszEncoder.GetStateRoot(beaconState)
if err != nil {
return fmt.Errorf("failed to compute state root: %w", err)
}

if computedRoot != stateRoot {
return fmt.Errorf("beacon state root mismatch: node %s returned a state for slot %d with root %#x, expected %#x", node.Config.Name, slot, computedRoot, stateRoot)
}

expiresAt := time.Now().Add(FinalityHaltedServingPeriod)
if slot == phase0.Slot(0) {
expiresAt = time.Now().Add(999999 * time.Hour)
Expand Down
Loading