Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/bufbuild/buf-setup…
Browse files Browse the repository at this point in the history
…-action-1.45.0
  • Loading branch information
Unique-Divine authored Oct 24, 2024
2 parents 5cc207f + 9ce1d87 commit fa685fd
Show file tree
Hide file tree
Showing 53 changed files with 2,285 additions and 861 deletions.
58 changes: 40 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### State Machine Breaking
### Nibiru EVM

#### For next mainnet version
#### Nibiru EVM | Before Audit 2 [Nov, 2024]

- [#1766](https://github.com/NibiruChain/nibiru/pull/1766) - refactor(app-wasmext)!: remove wasmbinding `CosmosMsg::Custom` bindings.
- [#1776](https://github.com/NibiruChain/nibiru/pull/1776) - feat(inflation): make inflation params a collection and add commands to update them
- [#1872](https://github.com/NibiruChain/nibiru/pull/1872) - chore(math): use cosmossdk.io/math to replace sdk types
- [#1874](https://github.com/NibiruChain/nibiru/pull/1874) - chore(proto): remove the proto stringer as per Cosmos SDK migration guidelines
- [#1932](https://github.com/NibiruChain/nibiru/pull/1932) - fix(gosdk): fix keyring import functions
The codebase went through a third-party [Code4rena
Zenith](https://code4rena.com/zenith) Audit, running from 2024-10-07 until
2024-11-01 and including both a primary review period and mitigation/remission
period. This section describes code changes that occured after that audit in
preparation for a second audit starting in November 2024.

- [#2074](https://github.com/NibiruChain/nibiru/pull/2074) - fix(evm-keeper): better utilize ERC20 metadata during FunToken creation. The bank metadata for a new FunToken mapping ties a connection between the Bank Coin's `DenomUnit` and the ERC20 contract metadata like the name, decimals, and symbol. This change brings parity between EVM wallets, such as MetaMask, and Interchain wallets like Keplr and Leap.
- [#2076](https://github.com/NibiruChain/nibiru/pull/2076) - fix(evm-gas-fees):
Use effective gas price in RefundGas and make sure that units are properly
reflected on all occurences of "base fee" in the codebase. This fixes [#2059](https://github.com/NibiruChain/nibiru/issues/2059)
and the [related comments from @Unique-Divine and @berndartmueller](https://github.com/NibiruChain/nibiru/issues/2059#issuecomment-2408625724).
- [#2084](https://github.com/NibiruChain/nibiru/pull/2084) - feat(evm-forge): foundry support and template for Nibiru EVM develoment
- [#2086](https://github.com/NibiruChain/nibiru/pull/2086) - fix(evm-precomples):
Fix state consistency in precompile execution by ensuring proper journaling of
state changes in the StateDB. This pull request makes sure that state is
committed as expected, fixes the `StateDB.Commit` to follow its guidelines more
closely, and solves for a critical state inconsistency producible from the
FunToken.sol precompiled contract. It also aligns the precompiles to use
consistent setup and dynamic gas calculations, addressing the following tickets.
- https://github.com/NibiruChain/nibiru/issues/2083
- https://github.com/code-423n4/2024-10-nibiru-zenith/issues/43
- https://github.com/code-423n4/2024-10-nibiru-zenith/issues/47
- [#2088](https://github.com/NibiruChain/nibiru/pull/2088) - refactor(evm): remove outdated comment and improper error message text
- [#2089](https://github.com/NibiruChain/nibiru/pull/2089) - better handling of gas consumption within erc20 contract execution
- [#2091](https://github.com/NibiruChain/nibiru/pull/2091) - feat(evm): add fun token creation fee validation

#### Nibiru EVM
#### Nibiru EVM | Before Audit 1 - 2024-10-18

- [#1837](https://github.com/NibiruChain/nibiru/pull/1837) - feat(eth): protos, eth types, and evm module types
- [#1838](https://github.com/NibiruChain/nibiru/pull/1838) - feat(eth): Go-ethereum, crypto, encoding, and unit tests for evm/types
Expand All @@ -70,7 +90,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#1909](https://github.com/NibiruChain/nibiru/pull/1909) - chore(evm): set is_london true by default and removed from config
- [#1911](https://github.com/NibiruChain/nibiru/pull/1911) - chore(evm): simplified config by removing old eth forks
- [#1912](https://github.com/NibiruChain/nibiru/pull/1912) - test(evm): unit tests for evm_ante
- [#1914](https://github.com/NibiruChain/nibiru/pull/1914) - refactor(evm): Remove dead code and document non-EVM ante handler- [#1917](https://github.com/NibiruChain/nibiru/pull/1917) - test(e2e-evm): TypeScript support. Type generation from compiled contracts. Formatter for TS code.
- [#1914](https://github.com/NibiruChain/nibiru/pull/1914) - refactor(evm): Remove dead code and document non-EVM ante handler
- [#1917](https://github.com/NibiruChain/nibiru/pull/1917) - test(e2e-evm): TypeScript support. Type generation from compiled contracts. Formatter for TS code.
- [#1922](https://github.com/NibiruChain/nibiru/pull/1922) - feat(evm): tracer option is read from the config.
- [#1936](https://github.com/NibiruChain/nibiru/pull/1936) - feat(evm): EVM fungible token protobufs and encoding tests
Expand Down Expand Up @@ -108,7 +128,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#2002](https://github.com/NibiruChain/nibiru/pull/2002) - feat(evm): Add the account query to the EVM command. Cover the CLI with tests.
- [#2003](https://github.com/NibiruChain/nibiru/pull/2003) - fix(evm): fix FunToken conversions between Cosmos and EVM
- [#2004](https://github.com/NibiruChain/nibiru/pull/2004) - refactor(evm)!: replace `HexAddr` with `EIP55Addr`
- [#2006](https://github.com/NibiruChain/nibiru/pull/2006) - test(evm): e2e tests for eth_* endpoints
- [#2006](https://github.com/NibiruChain/nibiru/pull/2006) - test(evm): e2e tests for eth\_\* endpoints
- [#2008](https://github.com/NibiruChain/nibiru/pull/2008) - refactor(evm): clean up precompile setups
- [#2013](https://github.com/NibiruChain/nibiru/pull/2013) - chore(evm): Set appropriate gas value for the required gas of the "IFunToken.sol" precompile.
- [#2014](https://github.com/NibiruChain/nibiru/pull/2014) - feat(evm): Emit block bloom event in EndBlock hook.
Expand All @@ -124,18 +144,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#2044](https://github.com/NibiruChain/nibiru/pull/2044) - feat(evm): evm tx indexer service implemented
- [#2045](https://github.com/NibiruChain/nibiru/pull/2045) - test(evm): backend tests with test network and real txs
- [#2053](https://github.com/NibiruChain/nibiru/pull/2053) - refactor(evm): converted untyped event to typed and cleaned up
- [#2054](https://github.com/NibiruChain/nibiru/pull/2054) - feat(evm-precompile): Precompile for one-way EVM calls to invoke/execute Wasm contracts.
- [#2054](https://github.com/NibiruChain/nibiru/pull/2054) - feat(evm-precompile): Precompile for one-way EVM calls to invoke/execute Wasm contracts.
- [#2060](https://github.com/NibiruChain/nibiru/pull/2060) - fix(evm-precompiles): add assertNumArgs validation
- [#2056](https://github.com/NibiruChain/nibiru/pull/2056) - feat(evm): add oracle precompile
- [#2065](https://github.com/NibiruChain/nibiru/pull/2065) - refactor(evm)!: Refactor out dead code from the evm.Params
- [#2073](https://github.com/NibiruChain/nibiru/pull/2073) - fix(evm-keeper): better utilize ERC20 metadata during FunToken creation
- [#2076](https://github.com/NibiruChain/nibiru/pull/2076) - fix(evm-gas-fees):
Use effective gas price in RefundGas and make sure that units are properly
reflected on all occurences of "base fee" in the codebase. This fixes [#2059](https://github.com/NibiruChain/nibiru/issues/2059)
and the [related comments from @Unique-Divine and @berndartmueller](https://github.com/NibiruChain/nibiru/issues/2059#issuecomment-2408625724).
- [#2084](https://github.com/NibiruChain/nibiru/pull/2084) - feat(evm-forge): foundry support and template for Nibiru EVM develoment
- [#2088](https://github.com/NibiruChain/nibiru/pull/2088) - refactor(evm): remove outdated comment and improper error message text

### State Machine Breaking (Other)

#### For next mainnet version

- [#1766](https://github.com/NibiruChain/nibiru/pull/1766) - refactor(app-wasmext)!: remove wasmbinding `CosmosMsg::Custom` bindings.
- [#1776](https://github.com/NibiruChain/nibiru/pull/1776) - feat(inflation): make inflation params a collection and add commands to update them
- [#1872](https://github.com/NibiruChain/nibiru/pull/1872) - chore(math): use cosmossdk.io/math to replace sdk types
- [#1874](https://github.com/NibiruChain/nibiru/pull/1874) - chore(proto): remove the proto stringer as per Cosmos SDK migration guidelines
- [#1932](https://github.com/NibiruChain/nibiru/pull/1932) - fix(gosdk): fix keyring import functions

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

Expand Down
24 changes: 20 additions & 4 deletions app/evmante/evmante_validate_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ func (s *TestSuite) TestEthValidateBasicDecorator() {
},
wantErr: "",
},
{
name: "sad: fail to set params",
txSetup: func(deps *evmtest.TestDeps) sdk.Tx {
return evmtest.HappyCreateContractTx(deps)
},
paramsSetup: func(deps *evmtest.TestDeps) evm.Params {
return evm.Params{
CreateFuntokenFee: sdk.NewInt(-1),
}
},
wantErr: "createFuntokenFee cannot be negative: -1",
},
{
name: "happy: ctx recheck should ignore validation",
ctxSetup: func(deps *evmtest.TestDeps) {
Expand Down Expand Up @@ -195,12 +207,16 @@ func (s *TestSuite) TestEthValidateBasicDecorator() {
if tc.ctxSetup != nil {
tc.ctxSetup(&deps)
}
var err error
if tc.paramsSetup != nil {
deps.EvmKeeper.SetParams(deps.Ctx, tc.paramsSetup(&deps))
err = deps.EvmKeeper.SetParams(deps.Ctx, tc.paramsSetup(&deps))
}

if err == nil {
_, err = anteDec.AnteHandle(
deps.Ctx, tx, false, evmtest.NextNoOpAnteHandler,
)
}
_, err := anteDec.AnteHandle(
deps.Ctx, tx, false, evmtest.NextNoOpAnteHandler,
)
if tc.wantErr != "" {
s.Require().ErrorContains(err, tc.wantErr)
return
Expand Down
10 changes: 6 additions & 4 deletions eth/indexer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions proto/eth/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/NibiruChain/nibiru/v2/x/evm";

// FunToken is a fungible token mapping between a bank coin and a corresponding
// ERC-20 smart contract. Bank coins here refer to tokens like NIBI, IBC
// FunToken is a fungible token mapping between a Bank Coin and a corresponding
// ERC-20 smart contract. Bank Coins here refer to tokens like NIBI, IBC
// coins (ICS-20), and token factory coins, which are each represented by the
// "Coin" type in Golang.
message FunToken {
Expand All @@ -20,7 +20,7 @@ message FunToken {
// bank_denom: Coin denomination in the Bank Module.
string bank_denom = 2;

// True if the `FunToken` mapping was created from an existing bank coin and
// True if the `FunToken` mapping was created from an existing Bank Coin and
// the ERC-20 contract gets deployed by the module account. False if the
// mapping was created from an externally owned ERC-20 contract.
bool is_made_from_coin = 3;
Expand Down
2 changes: 1 addition & 1 deletion proto/eth/evm/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,6 @@ message QueryFunTokenMappingResponse {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// fun_token is a mapping between the Cosmos native coin and the ERC20 contract address
// fun_token is a mapping between the Bank Coin and the ERC20 contract address
eth.evm.v1.FunToken fun_token = 1;
}
16 changes: 8 additions & 8 deletions proto/eth/evm/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ service Msg {
rpc EthereumTx(MsgEthereumTx) returns (MsgEthereumTxResponse) {
option (google.api.http).post = "/nibiru/evm/v1/ethereum_tx";
};
// UpdateParams defined a governance operation for updating the x/evm module parameters.
// The authority is hard-coded to the Cosmos SDK x/gov module account
// UpdateParams defined a governance operation for updating the x/evm module
// parameters. The authority is hard-coded to the x/gov module account
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);

// CreateFunToken: Create a "FunToken" mapping. Either the ERC20 contract
// address can be given to create the mapping to a bank coin, or the
// denomination for a bank coin can be given to create the mapping to an ERC20.
// address can be given to create the mapping to a Bank Coin, or the
// denomination for a Bank Coin can be given to create the mapping to an ERC20.
rpc CreateFunToken(MsgCreateFunToken) returns (MsgCreateFunTokenResponse);

// ConvertCoinToEvm: Sends a coin with a valid "FunToken" mapping to the
Expand Down Expand Up @@ -229,8 +229,8 @@ message MsgUpdateParams {
message MsgUpdateParamsResponse {}

// MsgCreateFunToken: Arguments to create a "FunToken" mapping. Either the ERC20
// contract address can be given to create the mapping to a bank coin, or the
// denomination for a bank coin can be given to create the mapping to an ERC20.
// contract address can be given to create the mapping to a Bank Coin, or the
// denomination for a Bank Coin can be given to create the mapping to an ERC20.
message MsgCreateFunToken {
// Hexadecimal address of the ERC20 token to which the `FunToken` maps
string from_erc20 = 1 [
Expand All @@ -250,7 +250,7 @@ message MsgCreateFunTokenResponse {
eth.evm.v1.FunToken funtoken_mapping = 1 [(gogoproto.nullable) = false];
}

// MsgConvertCoinToEvm: Arguments to send a bank coin to ERC-20 representation
// MsgConvertCoinToEvm: Arguments to send a Bank Coin to ERC-20 representation
message MsgConvertCoinToEvm {
// Hexadecimal address of the ERC20 token to which the `FunToken` maps
string to_eth_addr = 1 [
Expand All @@ -261,7 +261,7 @@ message MsgConvertCoinToEvm {
// Sender: Address for the signer of the transaction.
string sender = 2;

// Bank coin to get converted to ERC20
// Bank Coin to get converted to ERC20
cosmos.base.v1beta1.Coin bank_coin = 3 [
(gogoproto.moretags) = "yaml:\"bank_coin\"",
(gogoproto.nullable) = false
Expand Down
10 changes: 6 additions & 4 deletions proto/eth/types/v1/indexer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ message TxResult {

// height of the blockchain
int64 height = 1;
// tx_index of the cosmos transaction
// tx_index is the index of the block transaction. It is not the index of an
// "internal transaction"
uint32 tx_index = 2;
// msg_index in a batch transaction
uint32 msg_index = 3;

// eth_tx_index is the index in the list of valid eth tx in the block,
// aka. the transaction list returned by eth_getBlock api.
// eth_tx_index is the index in the list of valid eth tx in the block. Said
// another way, it is the index of the transaction list returned by
// eth_getBlock API.
int32 eth_tx_index = 4;
// failed is true if the eth transaction did not go succeed
// failed is true if the eth transaction did not succeed
bool failed = 5;
// gas_used by the transaction. If it exceeds the block gas limit,
// it's set to gas limit, which is what's actually deducted by ante handler.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "FunToken",
"contractName": "IFunToken",
"sourceName": "contracts/FunToken.sol",
"abi": [
{
Expand Down
Loading

0 comments on commit fa685fd

Please sign in to comment.