Skip to content

Commit

Permalink
feat!: apply the changes of lbm-sdk and ostracon proto (#9)
Browse files Browse the repository at this point in the history
* feat!: apply the changes of lbm-sdk and ostracon proto
- base lbm-sdk commit: b8864730859710d92a83f9f91289d4c6aef658cd

* chore: remove debug comments.

* chore: update changelog

* chore: update line/ibc-go commit
  • Loading branch information
zemyblue authored Feb 10, 2023
1 parent e0d9c95 commit 9104d00
Show file tree
Hide file tree
Showing 80 changed files with 1,364 additions and 19,276 deletions.
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

0 comments on commit 9104d00

Please sign in to comment.