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

refactor(wasmbinding)!: remove wasmbinding custom executors #1766

Merged
merged 6 commits into from
Jan 8, 2024
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
29 changes: 15 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1712](https://github.com/NibiruChain/nibiru/pull/1712) - refactor(inflation): turn inflation off by default
* [#1713](https://github.com/NibiruChain/nibiru/pull/1713) - chore(build-release): use new rocksdb libraries and link required libs
* [#1715](https://github.com/NibiruChain/nibiru/pull/1715) - fix(build): revert! to working build + cherry-picks
* [#1731](https://github.com/NibiruChain/nibiru/pull/1731) - feat(cli): add cli command to decode stargate base64 messages
* [#1766](https://github.com/NibiruChain/nibiru/pull/1766) - refactor(app-wasmext)!: remove wasmbinding `CosmosMsg::Custom` bindings.

#### Dapp modules: perp, spot, etc

* [#1687](https://github.com/NibiruChain/nibiru/pull/1687) - chore(wasmbinding): delete CustomQuerier since we have QueryRequest::Stargate now
* [#1686](https://github.com/NibiruChain/nibiru/pull/1686) - test(perp): add more tests for perp module msg server for DnR
* [#1683](https://github.com/NibiruChain/nibiru/pull/1683) - feat(perp): Add `StartDnREpoch` to `AfterEpochEnd` hook
* [#1680](https://github.com/NibiruChain/nibiru/pull/1680) - feat(perp): MsgShiftPegMultiplier, MsgShiftSwapInvariant.
* [#1677](https://github.com/NibiruChain/nibiru/pull/1677) - fix(perp): make Gen_market set initial perp versions
* [#1669](https://github.com/NibiruChain/nibiru/pull/1669) - feat(perp): add query to get collateral metadata
* [#1663](https://github.com/NibiruChain/nibiru/pull/1663) - feat(perp): Add volume based rebates
* [#1656](https://github.com/NibiruChain/nibiru/pull/1656) - feat(perp): Make the collateral denom a stateful collections.Item
* [#1632](https://github.com/NibiruChain/nibiru/pull/1632) - feat(perp): Add settle position transaction
* [#1573](https://github.com/NibiruChain/nibiru/pull/1573) - feat(perp): Close markets and compute settlement price
* [#1632](https://github.com/NibiruChain/nibiru/pull/1632) - feat(perp): Add settle position transaction
* [#1656](https://github.com/NibiruChain/nibiru/pull/1656) - feat(perp): Make the collateral denom a stateful collections.Item
* [#1663](https://github.com/NibiruChain/nibiru/pull/1663) - feat(perp): Add volume based rebates
* [#1669](https://github.com/NibiruChain/nibiru/pull/1669) - feat(perp): add query to get collateral metadata
* [#1677](https://github.com/NibiruChain/nibiru/pull/1677) - fix(perp): make Gen_market set initial perp versions
* [#1680](https://github.com/NibiruChain/nibiru/pull/1680) - feat(perp): MsgShiftPegMultiplier, MsgShiftSwapInvariant.
* [#1683](https://github.com/NibiruChain/nibiru/pull/1683) - feat(perp): Add `StartDnREpoch` to `AfterEpochEnd` hook
* [#1686](https://github.com/NibiruChain/nibiru/pull/1686) - test(perp): add more tests for perp module msg server for DnR
* [#1687](https://github.com/NibiruChain/nibiru/pull/1687) - chore(wasmbinding): delete CustomQuerier since we have QueryRequest::Stargate now
* [#1705](https://github.com/NibiruChain/nibiru/pull/1705) - feat(perp): Add oracle pair to market object
* [#1718](https://github.com/NibiruChain/nibiru/pull/1718) - fix: fees does not require additional funds
* [#1734](https://github.com/NibiruChain/nibiru/pull/1734) - feat(perp): MsgDonateToPerpFund sudo call as part of #1642
* [#1749](https://github.com/NibiruChain/nibiru/pull/1749) - feat(perp): move close market from Wasm Binding to MsgCloseMarket
* [#1752](https://github.com/NibiruChain/nibiru/pull/1752) - feat(oracle): MsgEditOracleParams sudo tx msg as part of #1642
* [#1755](https://github.com/NibiruChain/nibiru/pull/1755) - feat(oracle): Add more events on validator's performance
* [#1749](https://github.com/NibiruChain/nibiru/pull/1749) - feat(perp): move close market from Wasm Binding to MsgCloseMarket
* [#1764](https://github.com/NibiruChain/nibiru/pull/1764) - fix(perp): make updateswapinvariant aware of total short supply to avoid panics


### Non-breaking/Compatible Improvements

* [#1690](https://github.com/NibiruChain/nibiru/pull/1690) - docs(CHANGELOG.md): Correct the change log, providing clarity on what's released.
* [#1679](https://github.com/NibiruChain/nibiru/pull/1679) - test(perp): add more tests for perp module msg server
* [#1690](https://github.com/NibiruChain/nibiru/pull/1690) - docs(CHANGELOG.md): Correct the change log, providing clarity on what's released.
* [#1695](https://github.com/NibiruChain/nibiru/pull/1695) - feat(inflation): add events for inflation distribution
* [#1695](https://github.com/NibiruChain/nibiru/pull/1695) - fix(sudo): Make blank sudoers root invalid at genesis time.
* [#1710](https://github.com/NibiruChain/nibiru/pull/1710) - refactor(perp): Clean and organize module errors for x/perp
* [#1714](https://github.com/NibiruChain/nibiru/pull/1714) - ci(localnet.sh): Fix script, simplify, and test in CI.
* [#1719](https://github.com/NibiruChain/nibiru/pull/1719) - refactor(test): add is not mandatory interface to action
* [#1723](https://github.com/NibiruChain/nibiru/pull/1723) - ci(e2e-wasm.yml): rm unused workflow
* [#1728](https://github.com/NibiruChain/nibiru/pull/1728) - test(devgas-cli): CLI tests for devgas txs
* [#1731](https://github.com/NibiruChain/nibiru/pull/1731) - feat(cli): add cli command to decode stargate base64 messages
* [#1735](https://github.com/NibiruChain/nibiru/pull/1735) - test(sim): fix simulation tests
* [#1754](https://github.com/NibiruChain/nibiru/pull/1754) - refactor(decode-base64): clean code improvements and fn docs
* [#1736](https://github.com/NibiruChain/nibiru/pull/1736) - test(sim): add sim genesis state for all cusom modules
* [#1764](https://github.com/NibiruChain/nibiru/pull/1764) - fix(perp): make updateswapinvariant aware of total short supply to avoid panics
* [#1754](https://github.com/NibiruChain/nibiru/pull/1754) - refactor(decode-base64): clean code improvements and fn docs

### Dependencies
- Bump `github.com/cometbft/cometbft-db` from 0.9.0 to 0.9.1 ([#1760](https://github.com/NibiruChain/nibiru/pull/1760))
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@

**Nibiru Chain** is a breakthrough smart contract platform providing superior throughput, reduced latency, and improved security, all driven by Web Assembly (Wasm) smart contracts.

- [⚙️ — Documentation](#%EF%B8%8F--documentation)
- [💬 — Community](#--community)
- [🧱 — Components of Nibiru](#--components-of-nibiru)
- [⛓️ — Building: `make` commands](#%EF%B8%8F--building-make-commands)
- [Nibid CLI](#nibid-cli)
- [Running a Local Node](#running-a-local-node)
- [Generate the protobufs](#generate-the-protobufs)
- [Linter](#linter)
- [Multiple Nodes](#multiple-nodes)
- [License](#license)
- [Nibiru Chain](#nibiru-chain)
- [⚙️ — Documentation](#️--documentation)
- [💬 — Community](#--community)
- [🧱 — Components of Nibiru](#--components-of-nibiru)
- [⛓️ — Building: `make` commands](#️--building-make-commands)
- [Nibid CLI](#nibid-cli)
- [Running a Local Node](#running-a-local-node)
- [Generate the protobufs](#generate-the-protobufs)
- [Linter](#linter)
- [Multiple Nodes](#multiple-nodes)
- [License](#license)

## ⚙️ — Documentation

Expand Down Expand Up @@ -66,7 +67,6 @@ If you have questions or concerns, feel free to connect with a developer or comm
[code-x-oracle]: https://github.com/NibiruChain/nibiru/tree/main/x/oracle
[code-x-perp]: https://github.com/NibiruChain/nibiru/tree/main/x/perp
[code-x-spot]: https://github.com/NibiruChain/nibiru/tree/main/x/spot
[code-x-wasm]: https://github.com/NibiruChain/nibiru/tree/main/wasmbinding

Nibiru is built with the [Cosmos-SDK][cosmos-sdk-repo] on [Tendermint Core](https://tendermint.com/core/) consensus and communicates with other blockchain chains using the [Inter-Blockchain Communication (IBC)](https://github.com/cosmos/ibc) protocol.

Expand Down
13 changes: 4 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

"github.com/NibiruChain/nibiru/app/wasmext"

dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
Expand Down Expand Up @@ -43,8 +46,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

wasmbinding "github.com/NibiruChain/nibiru/wasmbinding"
)

const (
Expand Down Expand Up @@ -115,16 +116,10 @@ func GetWasmOpts(nibiru NibiruApp, appOpts servertypes.AppOptions) []wasmkeeper.
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
}

// Add the bindings to the app's set of []wasmkeeper.Option.
wasmOpts = append(wasmOpts, wasmbinding.NibiruWasmOptions(
return append(wasmOpts, wasmext.NibiruWasmOptions(
nibiru.GRPCQueryRouter(),
nibiru.appCodec,
nibiru.PerpKeeperV2,
nibiru.SudoKeeper,
nibiru.OracleKeeper,
)...)

return wasmOpts
}

// NewNibiruApp returns a reference to an initialized NibiruApp.
Expand Down
1 change: 0 additions & 1 deletion app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ func (app *NibiruApp) InitKeepers(
govModuleAddr,
)

// TokenFactory has wasm bindings
app.TokenFactoryKeeper = tokenfactorykeeper.NewKeeper(
keys[tokenfactorytypes.StoreKey],
appCodec,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasmbinding
package wasmext

import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
Expand Down Expand Up @@ -140,9 +140,5 @@ func WasmAcceptedStargateQueries() wasmkeeper.AcceptedStargateQueries {
"/nibiru.devgas.v1.Query/FeeShare": new(devgas.QueryFeeShareResponse),
"/nibiru.devgas.v1.Query/Params": new(devgas.QueryParamsResponse),
"/nibiru.devgas.v1.Query/FeeSharesByWithdrawer": new(devgas.QueryFeeSharesByWithdrawerResponse),

// TODO: for post v1
// nibiru.perp
// nibiru.spot
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasmbinding_test
package wasmext_test

import (
"fmt"
Expand All @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"

"github.com/NibiruChain/nibiru/wasmbinding"
wasmbinding "github.com/NibiruChain/nibiru/app/wasmext"

"github.com/NibiruChain/nibiru/x/common/set"

Expand Down
16 changes: 2 additions & 14 deletions wasmbinding/wasm.go → app/wasmext/wasm.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
package wasmbinding
package wasmext

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

"github.com/NibiruChain/nibiru/x/sudo/keeper"

oraclekeeper "github.com/NibiruChain/nibiru/x/oracle/keeper"
perpv2keeper "github.com/NibiruChain/nibiru/x/perp/v2/keeper"
)

// NibiruWasmOptions: Wasm Options are extension points to instantiate the Wasm
// keeper with non-default values
func NibiruWasmOptions(
grpcQueryRouter *baseapp.GRPCQueryRouter,
appCodec codec.Codec,
perpv2 perpv2keeper.Keeper,
sudoKeeper keeper.Keeper,
oracleKeeper oraclekeeper.Keeper,
) []wasmkeeper.Option {
wasmQueryOption := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{
Stargate: wasmkeeper.AcceptListStargateQuerier(
Expand All @@ -28,9 +20,5 @@ func NibiruWasmOptions(
),
})

wasmExecuteOption := wasmkeeper.WithMessageHandlerDecorator(
CustomMessageDecorator(perpv2, sudoKeeper, oracleKeeper),
)

return []wasmkeeper.Option{wasmQueryOption, wasmExecuteOption}
return []wasmkeeper.Option{wasmQueryOption}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package test
package wasm_cli_test

import (
"encoding/hex"
"fmt"
"testing"
"time"

wasmcli "github.com/CosmWasm/wasmd/x/wasm/client/cli"

Expand All @@ -15,22 +14,19 @@ import (
"github.com/stretchr/testify/suite"

"github.com/NibiruChain/nibiru/app"
"github.com/NibiruChain/nibiru/x/common"
"github.com/NibiruChain/nibiru/x/common/asset"
"github.com/NibiruChain/nibiru/x/common/denoms"
"github.com/NibiruChain/nibiru/x/common/testutil"
testutilcli "github.com/NibiruChain/nibiru/x/common/testutil/cli"
"github.com/NibiruChain/nibiru/x/common/testutil/genesis"
"github.com/NibiruChain/nibiru/x/common/testutil/testapp"
epochstypes "github.com/NibiruChain/nibiru/x/epochs/types"
perpv2types "github.com/NibiruChain/nibiru/x/perp/v2/types"
)

// commonArgs is args for CLI test commands.
var commonArgs = []string{
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(denoms.NIBI, sdk.NewInt(10000000))).String()),
fmt.Sprintf("--%s=%s", flags.FlagFees,
sdk.NewCoins(sdk.NewCoin(denoms.NIBI, sdk.NewInt(10_000_000))).String()),
}

type IntegrationTestSuite struct {
Expand All @@ -46,38 +42,6 @@ func (s *IntegrationTestSuite) SetupSuite() {

encodingConfig := app.MakeEncodingConfig()
genesisState := genesis.NewTestGenesisState(encodingConfig)
perpv2Gen := perpv2types.DefaultGenesis()
perpv2Gen.Markets = []perpv2types.Market{
{
Pair: asset.Registry.Pair(denoms.ETH, denoms.NUSD),
Enabled: true,
MaintenanceMarginRatio: sdk.MustNewDecFromStr("0.0625"),
MaxLeverage: sdk.MustNewDecFromStr("15"),
LatestCumulativePremiumFraction: sdk.ZeroDec(),
ExchangeFeeRatio: sdk.MustNewDecFromStr("0.0005"),
EcosystemFundFeeRatio: sdk.MustNewDecFromStr("0.0005"),
LiquidationFeeRatio: sdk.MustNewDecFromStr("0.001"),
PartialLiquidationRatio: sdk.MustNewDecFromStr("0.5"),
FundingRateEpochId: epochstypes.ThirtyMinuteEpochID,
MaxFundingRate: sdk.OneDec(),
TwapLookbackWindow: 30 * time.Minute,
PrepaidBadDebt: sdk.NewCoin(denoms.NUSD, sdk.ZeroInt()),
OraclePair: asset.Registry.Pair(denoms.ETH, denoms.USD),
},
}
perpv2Gen.Amms = []perpv2types.AMM{
{
Pair: asset.Registry.Pair(denoms.ETH, denoms.NUSD),
BaseReserve: sdk.NewDec(10 * common.TO_MICRO),
QuoteReserve: sdk.NewDec(10 * common.TO_MICRO),
SqrtDepth: common.MustSqrtDec(sdk.NewDec(10 * 10 * common.TO_MICRO * common.TO_MICRO)),
PriceMultiplier: sdk.NewDec(6000),
TotalLong: sdk.ZeroDec(),
TotalShort: sdk.ZeroDec(),
},
}
genesisState[perpv2types.ModuleName] = encodingConfig.Marshaler.MustMarshalJSON(perpv2Gen)

s.cfg = testutilcli.BuildNetworkConfig(genesisState)
network, err := testutilcli.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)
Expand Down
109 changes: 0 additions & 109 deletions wasmbinding/bindings/execute_msg.json

This file was deleted.

Loading
Loading