Skip to content

Commit

Permalink
Clear Pre-Genesis Objects (#4656)
Browse files Browse the repository at this point in the history
* remove pre-genesis data
* Merge branch 'master' into clearUnusedObjects
* lint
* Merge branch 'clearUnusedObjects' of https://github.com/prysmaticlabs/geth-sharding into clearUnusedObjects
* fic build
* gaz
* faulty mock
* Update beacon-chain/blockchain/service.go
  • Loading branch information
nisdas authored and prylabs-bulldozer[bot] committed Jan 26, 2020
1 parent 5eece9a commit 4ea5661
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions beacon-chain/blockchain/service.go
Expand Up @@ -224,6 +224,9 @@ func (s *Service) initializeBeaconChain(

log.Info("Initialized beacon chain genesis state")

// Clear out all pre-genesis data now that the state is initialized.
s.chainStartFetcher.ClearPreGenesisData()

// Update committee shuffled indices for genesis epoch.
if err := helpers.UpdateCommitteeCache(genesisState, 0 /* genesis epoch */); err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions beacon-chain/interop-cold-start/service.go
Expand Up @@ -127,6 +127,11 @@ func (s *Service) PreGenesisState() *pb.BeaconState {
return &pb.BeaconState{}
}

// ClearPreGenesisData --
func (s *Service) ClearPreGenesisData() {
//no-op
}

// DepositByPubkey mocks out the deposit cache functionality for interop.
func (s *Service) DepositByPubkey(ctx context.Context, pubKey []byte) (*ethpb.Deposit, *big.Int) {
return &ethpb.Deposit{}, big.NewInt(1)
Expand Down
7 changes: 7 additions & 0 deletions beacon-chain/powchain/service.go
Expand Up @@ -65,6 +65,7 @@ type ChainStartFetcher interface {
ChainStartDeposits() []*ethpb.Deposit
ChainStartEth1Data() *ethpb.Eth1Data
PreGenesisState() *pb.BeaconState
ClearPreGenesisData()
}

// ChainInfoFetcher retrieves information about eth1 metadata at the eth2 genesis time.
Expand Down Expand Up @@ -241,6 +242,12 @@ func (s *Service) ChainStartDeposits() []*ethpb.Deposit {
return s.chainStartData.ChainstartDeposits
}

// ClearPreGenesisData clears out the stored chainstart deposits and beacon state.
func (s *Service) ClearPreGenesisData() {
s.chainStartData.ChainstartDeposits = []*ethpb.Deposit{}
s.preGenesisState = &pb.BeaconState{}
}

// ChainStartEth1Data returns the eth1 data at chainstart.
func (s *Service) ChainStartEth1Data() *ethpb.Eth1Data {
return s.chainStartData.Eth1Data
Expand Down
5 changes: 5 additions & 0 deletions beacon-chain/powchain/testing/faulty_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions beacon-chain/powchain/testing/mock.go
Expand Up @@ -100,6 +100,11 @@ func (m *POWChain) PreGenesisState() *pb.BeaconState {
return &pb.BeaconState{}
}

// ClearPreGenesisData --
func (m *POWChain) ClearPreGenesisData() {
//no-op
}

// IsConnectedToETH1 --
func (m *POWChain) IsConnectedToETH1() bool {
return true
Expand Down

0 comments on commit 4ea5661

Please sign in to comment.