Skip to content

Commit a3d3efb

Browse files
committed
Merge branch 'main' into releases/v2.0.0
2 parents 13d9296 + 585ebe7 commit a3d3efb

File tree

125 files changed

+5357
-9194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+5357
-9194
lines changed

.github/issue-labeler-config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Adds the "S-triage" label ot any issue that gets opened.
2+
S-triage:
3+
- '/.*/'

.github/workflows/e2e-wasm.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
name: CosmWasm e2e tests
32

43
on:

.github/workflows/gh-issues.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "Auto-add GH issues to project"
2+
# Add all issues opened to the issue board for triage and assignment
3+
# GitHub Org and Project Automation
4+
# https://www.notion.so/nibiru/GitHub-Org-and-Project-Automation-c771d671109849ee9fda7c8b741cd66a?pvs=4
5+
6+
on:
7+
issues:
8+
types: ["opened", "labeled"]
9+
10+
permissions:
11+
issues: write
12+
contents: read
13+
14+
jobs:
15+
# https://github.com/actions/add-to-project
16+
add-to-project:
17+
name: "Add GH ticket to project"
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/[email protected]
21+
with:
22+
project-url: https://github.com/orgs/NibiruChain/projects/8
23+
github-token: ${{ secrets.NIBIRU_PM }}
24+
25+
label-triage:
26+
name: "Add GH ticket to project"
27+
runs-on: ubuntu-latest
28+
# The action comes from the "Activty types" for the "issues" webhook event
29+
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#issues
30+
if: "github.event.action == 'opened'"
31+
steps:
32+
- uses: github/[email protected]
33+
if: join(github.event.issue.labels) == ''
34+
with:
35+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
36+
configuration-path: ".github/issue-labeler-config.yml"
37+
enable-versioned-regex: 0
38+
not-before: "2024-05-01T00:00:00Z"

.github/workflows/proto-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# timeout-minutes: 5
2323
# steps:
2424
# - uses: actions/checkout@v4
25-
# - uses: bufbuild/buf-setup-action@v1.36.0
25+
# - uses: bufbuild/buf-setup-action@v1.43.0
2626
# - uses: bufbuild/buf-lint-action@v1
2727
# with:
2828
# input: "proto"
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ubuntu-latest
3232
steps:
3333
- uses: actions/checkout@v4
34-
- uses: bufbuild/buf-setup-action@v1.36.0
34+
- uses: bufbuild/buf-setup-action@v1.43.0
3535
with:
3636
github_token: ${{ github.token }}
3737
- uses: bufbuild/buf-breaking-action@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ temp*
2020
txout.json
2121
vote.json
2222
**__pycache**
23+
scratch-paper.md
2324

