From a84ab3407c3772fc6631c2de96d6cdda8f01054f Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Thu, 31 Oct 2024 14:18:50 -0400 Subject: [PATCH 1/4] chore: update chain IDs --- app/appconst/appconst.go | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/app/appconst/appconst.go b/app/appconst/appconst.go index cbf5d8909..e869ad993 100644 --- a/app/appconst/appconst.go +++ b/app/appconst/appconst.go @@ -53,39 +53,39 @@ func RuntimeVersion() string { // EIP 155 Chain IDs exported for tests. const ( - ETH_CHAIN_ID_MAINNET int64 = 7200 + ETH_CHAIN_ID_MAINNET int64 = 6900 - ETH_CHAIN_ID_TESTNET_1 int64 = 7210 - ETH_CHAIN_ID_TESTNET_2 int64 = 7211 - ETH_CHAIN_ID_TESTNET_3 int64 = 7212 + ETH_CHAIN_ID_TESTNET_1 int64 = 6910 + ETH_CHAIN_ID_TESTNET_2 int64 = 6911 + ETH_CHAIN_ID_TESTNET_3 int64 = 6912 - ETH_CHAIN_ID_DEVNET_1 int64 = 7220 - ETH_CHAIN_ID_DEVNET_2 int64 = 7221 - ETH_CHAIN_ID_DEVNET_3 int64 = 7222 + ETH_CHAIN_ID_DEVNET_1 int64 = 6920 + ETH_CHAIN_ID_DEVNET_2 int64 = 6921 + ETH_CHAIN_ID_DEVNET_3 int64 = 6922 - ETH_CHAIN_ID_LOCALNET_0 int64 = 7230 - ETH_CHAIN_ID_LOCALNET_1 int64 = 7231 - ETH_CHAIN_ID_LOCALNET_2 int64 = 7232 - ETH_CHAIN_ID_LOCALNET_3 int64 = 7233 + ETH_CHAIN_ID_LOCALNET_0 int64 = 6930 + ETH_CHAIN_ID_LOCALNET_1 int64 = 6931 + ETH_CHAIN_ID_LOCALNET_2 int64 = 6932 + ETH_CHAIN_ID_LOCALNET_3 int64 = 6933 - ETH_CHAIN_ID_DEFAULT int64 = 7230 + ETH_CHAIN_ID_DEFAULT int64 = 6930 ) var knownEthChainIDMap = map[string]int64{ - "cataclysm-1": 7200, + "cataclysm-1": 6900, - "nibiru-testnet-1": 7210, - "nibiru-testnet-2": 7211, - "nibiru-testnet-3": 7212, + "nibiru-testnet1": 6910, + "nibiru-testnet2": 6911, + "nibiru-testnet3": 6912, - "nibiru-devnet-1": 7220, - "nibiru-devnet-2": 7221, - "nibiru-devnet-3": 7222, + "nibiru-devnet1": 6920, + "nibiru-devnet2": 6921, + "nibiru-devnet3": 6922, - "nibiru-localnet-0": 7230, - "nibiru-localnet-1": 7231, - "nibiru-localnet-2": 7232, - "nibiru-localnet-3": 7233, + "nibiru-localnet0": 6930, + "nibiru-localnet1": 6931, + "nibiru-localnet2": 6932, + "nibiru-localnet3": 6933, } // GetEthChainID: Maps the given chain ID from the block's `sdk.Context` to an From 0ee9f1f4f62578836c9595f3f130f30f990a46c0 Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Thu, 31 Oct 2024 14:22:08 -0400 Subject: [PATCH 2/4] fix: changelog --- CHANGELOG.md | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88fa93ee9..717de2ada 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- [#2104](https://github.com/NibiruChain/nibiru/pull/2074) - chore: update chain IDs + ### Nibiru EVM #### Nibiru EVM | Before Audit 2 [Nov, 2024] @@ -50,19 +52,19 @@ Zenith](https://code4rena.com/zenith) Audit, running from 2024-10-07 until 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. +- [#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). + 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. + 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. - - - @@ -70,19 +72,19 @@ consistent setup and dynamic gas calculations, addressing the following tickets. - [#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 - [#2094](https://github.com/NibiruChain/nibiru/pull/2094) - fix(evm): Following -from the changs in #2086, this pull request implements a new `JournalChange` -struct that saves a deep copy of the state multi store before each -state-modifying, Nibiru-specific precompiled contract is called (`OnRunStart`). -Additionally, we commit the `StateDB` there as well. This guarantees that the -non-EVM and EVM state will be in sync even if there are complex, multi-step -Ethereum transactions, such as in the case of an EthereumTx that influences the -`StateDB`, then calls a precompile that also changes non-EVM state, and then EVM -reverts inside of a try-catch. + from the changs in #2086, this pull request implements a new `JournalChange` + struct that saves a deep copy of the state multi store before each + state-modifying, Nibiru-specific precompiled contract is called (`OnRunStart`). + Additionally, we commit the `StateDB` there as well. This guarantees that the + non-EVM and EVM state will be in sync even if there are complex, multi-step + Ethereum transactions, such as in the case of an EthereumTx that influences the + `StateDB`, then calls a precompile that also changes non-EVM state, and then EVM + reverts inside of a try-catch. - [#2098](https://github.com/NibiruChain/nibiru/pull/2098) - test(evm): statedb tests for race conditions within funtoken precompile - [#2090](https://github.com/NibiruChain/nibiru/pull/2090) - fix(evm): Account -for (1) ERC20 transfers with tokens that return false success values instead of -throwing an error and (2) ERC20 transfers with other operations that don't bring -about the expected resulting balance for the transfer recipient. + for (1) ERC20 transfers with tokens that return false success values instead of + throwing an error and (2) ERC20 transfers with other operations that don't bring + about the expected resulting balance for the transfer recipient. - [#2092](https://github.com/NibiruChain/nibiru/pull/2092) - feat(evm): add validation for wasm multi message execution #### Nibiru EVM | Before Audit 1 - 2024-10-18 From 5146b5011c7c601f81f4514f49c821b314cce59b Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Thu, 31 Oct 2024 14:35:26 -0400 Subject: [PATCH 3/4] chore: fix test --- app/appconst/appconst_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/appconst/appconst_test.go b/app/appconst/appconst_test.go index caa3e5823..4ab6e69ca 100644 --- a/app/appconst/appconst_test.go +++ b/app/appconst/appconst_test.go @@ -27,16 +27,16 @@ func (s *TestSuite) TestGetEthChainID() { s.Run("localnet", func() { s.EqualValues( big.NewInt(appconst.ETH_CHAIN_ID_LOCALNET_0), - appconst.GetEthChainID("nibiru-localnet-0"), + appconst.GetEthChainID("nibiru-localnet0"), ) }) s.Run("devnet", func() { want := big.NewInt(appconst.ETH_CHAIN_ID_TESTNET_1) - given := "nibiru-testnet-1" + given := "nibiru-testnet1" s.EqualValues(want, appconst.GetEthChainID(given)) want = big.NewInt(appconst.ETH_CHAIN_ID_DEVNET_2) - given = "nibiru-devnet-2" + given = "nibiru-devnet2" s.EqualValues(want, appconst.GetEthChainID(given)) }) s.Run("else", func() { From e00c2e0e543c8b93ff7c47cee81719b6fe326432 Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Thu, 31 Oct 2024 16:29:03 -0400 Subject: [PATCH 4/4] chore: reset chain id changes --- app/appconst/appconst.go | 24 ++++++++++++------------ app/appconst/appconst_test.go | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/appconst/appconst.go b/app/appconst/appconst.go index e869ad993..25c10dafc 100644 --- a/app/appconst/appconst.go +++ b/app/appconst/appconst.go @@ -74,18 +74,18 @@ const ( var knownEthChainIDMap = map[string]int64{ "cataclysm-1": 6900, - "nibiru-testnet1": 6910, - "nibiru-testnet2": 6911, - "nibiru-testnet3": 6912, - - "nibiru-devnet1": 6920, - "nibiru-devnet2": 6921, - "nibiru-devnet3": 6922, - - "nibiru-localnet0": 6930, - "nibiru-localnet1": 6931, - "nibiru-localnet2": 6932, - "nibiru-localnet3": 6933, + "nibiru-testnet-1": 6910, + "nibiru-testnet-2": 6911, + "nibiru-testnet-3": 6912, + + "nibiru-devnet-1": 6920, + "nibiru-devnet-2": 6921, + "nibiru-devnet-3": 6922, + + "nibiru-localnet-0": 6930, + "nibiru-localnet-1": 6931, + "nibiru-localnet-2": 6932, + "nibiru-localnet-3": 6933, } // GetEthChainID: Maps the given chain ID from the block's `sdk.Context` to an diff --git a/app/appconst/appconst_test.go b/app/appconst/appconst_test.go index 4ab6e69ca..caa3e5823 100644 --- a/app/appconst/appconst_test.go +++ b/app/appconst/appconst_test.go @@ -27,16 +27,16 @@ func (s *TestSuite) TestGetEthChainID() { s.Run("localnet", func() { s.EqualValues( big.NewInt(appconst.ETH_CHAIN_ID_LOCALNET_0), - appconst.GetEthChainID("nibiru-localnet0"), + appconst.GetEthChainID("nibiru-localnet-0"), ) }) s.Run("devnet", func() { want := big.NewInt(appconst.ETH_CHAIN_ID_TESTNET_1) - given := "nibiru-testnet1" + given := "nibiru-testnet-1" s.EqualValues(want, appconst.GetEthChainID(given)) want = big.NewInt(appconst.ETH_CHAIN_ID_DEVNET_2) - given = "nibiru-devnet2" + given = "nibiru-devnet-2" s.EqualValues(want, appconst.GetEthChainID(given)) }) s.Run("else", func() {