Skip to content

Commit

Permalink
Unify WARNING comments (#10678)
Browse files Browse the repository at this point in the history
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
rkapka and prylabs-bulldozer[bot] authored May 12, 2022
1 parent 1f086e4 commit 7db0435
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion beacon-chain/blockchain/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func testServiceOptsWithDB(t *testing.T) []Option {
}
}

// warning: only use these opts when you are certain there are no db calls
// WARNING: only use these opts when you are certain there are no db calls
// in your code path. this is a lightweight way to satisfy the stategen/beacondb
// initialization requirements w/o the overhead of db init.
func testServiceOptsNoDB() []Option {
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/blockchain/state_balance_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func newStateBalanceCache(sg *stategen.State) (*stateBalanceCache, error) {
// the previously read value. This cache assumes we only want to cache one
// set of balances for a single root (the current justified root).
//
// warning: this is not thread-safe on its own, relies on get() for locking
// WARNING: this is not thread-safe on its own, relies on get() for locking
func (c *stateBalanceCache) update(ctx context.Context, justifiedRoot [32]byte) ([]uint64, error) {
stateBalanceCacheMiss.Inc()
justifiedState, err := c.stateGen.StateByRoot(ctx, justifiedRoot)
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/forkchoice/protoarray/optimistic_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func (f *ForkChoice) IsOptimistic(root [32]byte) (bool, error) {

// SetOptimisticToValid is called with the root of a block that was returned as
// VALID by the EL.
//
// WARNING: This method returns an error if the root is not found in forkchoice
func (f *ForkChoice) SetOptimisticToValid(ctx context.Context, root [32]byte) error {
f.store.nodesLock.Lock()
Expand Down
3 changes: 2 additions & 1 deletion beacon-chain/state/state-native/getters_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ func (b *BeaconState) NumValidators() int {
}

// ReadFromEveryValidator reads values from every validator and applies it to the provided function.
// Warning: This method is potentially unsafe, as it exposes the actual validator registry.
//
// WARNING: This method is potentially unsafe, as it exposes the actual validator registry.
func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val state.ReadOnlyValidator) error) error {
if b.validators == nil {
return errors.New("nil validators in state")
Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/state/state-native/state_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ func (b *BeaconState) HashTreeRoot(ctx context.Context) ([32]byte, error) {
}

// Initializes the Merkle layers for the beacon state if they are empty.
//
// WARNING: Caller must acquire the mutex before using.
func (b *BeaconState) initializeMerkleLayers(ctx context.Context) error {
if len(b.merkleLayers) > 0 {
Expand All @@ -565,6 +566,7 @@ func (b *BeaconState) initializeMerkleLayers(ctx context.Context) error {
}

// Recomputes the Merkle layers for the dirty fields in the state.
//
// WARNING: Caller must acquire the mutex before using.
func (b *BeaconState) recomputeDirtyFields(ctx context.Context) error {
for field := range b.dirtyFields {
Expand Down
3 changes: 2 additions & 1 deletion beacon-chain/state/v1/getters_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ func (b *BeaconState) NumValidators() int {
}

// ReadFromEveryValidator reads values from every validator and applies it to the provided function.
// Warning: This method is potentially unsafe, as it exposes the actual validator registry.
//
// WARNING: This method is potentially unsafe, as it exposes the actual validator registry.
func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val state.ReadOnlyValidator) error) error {
if !b.hasInnerState() {
return ErrNilInnerState
Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/state/v1/state_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ func (b *BeaconState) HashTreeRoot(ctx context.Context) ([32]byte, error) {
}

// Initializes the Merkle layers for the beacon state if they are empty.
//
// WARNING: Caller must acquire the mutex before using.
func (b *BeaconState) initializeMerkleLayers(ctx context.Context) error {
if len(b.merkleLayers) > 0 {
Expand All @@ -229,6 +230,7 @@ func (b *BeaconState) initializeMerkleLayers(ctx context.Context) error {
}

// Recomputes the Merkle layers for the dirty fields in the state.
//
// WARNING: Caller must acquire the mutex before using.
func (b *BeaconState) recomputeDirtyFields(ctx context.Context) error {
for field := range b.dirtyFields {
Expand Down
3 changes: 2 additions & 1 deletion beacon-chain/state/v2/getters_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ func (b *BeaconState) NumValidators() int {
}

// ReadFromEveryValidator reads values from every validator and applies it to the provided function.
// Warning: This method is potentially unsafe, as it exposes the actual validator registry.
//
// WARNING: This method is potentially unsafe, as it exposes the actual validator registry.
func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val state.ReadOnlyValidator) error) error {
if !b.hasInnerState() {
return ErrNilInnerState
Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/state/v2/state_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func (b *BeaconState) HashTreeRoot(ctx context.Context) ([32]byte, error) {
}

// Initializes the Merkle layers for the beacon state if they are empty.
//
// WARNING: Caller must acquire the mutex before using.
func (b *BeaconState) initializeMerkleLayers(ctx context.Context) error {
if len(b.merkleLayers) > 0 {
Expand All @@ -234,6 +235,7 @@ func (b *BeaconState) initializeMerkleLayers(ctx context.Context) error {
}

// Recomputes the Merkle layers for the dirty fields in the state.
//
// WARNING: Caller must acquire the mutex before using.
func (b *BeaconState) recomputeDirtyFields(ctx context.Context) error {
for field := range b.dirtyFields {
Expand Down
3 changes: 2 additions & 1 deletion beacon-chain/state/v3/getters_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ func (b *BeaconState) NumValidators() int {
}

// ReadFromEveryValidator reads values from every validator and applies it to the provided function.
// Warning: This method is potentially unsafe, as it exposes the actual validator registry.
//
// WARNING: This method is potentially unsafe, as it exposes the actual validator registry.
func (b *BeaconState) ReadFromEveryValidator(f func(idx int, val state.ReadOnlyValidator) error) error {
if !b.hasInnerState() {
return ErrNilInnerState
Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/state/v3/state_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func (b *BeaconState) HashTreeRoot(ctx context.Context) ([32]byte, error) {
}

// Initializes the Merkle layers for the beacon state if they are empty.
//
// WARNING: Caller must acquire the mutex before using.
func (b *BeaconState) initializeMerkleLayers(ctx context.Context) error {
if len(b.merkleLayers) > 0 {
Expand All @@ -234,6 +235,7 @@ func (b *BeaconState) initializeMerkleLayers(ctx context.Context) error {
}

// Recomputes the Merkle layers for the dirty fields in the state.
//
// WARNING: Caller must acquire the mutex before using.
func (b *BeaconState) recomputeDirtyFields(_ context.Context) error {
for field := range b.dirtyFields {
Expand Down
3 changes: 2 additions & 1 deletion config/params/testnet_e2e_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ func UseE2EMainnetConfig() {
}

// E2ETestConfig retrieves the configurations made specifically for E2E testing.
// Warning: This config is only for testing, it is not meant for use outside of E2E.
//
// WARNING: This config is only for testing, it is not meant for use outside of E2E.
func E2ETestConfig() *BeaconChainConfig {
e2eConfig := MinimalSpecConfig()

Expand Down

0 comments on commit 7db0435

Please sign in to comment.