2425
### TypeScript and Friends
2526

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
109109
- [#2003](https://github.com/NibiruChain/nibiru/pull/2003) - fix(evm): fix FunToken conversions between Cosmos and EVM
110110
- [#2004](https://github.com/NibiruChain/nibiru/pull/2004) - refactor(evm)!: replace `HexAddr` with `EIP55Addr`
111111
- [#2006](https://github.com/NibiruChain/nibiru/pull/2006) - test(evm): e2e tests for eth_* endpoints
112-
- [#2008](https://github.com/NibiruChain/nibiru/pull/2008) - refactor(evm): clean up precompile setups
112+
- [#2008](https://github.com/NibiruChain/nibiru/pull/2008) - refactor(evm): clean up precompile setups
113113
- [#2013](https://github.com/NibiruChain/nibiru/pull/2013) - chore(evm): Set appropriate gas value for the required gas of the "IFunToken.sol" precompile.
114114
- [#2014](https://github.com/NibiruChain/nibiru/pull/2014) - feat(evm): Emit block bloom event in EndBlock hook.
115115
- [#2017](https://github.com/NibiruChain/nibiru/pull/2017) - fix(evm): Fix DynamicFeeTx gas cap parameters
116116
- [#2019](https://github.com/NibiruChain/nibiru/pull/2019) - chore(evm): enabled debug rpc api on localnet.
117117
- [#2020](https://github.com/NibiruChain/nibiru/pull/2020) - test(evm): e2e tests for debug namespace
118118
- [#2022](https://github.com/NibiruChain/nibiru/pull/2022) - feat(evm): debug_traceCall method implemented
119119
- [#2023](https://github.com/NibiruChain/nibiru/pull/2023) - fix(evm)!: adjusted generation and parsing of the block bloom events
120+
- [#2030](https://github.com/NibiruChain/nibiru/pull/2030) - refactor(eth/rpc): Delete unused code and improve logging in the eth and debug namespaces
121+
- [#2031](https://github.com/NibiruChain/nibiru/pull/2031) - fix(evm): debug calls with custom tracer and tracer options
122+
- [#2032](https://github.com/NibiruChain/nibiru/pull/2032) - feat(evm): ante handler to prohibit authz grant evm messages
123+
- [#2039](https://github.com/NibiruChain/nibiru/pull/2039) - refactor(rpc-backend): remove unnecessary interface code
124+
- [#2044](https://github.com/NibiruChain/nibiru/pull/2044) - feat(evm): evm tx indexer service implemented
125+
- [#2045](https://github.com/NibiruChain/nibiru/pull/2045) - test(evm): backend tests with test network and real txs
126+
- [#2053](https://github.com/NibiruChain/nibiru/pull/2053) - refactor(evm): converted untyped event to typed and cleaned up
127+
- [#2054](https://github.com/NibiruChain/nibiru/pull/2054) - feat(evm-precompile): Precompile for one-way EVM calls to invoke/execute Wasm contracts.
128+
- [#2060](https://github.com/NibiruChain/nibiru/pull/2060) - fix(evm-precompiles): add assertNumArgs validation
129+
- [#2056](https://github.com/NibiruChain/nibiru/pull/2056) - feat(evm): add oracle precompile
120130

121131
#### Dapp modules: perp, spot, oracle, etc
122132

@@ -146,6 +156,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
146156
- [#1913](https://github.com/NibiruChain/nibiru/pull/1913) - fix(tests): race condition from heavy Network tests
147157
- [#1992](https://github.com/NibiruChain/nibiru/pull/1992) - chore: enabled grpc for localnet
148158
- [#1999](https://github.com/NibiruChain/nibiru/pull/1999) - chore: update nibi go package version to v2
159+
- [#2050](https://github.com/NibiruChain/nibiru/pull/2050) - refactor(oracle): remove unused code and collapse empty client/cli directory
149160

150161
### Dependencies
151162

@@ -168,7 +179,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
168179
- Bump `github.com/hashicorp/go-getter` from 1.7.1 to 1.7.5 ([#1858](https://github.com/NibiruChain/nibiru/pull/1858), [#1938](https://github.com/NibiruChain/nibiru/pull/1938))
169180
- Bump `github.com/btcsuite/btcd` from 0.23.3 to 0.24.0 ([#1862](https://github.com/NibiruChain/nibiru/pull/1862))
170181
- Bump `pozetroninc/github-action-get-latest-release` from 0.7.0 to 0.8.0 ([#1863](https://github.com/NibiruChain/nibiru/pull/1863))
171-
- Bump `bufbuild/buf-setup-action` from 1.30.1 to 1.36.0 ([#1891](https://github.com/NibiruChain/nibiru/pull/1891), [#1900](https://github.com/NibiruChain/nibiru/pull/1900), [#1923](https://github.com/NibiruChain/nibiru/pull/1923), [#1972](https://github.com/NibiruChain/nibiru/pull/1972), [#1974](https://github.com/NibiruChain/nibiru/pull/1974), [#1988](https://github.com/NibiruChain/nibiru/pull/1988))
182+
- Bump `bufbuild/buf-setup-action` from 1.30.1 to 1.43.0 ([#1891](https://github.com/NibiruChain/nibiru/pull/1891), [#1900](https://github.com/NibiruChain/nibiru/pull/1900), [#1923](https://github.com/NibiruChain/nibiru/pull/1923), [#1972](https://github.com/NibiruChain/nibiru/pull/1972), [#1974](https://github.com/NibiruChain/nibiru/pull/1974), [#1988](https://github.com/NibiruChain/nibiru/pull/1988), [#2043](https://github.com/NibiruChain/nibiru/pull/2043), [#2057](https://github.com/NibiruChain/nibiru/pull/2057))
183+
- Bump `axios` from 1.7.3 to 1.7.4 ([#2016](https://github.com/NibiruChain/nibiru/pull/2016))
172184

173185
## [v1.5.0](https://github.com/NibiruChain/nibiru/releases/tag/v1.5.0) - 2024-06-21
174186

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ If you have questions or concerns, feel free to connect with a developer or comm
2828

2929
| Module | Description |
3030
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
31-
| [Wasm][code-x-wasm] | Implements the execution environment for WebAssembly (WASM) smart contracts. CosmWasm smart contracts are Rust-based, Wasm smart contracts built for enhanced security, performance, and interoperability. See our [CosmWasm sandbox monorepo (cw-nibiru)](https://github.com/NibiruChain/cw-nibiru/tree/main) for the protocol's core smart contracts. |
31+
| [Wasm][code-x-wasm] | Implements the execution environment for WebAssembly (WASM) smart contracts. CosmWasm smart contracts are Rust-based, Wasm smart contracts built for enhanced security, performance, and interoperability. See our [CosmWasm sandbox monorepo (nibiru-wasm)](https://github.com/NibiruChain/nibiru-wasm/tree/main) for the protocol's core smart contracts. |
3232
| [EVM][code-x-evm] | Implements Nibiru EVM, which manages an Ethereum Virtual Machine (EVM) state database and enables the execution of Ethereum smart contracts. Nibiru EVM is an extension of "[geth](https://github.com/ethereum/go-ethereum)" along with "web3" and "eth" JSON-RPC methods. |
3333
| [Devgas][code-x-devgas] | The `devgas` module of Nibiru Chain shares contract execution fees with smart contract developers. This aims to increase the adoption of Nibiru by offering CosmWasm smart contract developers a direct source of income based on usage. |
3434
| [Epochs][code-x-epochs] | The `epochs` module allows other modules to set hooks to be called to execute code automatically on a period basis. For example, "once a week, starting at UTC-time = x". `epochs` creates a generalized epoch interface. |

app/ante.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func NewAnteHandlerNonEVM(
6262
) sdk.AnteHandler {
6363
return sdk.ChainAnteDecorators(
6464
ante.AnteDecoratorPreventEtheruemTxMsgs{}, // reject MsgEthereumTxs
65+
ante.AnteDecoratorAuthzGuard{}, // disable certain messages in authz grant "generic"
6566
authante.NewSetUpContextDecorator(),
6667
wasmkeeper.NewLimitSimulationGasDecorator(opts.WasmConfig.SimulationGasLimit),
6768
wasmkeeper.NewCountTXDecorator(opts.TxCounterStoreKey),

app/ante/auth_grard_test.go

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
package ante_test
2+
3+
import (
4+
"time"
5+
6+
sdkclienttx "github.com/cosmos/cosmos-sdk/client/tx"
7+
sdk "github.com/cosmos/cosmos-sdk/types"
8+
"github.com/cosmos/cosmos-sdk/x/authz"
9+
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
10+
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
11+
12+
"github.com/NibiruChain/nibiru/v2/app"
13+
"github.com/NibiruChain/nibiru/v2/app/ante"
14+
"github.com/NibiruChain/nibiru/v2/x/evm"
15+
"github.com/NibiruChain/nibiru/v2/x/evm/evmtest"
16+
)
17+
18+
func (s *AnteTestSuite) TestAnteDecoratorAuthzGuard() {
19+
testCases := []struct {
20+
name string
21+
txMsg func() sdk.Msg
22+
wantErr string
23+
}{
24+
{
25+
name: "sad: authz generic grant with evm message",
26+
txMsg: func() sdk.Msg {
27+
someTime := time.Now()
28+
expiryTime := someTime.Add(time.Hour)
29+
genericGrant, err := authz.NewGrant(
30+
someTime,
31+
authz.NewGenericAuthorization(sdk.MsgTypeURL(&evm.MsgEthereumTx{})), &expiryTime,
32+
)
33+
s.Require().NoError(err)
34+
return &authz.MsgGrant{Grant: genericGrant}
35+
},
36+
wantErr: "not allowed",
37+
},
38+
{
39+
name: "happy: authz generic grant with non evm message",
40+
txMsg: func() sdk.Msg {
41+
someTime := time.Now()
42+
expiryTime := someTime.Add(time.Hour)
43+
genericGrant, err := authz.NewGrant(
44+
someTime,
45+
authz.NewGenericAuthorization(sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{})), &expiryTime,
46+
)
47+
s.Require().NoError(err)
48+
return &authz.MsgGrant{Grant: genericGrant}
49+
},
50+
wantErr: "",
51+
},
52+
{
53+
name: "happy: authz non generic grant",
54+
txMsg: func() sdk.Msg {
55+
someTime := time.Now()
56+
expiryTime := someTime.Add(time.Hour)
57+
genericGrant, err := authz.NewGrant(
58+
someTime,
59+
&banktypes.SendAuthorization{},
60+
&expiryTime,
61+
)
62+
s.Require().NoError(err)
63+
return &authz.MsgGrant{Grant: genericGrant}
64+
},
65+
wantErr: "",
66+
},
67+
{
68+
name: "happy: non authz message",
69+
txMsg: func() sdk.Msg {
70+
return &evm.MsgEthereumTx{}
71+
},
72+
wantErr: "",
73+
},
74+
{
75+
name: "sad: authz exec with a single evm message",
76+
txMsg: func() sdk.Msg {
77+
msgExec := authz.NewMsgExec(
78+
sdk.AccAddress("nibiuser"),
79+
[]sdk.Msg{
80+
&evm.MsgEthereumTx{},
81+
},
82+
)
83+
return &msgExec
84+
},
85+
wantErr: "ExtensionOptionsEthereumTx",
86+
},
87+
{
88+
name: "sad: authz exec with evm message and non evm message",
89+
txMsg: func() sdk.Msg {
90+
msgExec := authz.NewMsgExec(
91+
sdk.AccAddress("nibiuser"),
92+
[]sdk.Msg{
93+
&banktypes.MsgSend{},
94+
&evm.MsgEthereumTx{},
95+
},
96+
)
97+
return &msgExec
98+
},
99+
wantErr: "ExtensionOptionsEthereumTx",
100+
},
101+
{
102+
name: "happy: authz exec without evm messages",
103+
txMsg: func() sdk.Msg {
104+
msgExec := authz.NewMsgExec(
105+
sdk.AccAddress("nibiuser"),
106+
[]sdk.Msg{
107+
&banktypes.MsgSend{},
108+
},
109+
)
110+
return &msgExec
111+
},
112+
wantErr: "",
113+
},
114+
}
115+
116+
for _, tc := range testCases {
117+
s.Run(tc.name, func() {
118+
deps := evmtest.NewTestDeps()
119+
anteDec := ante.AnteDecoratorAuthzGuard{}
120+
121+
encCfg := app.MakeEncodingConfig()
122+
txBuilder, err := sdkclienttx.Factory{}.
123+
WithChainID(s.ctx.ChainID()).
124+
WithTxConfig(encCfg.TxConfig).
125+
BuildUnsignedTx(tc.txMsg())
126+
s.Require().NoError(err)
127+
128+
_, err = anteDec.AnteHandle(
129+
deps.Ctx, txBuilder.GetTx(), false, evmtest.NextNoOpAnteHandler,
130+
)
131+
if tc.wantErr != "" {
132+
s.Require().ErrorContains(err, tc.wantErr)
133+
return
134+
}
135+
s.Require().NoError(err)
136+
})
137+
}
138+
}

app/ante/authz_guard.go

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,67 @@
1+
// Copyright (c) 2023-2024 Nibi, Inc.
12
package ante
23

3-
// TODO: https://github.com/NibiruChain/nibiru/issues/1915
4-
// feat(ante): Add an authz guard to disable authz Ethereum txs and provide
5-
// additional security around the default functionality exposed by the module.
6-
//
7-
// Implemenetation Notes
8-
// UD-NOTE - IsAuthzMessage fn. Use authz import with module name
9-
// UD-NOTE - Define set of disabled txMsgs
4+
import (
5+
"cosmossdk.io/errors"
6+
sdk "github.com/cosmos/cosmos-sdk/types"
7+
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
8+
"github.com/cosmos/cosmos-sdk/x/authz"
9+
10+
"github.com/NibiruChain/nibiru/v2/x/evm"
11+
)
12+
13+
// AnteDecoratorAuthzGuard filters autz messages
14+
type AnteDecoratorAuthzGuard struct{}
15+
16+
// AnteHandle rejects "authz grant generic --msg-type '/eth.evm.v1.MsgEthereumTx'"
17+
// Also rejects authz exec tx.json with any MsgEthereumTx inside
18+
func (rmd AnteDecoratorAuthzGuard) AnteHandle(
19+
ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler,
20+
) (newCtx sdk.Context, err error) {
21+
for _, msg := range tx.GetMsgs() {
22+
// Do not allow grant for MsgEthereumTx
23+
if msgGrant, ok := msg.(*authz.MsgGrant); ok {
24+
if msgGrant.Grant.Authorization == nil {
25+
return ctx, errors.Wrapf(
26+
errortypes.ErrInvalidType,
27+
"grant authorization is missing",
28+
)
29+
}
30+
authorization, err := msgGrant.Grant.GetAuthorization()
31+
if err != nil {
32+
return ctx, errors.Wrapf(
33+
errortypes.ErrInvalidType,
34+
"failed unmarshaling generic authorization %s", err,
35+
)
36+
}
37+
if genericAuth, ok := authorization.(*authz.GenericAuthorization); ok {
38+
if genericAuth.MsgTypeURL() == sdk.MsgTypeURL(&evm.MsgEthereumTx{}) {
39+
return ctx, errors.Wrapf(
40+
errortypes.ErrNotSupported,
41+
"authz grant generic for msg type %s is not allowed",
42+
genericAuth.MsgTypeURL(),
43+
)
44+
}
45+
}
46+
}
47+
// Also reject MsgEthereumTx in exec
48+
if msgExec, ok := msg.(*authz.MsgExec); ok {
49+
msgsInExec, err := msgExec.GetMessages()
50+
if err != nil {
51+
return ctx, errors.Wrapf(
52+
errortypes.ErrInvalidType,
53+
"failed getting exec messages %s", err,
54+
)
55+
}
56+
for _, msgInExec := range msgsInExec {
57+
if _, ok := msgInExec.(*evm.MsgEthereumTx); ok {
58+
return ctx, errors.Wrapf(
59+
errortypes.ErrInvalidType,
60+
"MsgEthereumTx needs to be contained within a tx with 'ExtensionOptionsEthereumTx' option",
61+
)
62+
}
63+
}
64+
}
65+
}
66+
return next(ctx, tx, simulate)
67+
}

0 commit comments

Comments
 (0)