Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: apply the changes of lbm-sdk and ostracon proto #9

Merged
merged 4 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## [Unreleased](https://github.com/line/wasmd/tree/HEAD)

### Features
* [\#9](https://github.com/line/wasmd/pull/9) apply the changes of lbm-sdk and ostracon proto

### Improvements
* [\#1](https://github.com/line/wasmd/pull/1) apply all changes of `x/wasm` in lbm-sdk until [lbm-sdk@3bdcb6ffe01c81615bedb777ca0e039cc46ef00c](https://github.com/line/lbm-sdk/tree/3bdcb6ffe01c81615bedb777ca0e039cc46ef00c)
* [\#5](https://github.com/line/wasmd/pull/5) bump up wasmd v0.29.1
Expand Down
10 changes: 5 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

ica "github.com/line/ibc-go/v3/modules/apps/27-interchain-accounts"
Expand All @@ -30,6 +32,7 @@ import (
porttypes "github.com/line/ibc-go/v3/modules/core/05-port/types"
ibchost "github.com/line/ibc-go/v3/modules/core/24-host"
ibckeeper "github.com/line/ibc-go/v3/modules/core/keeper"
ocabci "github.com/line/ostracon/abci/types"

"github.com/line/lbm-sdk/baseapp"
"github.com/line/lbm-sdk/client"
Expand Down Expand Up @@ -98,12 +101,9 @@ import (
upgradeclient "github.com/line/lbm-sdk/x/upgrade/client"
upgradekeeper "github.com/line/lbm-sdk/x/upgrade/keeper"
upgradetypes "github.com/line/lbm-sdk/x/upgrade/types"
abci "github.com/line/ostracon/abci/types"
tmjson "github.com/line/ostracon/libs/json"
"github.com/line/ostracon/libs/log"
tmos "github.com/line/ostracon/libs/os"
ocproto "github.com/line/ostracon/proto/ostracon/types"

wasmappparams "github.com/line/wasmd/app/params"
"github.com/line/wasmd/x/wasm"
wasmclient "github.com/line/wasmd/x/wasm/client"
Expand Down Expand Up @@ -751,7 +751,7 @@ func NewWasmApp(
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(fmt.Sprintf("failed to load latest version: %s", err))
}
ctx := app.BaseApp.NewUncachedContext(true, ocproto.Header{})
ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{})

// Initialize pinned codes in wasmvm as they are not persisted there
if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil {
Expand All @@ -778,7 +778,7 @@ func (app *WasmApp) ModuleConfigurator() module.Configurator {
}

// BeginBlocker application updates every begin block
func (app *WasmApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
func (app *WasmApp) BeginBlocker(ctx sdk.Context, req ocabci.RequestBeginBlock) abci.ResponseBeginBlock {
return app.mm.BeginBlock(ctx, req)
}

Expand Down
2 changes: 1 addition & 1 deletion app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
db "github.com/tendermint/tm-db"

abci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/libs/log"

"github.com/line/wasmd/x/wasm"
Expand Down
5 changes: 3 additions & 2 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"encoding/json"
"log"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

servertypes "github.com/line/lbm-sdk/server/types"
sdk "github.com/line/lbm-sdk/types"
slashingtypes "github.com/line/lbm-sdk/x/slashing/types"
"github.com/line/lbm-sdk/x/staking"
stakingtypes "github.com/line/lbm-sdk/x/staking/types"
ocproto "github.com/line/ostracon/proto/ostracon/types"
)

// ExportAppStateAndValidators exports the state of the application for a genesis
Expand All @@ -18,7 +19,7 @@ func (app *WasmApp) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string,
) (servertypes.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, ocproto.Header{Height: app.LastBlockHeight()})
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})

// We export at last height + 1, because that's the height at which
// Tendermint will start InitChain.
Expand Down
11 changes: 5 additions & 6 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import (
"testing"
"time"

"github.com/line/lbm-sdk/store"
"github.com/line/lbm-sdk/store/prefix"

"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

ibctransfertypes "github.com/line/ibc-go/v3/modules/apps/transfer/types"
ibchost "github.com/line/ibc-go/v3/modules/core/24-host"
"github.com/line/lbm-sdk/baseapp"
"github.com/line/lbm-sdk/codec"
"github.com/line/lbm-sdk/simapp"
"github.com/line/lbm-sdk/store"
"github.com/line/lbm-sdk/store/prefix"
sdk "github.com/line/lbm-sdk/types"
"github.com/line/lbm-sdk/types/kv"
"github.com/line/lbm-sdk/types/module"
Expand All @@ -37,7 +37,6 @@ import (
slashingtypes "github.com/line/lbm-sdk/x/slashing/types"
stakingtypes "github.com/line/lbm-sdk/x/staking/types"
"github.com/line/ostracon/libs/log"
ocproto "github.com/line/ostracon/proto/ostracon/types"

"github.com/line/wasmd/x/wasm"
wasmtypes "github.com/line/wasmd/x/wasm/types"
Expand Down Expand Up @@ -163,8 +162,8 @@ func TestAppImportExport(t *testing.T) {
err = json.Unmarshal(exported.AppState, &genesisState)
require.NoError(t, err)

ctxA := app.NewContext(true, ocproto.Header{Height: app.LastBlockHeight()})
ctxB := newApp.NewContext(true, ocproto.Header{Height: app.LastBlockHeight()})
ctxA := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
ctxB := newApp.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
newApp.mm.InitGenesis(ctxB, app.AppCodec(), genesisState)
newApp.StoreConsensusParams(ctxB, exported.ConsensusParams)

Expand Down
21 changes: 11 additions & 10 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"time"

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

bam "github.com/line/lbm-sdk/baseapp"
Expand All @@ -28,9 +30,8 @@ import (
banktypes "github.com/line/lbm-sdk/x/bank/types"
minttypes "github.com/line/lbm-sdk/x/mint/types"
stakingtypes "github.com/line/lbm-sdk/x/staking/types"
abci "github.com/line/ostracon/abci/types"
ocabci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/libs/log"
ocproto "github.com/line/ostracon/proto/ostracon/types"
tmtypes "github.com/line/ostracon/types"

"github.com/line/wasmd/x/wasm"
Expand All @@ -43,12 +44,12 @@ var DefaultConsensusParams = &abci.ConsensusParams{
MaxBytes: 8000000,
MaxGas: 1234000000,
},
Evidence: &ocproto.EvidenceParams{
Evidence: &tmproto.EvidenceParams{
MaxAgeNumBlocks: 302400,
MaxAgeDuration: 504 * time.Hour, // 3 weeks is the max duration
MaxBytes: 10000,
},
Validator: &ocproto.ValidatorParams{
Validator: &tmproto.ValidatorParams{
PubKeyTypes: []string{
tmtypes.ABCIPubKeyTypeEd25519,
},
Expand Down Expand Up @@ -166,7 +167,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs

// commit genesis changes
app.Commit()
app.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{
Height: app.LastBlockHeight() + 1,
AppHash: app.LastCommitID().Hash,
ValidatorsHash: valSet.Hash(),
Expand Down Expand Up @@ -303,7 +304,7 @@ func TestAddr(addr string, bech string) (sdk.AccAddress, error) {

// CheckBalance checks the balance of an account.
func CheckBalance(t *testing.T, app *WasmApp, addr sdk.AccAddress, balances sdk.Coins) {
ctxCheck := app.BaseApp.NewContext(true, ocproto.Header{})
ctxCheck := app.BaseApp.NewContext(true, tmproto.Header{})
require.True(t, balances.IsEqual(app.BankKeeper.GetAllBalances(ctxCheck, addr)))
}

Expand All @@ -314,7 +315,7 @@ const DefaultGas = 1200000
// the parameter 'expPass' against the result. A corresponding result is
// returned.
func SignCheckDeliver(
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header ocproto.Header, msgs []sdk.Msg,
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg,
chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, error) {
tx, err := helpers.GenTx(
Expand Down Expand Up @@ -343,7 +344,7 @@ func SignCheckDeliver(
}

// Simulate a sending a transaction and committing a block
app.BeginBlock(abci.RequestBeginBlock{Header: header})
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
gInfo, res, err := app.Deliver(txCfg.TxEncoder(), tx)

if expPass {
Expand All @@ -363,7 +364,7 @@ func SignCheckDeliver(
// SignAndDeliver signs and delivers a transaction. No simulation occurs as the
// ibc testing package causes checkState and deliverState to diverge in block time.
func SignAndDeliver(
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header ocproto.Header, msgs []sdk.Msg,
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg,
chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, error) {
tx, err := helpers.GenTx(
Expand All @@ -379,7 +380,7 @@ func SignAndDeliver(
require.NoError(t, err)

// Simulate a sending a transaction and committing a block
app.BeginBlock(abci.RequestBeginBlock{Header: header})
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
gInfo, res, err := app.Deliver(txCfg.TxEncoder(), tx)

if expPass {
Expand Down
11 changes: 5 additions & 6 deletions appplus/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

ica "github.com/line/ibc-go/v3/modules/apps/27-interchain-accounts"
Expand Down Expand Up @@ -98,15 +100,12 @@ import (
upgradeclient "github.com/line/lbm-sdk/x/upgrade/client"
upgradekeeper "github.com/line/lbm-sdk/x/upgrade/keeper"
upgradetypes "github.com/line/lbm-sdk/x/upgrade/types"
abci "github.com/line/ostracon/abci/types"
ocabci "github.com/line/ostracon/abci/types"
tmjson "github.com/line/ostracon/libs/json"
"github.com/line/ostracon/libs/log"
tmos "github.com/line/ostracon/libs/os"
ocproto "github.com/line/ostracon/proto/ostracon/types"

// unnamed import of statik for swagger UI support
wasmapp "github.com/line/wasmd/app"

wasmappparams "github.com/line/wasmd/app/params"
"github.com/line/wasmd/x/wasm"
wasmclient "github.com/line/wasmd/x/wasm/client"
Expand Down Expand Up @@ -747,7 +746,7 @@ func NewWasmApp(
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(fmt.Sprintf("failed to load latest version: %s", err))
}
ctx := app.BaseApp.NewUncachedContext(true, ocproto.Header{})
ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{})

// Initialize pinned codes in wasmvm as they are not persisted there
if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil {
Expand All @@ -774,7 +773,7 @@ func (app *WasmPlusApp) ModuleConfigurator() module.Configurator {
}

// BeginBlocker application updates every begin block
func (app *WasmPlusApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
func (app *WasmPlusApp) BeginBlocker(ctx sdk.Context, req ocabci.RequestBeginBlock) abci.ResponseBeginBlock {
return app.mm.BeginBlock(ctx, req)
}

Expand Down
13 changes: 7 additions & 6 deletions appplus/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ package appplus

import (
"encoding/json"
"github.com/line/lbm-sdk/server"
wasmapp "github.com/line/wasmd/app"
wasmkeeper "github.com/line/wasmd/x/wasm/keeper"
wasmtypes "github.com/line/wasmd/x/wasm/types"
wasmplustypes "github.com/line/wasmd/x/wasmplus/types"
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
db "github.com/tendermint/tm-db"

abci "github.com/line/ostracon/abci/types"
"github.com/line/lbm-sdk/server"
"github.com/line/ostracon/libs/log"

wasmapp "github.com/line/wasmd/app"
wasmkeeper "github.com/line/wasmd/x/wasm/keeper"
wasmtypes "github.com/line/wasmd/x/wasm/types"
wasmplustypes "github.com/line/wasmd/x/wasmplus/types"
)

var emptyWasmOpts []wasmkeeper.Option = nil
Expand Down
5 changes: 3 additions & 2 deletions appplus/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"encoding/json"
"log"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

servertypes "github.com/line/lbm-sdk/server/types"
sdk "github.com/line/lbm-sdk/types"
slashingtypes "github.com/line/lbm-sdk/x/slashing/types"
"github.com/line/lbm-sdk/x/staking"
stakingtypes "github.com/line/lbm-sdk/x/staking/types"
ocproto "github.com/line/ostracon/proto/ostracon/types"
)

// ExportAppStateAndValidators exports the state of the application for a genesis
Expand All @@ -18,7 +19,7 @@ func (app *WasmPlusApp) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string,
) (servertypes.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, ocproto.Header{Height: app.LastBlockHeight()})
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})

// We export at last height + 1, because that's the height at which
// Tendermint will start InitChain.
Expand Down
4 changes: 2 additions & 2 deletions appplus/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package appplus

import (
"encoding/json"
abci "github.com/line/ostracon/abci/types"
"github.com/stretchr/testify/require"
"os"
"testing"

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
db "github.com/tendermint/tm-db"

"github.com/line/ostracon/libs/log"
Expand Down
7 changes: 4 additions & 3 deletions appplus/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package appplus
import (
"encoding/json"

wasmapp "github.com/line/wasmd/app"
abci "github.com/tendermint/tendermint/abci/types"
dbm "github.com/tendermint/tm-db"

abci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/libs/log"

wasmapp "github.com/line/wasmd/app"
"github.com/line/wasmd/x/wasm"
dbm "github.com/tendermint/tm-db"
)

// Setup initializes a new WasmApp with DefaultNodeHome for integration tests
Expand Down
9 changes: 5 additions & 4 deletions benchmarks/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"time"

"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/line/lbm-sdk/client"
Expand All @@ -15,9 +17,8 @@ import (
sdk "github.com/line/lbm-sdk/types"
authtypes "github.com/line/lbm-sdk/x/auth/types"
banktypes "github.com/line/lbm-sdk/x/bank/types"
abci "github.com/line/ostracon/abci/types"
ocabci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/libs/log"
ocproto "github.com/line/ostracon/proto/ostracon/types"

"github.com/line/wasmd/app"
wasmappparams "github.com/line/wasmd/app/params"
Expand Down Expand Up @@ -65,7 +66,7 @@ func SetupWithGenesisAccounts(b testing.TB, db dbm.DB, genAccs []authtypes.Genes
)

wasmApp.Commit()
wasmApp.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{Height: wasmApp.LastBlockHeight() + 1}})
wasmApp.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: wasmApp.LastBlockHeight() + 1}})

return wasmApp
}
Expand Down Expand Up @@ -115,7 +116,7 @@ func InitializeWasmApp(b testing.TB, db dbm.DB, numAccounts int) AppInfo {
// add wasm contract
height := int64(2)
txGen := wasmappparams.MakeEncodingConfig().TxConfig
wasmApp.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{Height: height, Time: time.Now()}})
wasmApp.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: height, Time: time.Now()}})

// upload the code
cw20Code, err := os.ReadFile("./testdata/cw20_base.wasm")
Expand Down
Loading