Skip to content

Commit

Permalink
Remove absent validators from sdk.NewContext
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes committed May 29, 2018
1 parent f4f8cc6 commit aed5d94
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 31 deletions.
8 changes: 4 additions & 4 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ func (app *BaseApp) initFromStore(mainKey sdk.StoreKey) error {
// NewContext returns a new Context with the correct store, the given header, and nil txBytes.
func (app *BaseApp) NewContext(isCheckTx bool, header abci.Header) sdk.Context {
if isCheckTx {
return sdk.NewContext(app.checkState.ms, header, true, nil, app.Logger, nil)
return sdk.NewContext(app.checkState.ms, header, true, nil, app.Logger)
}
return sdk.NewContext(app.deliverState.ms, header, false, nil, app.Logger, nil)
return sdk.NewContext(app.deliverState.ms, header, false, nil, app.Logger)
}

type state struct {
Expand All @@ -253,15 +253,15 @@ func (app *BaseApp) setCheckState(header abci.Header) {
ms := app.cms.CacheMultiStore()
app.checkState = &state{
ms: ms,
ctx: sdk.NewContext(ms, header, true, nil, app.Logger, nil),
ctx: sdk.NewContext(ms, header, true, nil, app.Logger),
}
}

func (app *BaseApp) setDeliverState(header abci.Header) {
ms := app.cms.CacheMultiStore()
app.deliverState = &state{
ms: ms,
ctx: sdk.NewContext(ms, header, false, nil, app.Logger, nil),
ctx: sdk.NewContext(ms, header, false, nil, app.Logger),
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/democoin/x/cool/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestCoolKeeper(t *testing.T) {
auth.RegisterBaseAccount(cdc)

am := auth.NewAccountMapper(cdc, capKey, &auth.BaseAccount{})
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, nil, nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, nil)
ck := bank.NewKeeper(am)
keeper := NewKeeper(capKey, ck, DefaultCodespace)

Expand Down
2 changes: 1 addition & 1 deletion examples/democoin/x/pow/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestPowHandler(t *testing.T) {
auth.RegisterBaseAccount(cdc)

am := auth.NewAccountMapper(cdc, capKey, &auth.BaseAccount{})
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
config := NewConfig("pow", int64(1))
ck := bank.NewKeeper(am)
keeper := NewKeeper(capKey, config, ck, DefaultCodespace)
Expand Down
2 changes: 1 addition & 1 deletion examples/democoin/x/pow/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestPowKeeperGetSet(t *testing.T) {
auth.RegisterBaseAccount(cdc)

am := auth.NewAccountMapper(cdc, capKey, &auth.BaseAccount{})
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
config := NewConfig("pow", int64(1))
ck := bank.NewKeeper(am)
keeper := NewKeeper(capKey, config, ck, DefaultCodespace)
Expand Down
4 changes: 2 additions & 2 deletions examples/democoin/x/simplestake/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestKeeperGetSet(t *testing.T) {

accountMapper := auth.NewAccountMapper(cdc, authKey, &auth.BaseAccount{})
stakeKeeper := NewKeeper(capKey, bank.NewKeeper(accountMapper), DefaultCodespace)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
addr := sdk.Address([]byte("some-address"))

bi := stakeKeeper.getBondInfo(ctx, addr)
Expand All @@ -63,7 +63,7 @@ func TestBonding(t *testing.T) {
cdc := wire.NewCodec()
auth.RegisterBaseAccount(cdc)

ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())

accountMapper := auth.NewAccountMapper(cdc, authKey, &auth.BaseAccount{})
coinKeeper := bank.NewKeeper(accountMapper)
Expand Down
5 changes: 2 additions & 3 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ type Context struct {
}

// create a new context
func NewContext(ms MultiStore, header abci.Header, isCheckTx bool,
txBytes []byte, logger log.Logger, absentValidators [][]byte) Context {
func NewContext(ms MultiStore, header abci.Header, isCheckTx bool, txBytes []byte, logger log.Logger) Context {

c := Context{
Context: context.Background(),
Expand All @@ -45,7 +44,7 @@ func NewContext(ms MultiStore, header abci.Header, isCheckTx bool,
c = c.WithIsCheckTx(isCheckTx)
c = c.WithTxBytes(txBytes)
c = c.WithLogger(logger)
c = c.WithAbsentValidators(absentValidators)
c = c.WithAbsentValidators(nil)
c = c.WithGasMeter(NewInfiniteGasMeter())
return c
}
Expand Down
4 changes: 2 additions & 2 deletions types/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (l MockLogger) With(kvs ...interface{}) log.Logger {

func TestContextGetOpShouldNeverPanic(t *testing.T) {
var ms types.MultiStore
ctx := types.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := types.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
indices := []int64{
-10, 1, 0, 10, 20,
}
Expand All @@ -58,7 +58,7 @@ func defaultContext(key types.StoreKey) types.Context {
cms := store.NewCommitMultiStore(db)
cms.MountStoreWithDB(key, types.StoreTypeIAVL, db)
cms.LoadLatestVersion()
ctx := types.NewContext(cms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := types.NewContext(cms, abci.Header{}, false, nil, log.NewNopLogger())
return ctx
}

Expand Down
2 changes: 1 addition & 1 deletion types/lib/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func defaultComponents(key sdk.StoreKey) (sdk.Context, *wire.Codec) {
cms := store.NewCommitMultiStore(db)
cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db)
cms.LoadLatestVersion()
ctx := sdk.NewContext(cms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(cms, abci.Header{}, false, nil, log.NewNopLogger())
cdc := wire.NewCodec()
return ctx, cdc
}
Expand Down
10 changes: 5 additions & 5 deletions x/auth/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestAnteHandlerSigErrors(t *testing.T) {
mapper := NewAccountMapper(cdc, capKey, &BaseAccount{})
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
anteHandler := NewAnteHandler(mapper, feeCollector)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger())

// keys and addresses
priv1, addr1 := privAndAddr()
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestAnteHandlerSequences(t *testing.T) {
mapper := NewAccountMapper(cdc, capKey, &BaseAccount{})
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
anteHandler := NewAnteHandler(mapper, feeCollector)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger())

// keys and addresses
priv1, addr1 := privAndAddr()
Expand Down Expand Up @@ -184,7 +184,7 @@ func TestAnteHandlerFees(t *testing.T) {
mapper := NewAccountMapper(cdc, capKey, &BaseAccount{})
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
anteHandler := NewAnteHandler(mapper, feeCollector)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger())

// keys and addresses
priv1, addr1 := privAndAddr()
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestAnteHandlerBadSignBytes(t *testing.T) {
mapper := NewAccountMapper(cdc, capKey, &BaseAccount{})
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
anteHandler := NewAnteHandler(mapper, feeCollector)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger())

// keys and addresses
priv1, addr1 := privAndAddr()
Expand Down Expand Up @@ -302,7 +302,7 @@ func TestAnteHandlerSetPubKey(t *testing.T) {
mapper := NewAccountMapper(cdc, capKey, &BaseAccount{})
feeCollector := NewFeeCollectionKeeper(cdc, capKey2)
anteHandler := NewAnteHandler(mapper, feeCollector)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger())

// keys and addresses
priv1, addr1 := privAndAddr()
Expand Down
2 changes: 1 addition & 1 deletion x/auth/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func TestContextWithSigners(t *testing.T) {
ms, _, _ := setupMultiStore()
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger())

_, _, addr1 := keyPubAddr()
_, _, addr2 := keyPubAddr()
Expand Down
6 changes: 3 additions & 3 deletions x/auth/feekeeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestFeeCollectionKeeperGetSet(t *testing.T) {
cdc := wire.NewCodec()

// make context and keeper
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
fck := NewFeeCollectionKeeper(cdc, capKey2)

// no coins initially
Expand All @@ -42,7 +42,7 @@ func TestFeeCollectionKeeperAdd(t *testing.T) {
cdc := wire.NewCodec()

// make context and keeper
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
fck := NewFeeCollectionKeeper(cdc, capKey2)

// no coins initially
Expand All @@ -62,7 +62,7 @@ func TestFeeCollectionKeeperClear(t *testing.T) {
cdc := wire.NewCodec()

// make context and keeper
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
fck := NewFeeCollectionKeeper(cdc, capKey2)

// set coins initially
Expand Down
2 changes: 1 addition & 1 deletion x/auth/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestAccountMapperGetSet(t *testing.T) {
RegisterBaseAccount(cdc)

// make context and mapper
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
mapper := NewAccountMapper(cdc, capKey, &BaseAccount{})

addr := sdk.Address([]byte("some-address"))
Expand Down
6 changes: 3 additions & 3 deletions x/bank/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestKeeper(t *testing.T) {
cdc := wire.NewCodec()
auth.RegisterBaseAccount(cdc)

ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
accountMapper := auth.NewAccountMapper(cdc, authKey, &auth.BaseAccount{})
coinKeeper := NewKeeper(accountMapper)

Expand Down Expand Up @@ -116,7 +116,7 @@ func TestSendKeeper(t *testing.T) {
cdc := wire.NewCodec()
auth.RegisterBaseAccount(cdc)

ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
accountMapper := auth.NewAccountMapper(cdc, authKey, &auth.BaseAccount{})
coinKeeper := NewKeeper(accountMapper)
sendKeeper := NewSendKeeper(accountMapper)
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestViewKeeper(t *testing.T) {
cdc := wire.NewCodec()
auth.RegisterBaseAccount(cdc)

ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
accountMapper := auth.NewAccountMapper(cdc, authKey, &auth.BaseAccount{})
coinKeeper := NewKeeper(accountMapper)
viewKeeper := NewViewKeeper(accountMapper)
Expand Down
2 changes: 1 addition & 1 deletion x/ibc/ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func defaultContext(key sdk.StoreKey) sdk.Context {
cms := store.NewCommitMultiStore(db)
cms.MountStoreWithDB(key, sdk.StoreTypeIAVL, db)
cms.LoadLatestVersion()
ctx := sdk.NewContext(cms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(cms, abci.Header{}, false, nil, log.NewNopLogger())
return ctx
}

Expand Down
2 changes: 1 addition & 1 deletion x/slashing/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func createTestInput(t *testing.T) (sdk.Context, bank.Keeper, stake.Keeper, Keep
ms.MountStoreWithDB(keySlashing, sdk.StoreTypeIAVL, db)
err := ms.LoadLatestVersion()
require.Nil(t, err)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewTMLogger(os.Stdout), nil)
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewTMLogger(os.Stdout))
cdc := createTestCodec()
accountMapper := auth.NewAccountMapper(cdc, keyAcc, &auth.BaseAccount{})
ck := bank.NewKeeper(accountMapper)
Expand Down
2 changes: 1 addition & 1 deletion x/stake/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func createTestInput(t *testing.T, isCheckTx bool, initCoins int64) (sdk.Context
err := ms.LoadLatestVersion()
require.Nil(t, err)

ctx := sdk.NewContext(ms, abci.Header{ChainID: "foochainid"}, isCheckTx, nil, log.NewNopLogger(), nil)
ctx := sdk.NewContext(ms, abci.Header{ChainID: "foochainid"}, isCheckTx, nil, log.NewNopLogger())
cdc := makeTestCodec()
accountMapper := auth.NewAccountMapper(
cdc, // amino codec
Expand Down

0 comments on commit aed5d94

Please sign in to comment.