Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
ApplyGenesis fix
Browse files Browse the repository at this point in the history
  • Loading branch information
a.guzev committed Mar 12, 2020
1 parent 09d76e0 commit fa06db1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
9 changes: 8 additions & 1 deletion app/apply_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ import (
"github.com/ethereum/go-ethereum/common"

"github.com/Fantom-foundation/go-lachesis/evmcore"
"github.com/Fantom-foundation/go-lachesis/inter"
"github.com/Fantom-foundation/go-lachesis/inter/sfctype"
"github.com/Fantom-foundation/go-lachesis/lachesis"
)

// ApplyGenesis writes initial state.
func (s *Store) ApplyGenesis(net *lachesis.Config) (block *evmcore.EvmBlock, isNew bool, err error) {
// TODO: replace first block with DB-migrations
func (s *Store) ApplyGenesis(net *lachesis.Config, firstBlock *inter.Block) (block *evmcore.EvmBlock, isNew bool, err error) {
stored := s.getGenesisState()

if stored == nil && firstBlock != nil {
stored = &firstBlock.Root
}

if stored != nil {
block, err = calcGenesisBlock(net)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions gossip/evm_state_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestGetGenesisBlock(t *testing.T) {
net.Genesis.Alloc.Accounts[addrWithStorage] = accountWithCode

app := app.NewMemStore()
state, _, err := app.ApplyGenesis(&net)
state, _, err := app.ApplyGenesis(&net, nil)
if !assertar.NoError(err) {
return
}
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestGetBlock(t *testing.T) {
net := lachesis.FakeNetConfig(genesis.FakeAccounts(0, 5, big.NewInt(0), pos.StakeToBalance(1)))

app := app.NewMemStore()
state, _, err := app.ApplyGenesis(&net)
state, _, err := app.ApplyGenesis(&net, nil)
if !assertar.NoError(err) {
return
}
Expand Down
2 changes: 1 addition & 1 deletion gossip/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func testBroadcastEvent(t *testing.T, totalPeers int, forcedAggressiveBroadcast

// create stores
app := app.NewMemStore()
state, _, err := app.ApplyGenesis(&net)
state, _, err := app.ApplyGenesis(&net, nil)
if !assertar.NoError(err) {
return
}
Expand Down
2 changes: 1 addition & 1 deletion gossip/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func newTestProtocolManager(nodesNum int, eventsNum int, newtx chan<- []*types.T
}

app := app.NewMemStore()
state, _, err := app.ApplyGenesis(&net)
state, _, err := app.ApplyGenesis(&net, nil)
if err != nil {
return nil, nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion integration/assembly.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ func MakeEngine(dataDir string, gossipCfg *gossip.Config) (*poset.Poset, *app.St

// write genesis

state, _, err := adb.ApplyGenesis(&gossipCfg.Net)
// TODO: replace first block with DB-migrations
firstBlock := gdb.GetBlock(0)
state, _, err := adb.ApplyGenesis(&gossipCfg.Net, firstBlock)
if err != nil {
utils.Fatalf("Failed to write App genesis state: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ func init() {
params.VersionMajor = 0 // Major version component of the current release
params.VersionMinor = 6 // Minor version component of the current release
params.VersionPatch = 0 // Patch version component of the current release
params.VersionMeta = "rc1" // Version metadata to append to the version string
params.VersionMeta = "rc.2" // Version metadata to append to the version string
}

0 comments on commit fa06db1

Please sign in to comment.