From 7606b7595fa11cf07b16ca7aabdff3e224f337db Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Thu, 31 May 2018 22:18:17 -0400 Subject: [PATCH] compiles --- consensus/replay.go | 14 ++++++++------ consensus/replay_file.go | 2 +- consensus/wal_generator.go | 2 +- node/node.go | 2 +- types/protobuf.go | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/consensus/replay.go b/consensus/replay.go index 13d665f7..a51c07bb 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -2,7 +2,6 @@ package consensus import ( "bytes" - "encoding/json" "fmt" "hash/crc32" "io" @@ -197,20 +196,20 @@ type Handshaker struct { stateDB dbm.DB initialState sm.State store sm.BlockStore - appState json.RawMessage + genDoc *types.GenesisDoc logger log.Logger nBlocks int // number of blocks applied to the state } func NewHandshaker(stateDB dbm.DB, state sm.State, - store sm.BlockStore, appState json.RawMessage) *Handshaker { + store sm.BlockStore, genDoc *types.GenesisDoc) *Handshaker { return &Handshaker{ stateDB: stateDB, initialState: state, store: store, - appState: appState, + genDoc: genDoc, logger: log.NewNopLogger(), nBlocks: 0, } @@ -269,8 +268,11 @@ func (h *Handshaker) ReplayBlocks(state sm.State, appHash []byte, appBlockHeight if appBlockHeight == 0 { validators := types.TM2PB.Validators(state.Validators) req := abci.RequestInitChain{ - Validators: validators, - AppStateBytes: h.appState, + Time: h.genDoc.GenesisTime.Unix(), // TODO + ChainId: h.genDoc.ChainID, + ConsensusParams: types.TM2PB.ConsensusParams(h.genDoc.ConsensusParams), + Validators: validators, + AppStateBytes: h.genDoc.AppStateJSON, } _, err := proxyApp.Consensus().InitChainSync(req) if err != nil { diff --git a/consensus/replay_file.go b/consensus/replay_file.go index 4f834346..57204b01 100644 --- a/consensus/replay_file.go +++ b/consensus/replay_file.go @@ -299,7 +299,7 @@ func newConsensusStateForReplay(config cfg.BaseConfig, csConfig *cfg.ConsensusCo // Create proxyAppConn connection (consensus, mempool, query) clientCreator := proxy.DefaultClientCreator(config.ProxyApp, config.ABCI, config.DBDir()) proxyApp := proxy.NewAppConns(clientCreator, - NewHandshaker(stateDB, state, blockStore, gdoc.AppState())) + NewHandshaker(stateDB, state, blockStore, gdoc)) err = proxyApp.Start() if err != nil { cmn.Exit(cmn.Fmt("Error starting proxy app conns: %v", err)) diff --git a/consensus/wal_generator.go b/consensus/wal_generator.go index 38bed4ac..f61af15f 100644 --- a/consensus/wal_generator.go +++ b/consensus/wal_generator.go @@ -52,7 +52,7 @@ func WALWithNBlocks(numBlocks int) (data []byte, err error) { return nil, errors.Wrap(err, "failed to make genesis state") } blockStore := bc.NewBlockStore(blockStoreDB) - handshaker := NewHandshaker(stateDB, state, blockStore, genDoc.AppState()) + handshaker := NewHandshaker(stateDB, state, blockStore, genDoc) proxyApp := proxy.NewAppConns(proxy.NewLocalClientCreator(app), handshaker) proxyApp.SetLogger(logger.With("module", "proxy")) if err := proxyApp.Start(); err != nil { diff --git a/node/node.go b/node/node.go index 5da57665..a8b5c9b2 100644 --- a/node/node.go +++ b/node/node.go @@ -159,7 +159,7 @@ func NewNode(config *cfg.Config, // and sync tendermint and the app by performing a handshake // and replaying any necessary blocks consensusLogger := logger.With("module", "consensus") - handshaker := cs.NewHandshaker(stateDB, state, blockStore, genDoc.AppState()) + handshaker := cs.NewHandshaker(stateDB, state, blockStore, genDoc) handshaker.SetLogger(consensusLogger) proxyApp := proxy.NewAppConns(clientCreator, handshaker) proxyApp.SetLogger(logger.With("module", "proxy")) diff --git a/types/protobuf.go b/types/protobuf.go index 48cc0202..2e772faf 100644 --- a/types/protobuf.go +++ b/types/protobuf.go @@ -57,8 +57,8 @@ func (tm2pb) Validators(vals *ValidatorSet) []types.Validator { return validators } -func (tm2pb) ConsensusParams(params *ConsensusParams) types.ConsensusParams { - return types.ConsensusParams{ +func (tm2pb) ConsensusParams(params *ConsensusParams) *types.ConsensusParams { + return &types.ConsensusParams{ BlockSize: &types.BlockSize{ MaxBytes: int32(params.BlockSize.MaxBytes),