Skip to content

Commit

Permalink
Dont Initialize Zeroed Out State (#4863)
Browse files Browse the repository at this point in the history
* dont initialize map with empty registry
* check zeroed pointer
* check zeroed pointer
* imports
* gaz
* better check
* gaz
* fix it finally
* finally fix it
* gaz
  • Loading branch information
nisdas committed Feb 14, 2020
1 parent b99779f commit 214121b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions beacon-chain/powchain/service.go
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"math/big"
"reflect"
"runtime/debug"
"strings"
"sync"
Expand Down Expand Up @@ -211,9 +212,11 @@ func NewService(ctx context.Context, config *Web3ServiceConfig) (*Service, error
if eth1Data != nil {
s.depositTrie = trieutil.CreateTrieFromProto(eth1Data.Trie)
s.chainStartData = eth1Data.ChainstartData
s.preGenesisState, err = stateTrie.InitializeFromProto(eth1Data.BeaconState)
if err != nil {
return nil, errors.Wrap(err, "Could not initialize state trie")
if !reflect.ValueOf(eth1Data.BeaconState).IsZero() {
s.preGenesisState, err = stateTrie.InitializeFromProto(eth1Data.BeaconState)
if err != nil {
return nil, errors.Wrap(err, "Could not initialize state trie")
}
}
s.latestEth1Data = eth1Data.CurrentEth1Data
s.lastReceivedMerkleIndex = int64(len(s.depositTrie.Items()) - 1)
Expand Down

0 comments on commit 214121b

Please sign in to comment.