Skip to content

Fix Genesis() silently returning nil instead of an error - #91

Open
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/genesis-nil-contract
Open

Fix Genesis() silently returning nil instead of an error#91
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/genesis-nil-contract

Conversation

@damilolaedwards

Copy link
Copy Markdown

Summary

Spec() and Genesis() are both cached values that may not be ready before bootstrap completes, but Spec() returned an error on unset while Genesis() returned a bare nil. A consumer checking the error the same way for both, a reasonable assumption given the shared shape, nil derefs on Genesis instead of getting an error back.

Fix makes Genesis() share the same contract as Spec().

Test plan

  • Added TestGenesisErrorsWhenUnset in pkg/beacon/beacon_test.go, confirming both getters error on unset
  • Confirmed the test fails against the old code and passes against the fix
  • go build ./..., go vet ./..., go test -race ./... all green

Spec() and Genesis() are both cached values that may not be ready
before bootstrap completes, but Spec() returned an error on unset
while Genesis() returned a bare nil. A consumer checking the error
the same way for both would nil deref on Genesis. Now both getters
share the same contract.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant