Skip to content

Commit

Permalink
F/rewards generation e2e (#63)
Browse files Browse the repository at this point in the history
babylon-contract v0.11 integration
  • Loading branch information
maurolacy authored Nov 26, 2024
1 parent 47b0a3e commit 97c3c30
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 3 deletions.
4 changes: 4 additions & 0 deletions demo/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
appparams "github.com/babylonlabs-io/babylon-sdk/demo/app/params"
appwasm "github.com/babylonlabs-io/babylon-sdk/demo/app/wasm"
abci "github.com/cometbft/cometbft/abci/types"
tmos "github.com/cometbft/cometbft/libs/os"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
Expand Down Expand Up @@ -492,6 +493,9 @@ func NewConsumerApp(
// add support for the custom queries
wasmkeeper.WithQueryHandlerDecorator(bbnkeeper.NewQueryDecorator(app.BabylonKeeper)),
)
// Add grpc query support for the whitelisted grpc queries
wasmOpts = append(wasmOpts, appwasm.RegisterGrpcQueries(bApp, appCodec)...)

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
availableCapabilities := AllCapabilities()
Expand Down
1 change: 1 addition & 0 deletions demo/app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func setup(t testing.TB, chainID string, withGenesis bool, invCheckPeriod uint,

appOptions := make(simsutils.AppOptionsMap, 0)
appOptions[flags.FlagHome] = nodeHome // ensure unique folder
appOptions[server.FlagTrace] = true
appOptions[server.FlagInvCheckPeriod] = invCheckPeriod
app := NewConsumerApp(log.NewNopLogger(), db, nil, true, appOptions, opts, bam.SetChainID(chainID), bam.SetSnapshot(snapshotStore, snapshottypes.SnapshotOptions{KeepRecent: 2}))
if withGenesis {
Expand Down
29 changes: 29 additions & 0 deletions demo/app/wasm/grpc_whitelist.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package wasm

import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)

func RegisterGrpcQueries(bApp *baseapp.BaseApp, appCodec codec.Codec) []wasmkeeper.Option {
queryRouter := bApp.GRPCQueryRouter()
queryPluginOpt := wasmkeeper.WithQueryPlugins(
&wasmkeeper.QueryPlugins{
Stargate: wasmkeeper.AcceptListStargateQuerier(WhitelistedGrpcQuery(), queryRouter, appCodec),
Grpc: wasmkeeper.AcceptListGrpcQuerier(WhitelistedGrpcQuery(), queryRouter, appCodec),
})

return []wasmkeeper.Option{
queryPluginOpt,
}
}

// WhitelistedGrpcQuery returns the whitelisted Grpc queries
func WhitelistedGrpcQuery() wasmkeeper.AcceptedQueries {
return wasmkeeper.AcceptedQueries{
// mint
"/cosmos.mint.v1beta1.Query/Params": &minttypes.QueryParamsResponse{},
}
}
2 changes: 1 addition & 1 deletion tests/scripts/copy_local_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -o errexit -o nounset -o pipefail
command -v shellcheck >/dev/null && shellcheck "$0"

CONTRACTS="babylon_contract btc_staking"
CONTRACTS="babylon_contract btc_staking btc_finality"
OUTPUT_FOLDER="$(dirname "$0")/../testdata"

echo "DEV-only: copy from local built instead of downloading"
Expand Down
Binary file modified tests/testdata/babylon_contract.wasm
Binary file not shown.
Binary file modified tests/testdata/btc_finality.wasm
Binary file not shown.
Binary file modified tests/testdata/btc_staking.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testdata/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.10.0-rc.0
v0.11.0-rc.1
3 changes: 2 additions & 1 deletion x/babylon/keeper/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/hex"
"encoding/json"
"fmt"

errorsmod "cosmossdk.io/errors"
"github.com/babylonlabs-io/babylon-sdk/x/babylon/contract"
Expand Down Expand Up @@ -113,6 +114,6 @@ func (k Keeper) doSudoCall(ctx sdk.Context, contractAddr sdk.AccAddress, msg con
return errorsmod.Wrap(err, "marshal sudo msg")
}
resp, err := k.wasm.Sudo(ctx, contractAddr, bz)
k.Logger(ctx).Debug("response of sudo call %v to contract %s: %v", bz, contractAddr.String(), resp)
k.Logger(ctx).Debug(fmt.Sprintf("response of sudo call %v to contract %s: %v", bz, contractAddr.String(), resp))
return err
}

0 comments on commit 97c3c30

Please sign in to comment.