Skip to content

Commit

Permalink
#197 Error on replay with wrong app hash calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
hleb-albau authored and arturalbov committed Jan 29, 2019
1 parent 3356025 commit f4d4872
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
14 changes: 7 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type CyberdApp struct {
mainKeeper store.MainKeeper
accountKeeper auth.AccountKeeper
feeCollectionKeeper auth.FeeCollectionKeeper
bankKeeper cbdbank.Keeper
bankKeeper *cbdbank.Keeper
stakingKeeper staking.Keeper
slashingKeeper slashing.Keeper
distrKeeper distr.Keeper
Expand All @@ -78,7 +78,7 @@ type CyberdApp struct {
// cyberd storage
linkIndexedKeeper *keeper.LinkIndexedKeeper
cidNumKeeper keeper.CidNumberKeeper
stakeIndex *cbdbank.IndexedKeeper
stakingIndex *cbdbank.IndexedKeeper
rankState *rank.RankState

latestBlockHeight int64
Expand Down Expand Up @@ -151,9 +151,9 @@ func NewCyberdApp(
// cyberd keepers
app.linkIndexedKeeper = keeper.NewLinkIndexedKeeper(keeper.NewBaseLinkKeeper(ms, dbKeys.links))
app.cidNumKeeper = keeper.NewBaseCidNumberKeeper(ms, dbKeys.cidNum, dbKeys.cidNumReverse)
app.stakeIndex = cbdbank.NewIndexedKeeper(&app.bankKeeper, app.accountKeeper)
app.stakingIndex = cbdbank.NewIndexedKeeper(app.bankKeeper, app.accountKeeper)
app.rankState = rank.NewRankState(
allowSearch, app.mainKeeper, app.stakeIndex,
allowSearch, app.mainKeeper, app.stakingIndex,
app.linkIndexedKeeper, app.cidNumKeeper, computeUnit,
)

Expand Down Expand Up @@ -209,7 +209,7 @@ func NewCyberdApp(
start := time.Now()
app.BaseApp.Logger.Info("Loading mem state")
app.linkIndexedKeeper.Load(rankCtx, ctx)
app.stakeIndex.Load(rankCtx, ctx)
app.stakingIndex.Load(rankCtx, ctx)
app.BaseApp.Logger.Info("App loaded", "time", time.Since(start))

// BANDWIDTH LOAD
Expand Down Expand Up @@ -242,7 +242,7 @@ func (app *CyberdApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) ab
acc := gacc.ToAccount()
acc.AccountNumber = app.accountKeeper.GetNextAccountNumber(ctx)
app.accountKeeper.SetAccount(ctx, acc)
app.stakeIndex.UpdateStake(types.AccNumber(acc.AccountNumber), acc.Coins.AmountOf(coin.CYB).Int64())
app.stakingIndex.UpdateStake(types.AccNumber(acc.AccountNumber), acc.Coins.AmountOf(coin.CYB).Int64())
}

// initialize distribution (must happen before staking)
Expand Down Expand Up @@ -452,7 +452,7 @@ func (app *CyberdApp) EndBlocker(ctx sdk.Context, _ abci.RequestEndBlock) abci.R
app.mainKeeper.StoreLatestBlockNumber(ctx, uint64(ctx.BlockHeight()))

validatorUpdates, tags := staking.EndBlocker(ctx, app.stakingKeeper)
app.stakeIndex.EndBlocker(ctx)
app.stakingIndex.EndBlocker(ctx)

bandwidth.EndBlocker(ctx, app.bandwidthMeter)

Expand Down
2 changes: 1 addition & 1 deletion daemon/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func initTestnet(config *tmconfig.Config, cdc *codec.Codec) error {

accs = append(accs, app.GenesisAccount{
Address: addr,
Amount: 10000000000000000,
Amount: 20000000000000000,
})

msg := staking.NewMsgCreateValidator(
Expand Down
2 changes: 1 addition & 1 deletion types/coin/coins.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package coin

const (
CYB = "сyb"
CYB = "cyb"
)
3 changes: 0 additions & 3 deletions x/bank/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ type IndexedKeeper struct {
func NewIndexedKeeper(keeper *Keeper, accKeeper auth.AccountKeeper) *IndexedKeeper {
index := IndexedKeeper{Keeper: *keeper, accKeeper: accKeeper, accsToUpdate: make([]sdk.AccAddress, 0)}
hook := func(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress) {
if ctx.IsCheckTx() {
return
}
if from != nil {
index.accsToUpdate = append(index.accsToUpdate, from)
}
Expand Down
4 changes: 2 additions & 2 deletions x/bank/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ type Keeper struct {
coinsTransferHooks []CoinsTransferHook
}

func NewBankKeeper(ak auth.AccountKeeper, sk *staking.Keeper) Keeper {
return Keeper{
func NewBankKeeper(ak auth.AccountKeeper, sk *staking.Keeper) *Keeper {
return &Keeper{
Keeper: bank.NewBaseKeeper(ak),
ak: ak,
sk: sk,
Expand Down

0 comments on commit f4d4872

Please sign in to comment.