From 70f9470669f6b646858f5190674cf9babb81092a Mon Sep 17 00:00:00 2001 From: ethan <101823964+Ethanncnm@users.noreply.github.com> Date: Wed, 19 Jul 2023 17:14:53 +0800 Subject: [PATCH 1/6] [R4R]: fix compile error for solidity version 0.8.8 (#1303) fix compile error on solidity ^0.8.8. Co-authored-by: Raymond <6427270+wukongcheng@users.noreply.github.com> --- packages/contracts/contracts/L2/predeploys/BVM_MANTLE.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/contracts/contracts/L2/predeploys/BVM_MANTLE.sol b/packages/contracts/contracts/L2/predeploys/BVM_MANTLE.sol index 429b3246c..09c1c69f5 100644 --- a/packages/contracts/contracts/L2/predeploys/BVM_MANTLE.sol +++ b/packages/contracts/contracts/L2/predeploys/BVM_MANTLE.sol @@ -25,11 +25,11 @@ contract BVM_MANTLE is L2StandardERC20 { {} - function transfer(address recipient, uint256 amount) public virtual override(ERC20,IERC20) returns (bool) { + function transfer(address recipient, uint256 amount) public virtual override(IERC20) returns (bool) { revert("BVM_MANTLE: transfer is disabled pending further community discussion."); } - function approve(address spender, uint256 amount) public virtual override(ERC20,IERC20) returns (bool) { + function approve(address spender, uint256 amount) public virtual override(IERC20) returns (bool) { revert("BVM_MANTLE: approve is disabled pending further community discussion."); } @@ -37,7 +37,7 @@ contract BVM_MANTLE is L2StandardERC20 { address sender, address recipient, uint256 amount - ) public virtual override(ERC20,IERC20) returns (bool) { + ) public virtual override(IERC20) returns (bool) { revert("BVM_MANTLE: transferFrom is disabled pending further community discussion."); } From c3dd7159bd0f8401d4f0c7564db9b66b71c8585f Mon Sep 17 00:00:00 2001 From: Shijiang Guo Date: Wed, 19 Jul 2023 19:08:52 +0800 Subject: [PATCH 2/6] [R4R]-{develop}: fix l2geth error judge (#1307) fix secure3 audit issure for err judge --- l2geth/core/state_transition.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l2geth/core/state_transition.go b/l2geth/core/state_transition.go index 5fe1cbc05..a4074755e 100644 --- a/l2geth/core/state_transition.go +++ b/l2geth/core/state_transition.go @@ -178,7 +178,7 @@ func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) (*StateTransition // state and would never be accepted within a block. func ApplyMessage(evm *vm.EVM, msg Message, gp *GasPool) ([]byte, uint64, bool, error) { stateTransition, err := NewStateTransition(evm, msg, gp) - if err == nil { + if err != nil { log.Error("apply message fall", "err", err) return nil, 0, false, err } From ae7b3038440f42f18b8dac9c5f5ae63835ce08b1 Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Wed, 19 Jul 2023 18:24:23 +0800 Subject: [PATCH 3/6] add nil pointer checker in traceCall --- l2geth/eth/api_tracer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l2geth/eth/api_tracer.go b/l2geth/eth/api_tracer.go index 37f2348c4..80c0f6619 100644 --- a/l2geth/eth/api_tracer.go +++ b/l2geth/eth/api_tracer.go @@ -554,7 +554,7 @@ func (api *PrivateDebugAPI) TraceCall(ctx context.Context, args ethapi.CallArgs, } // Override the fields of specified contracts before execution. - if config != nil { + if config != nil && config.StateOverrides != nil { for addr, account := range *config.StateOverrides { // Override account nonce. if account.Nonce != nil { From eb5506b6f1904b33d6565b609a457ca563008232 Mon Sep 17 00:00:00 2001 From: Grezle <4310551+grezle@users.noreply.github.com> Date: Thu, 20 Jul 2023 03:51:55 +0100 Subject: [PATCH 4/6] [R4R] - {sdk}: align standard-bridge with selected chain (#1268) fix(mantle-sdk): align standard-bridge with selected chain --- packages/sdk/src/adapters/standard-bridge.ts | 7 +++---- packages/sdk/src/utils/contracts.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/sdk/src/adapters/standard-bridge.ts b/packages/sdk/src/adapters/standard-bridge.ts index 59868cf99..efd02fccd 100644 --- a/packages/sdk/src/adapters/standard-bridge.ts +++ b/packages/sdk/src/adapters/standard-bridge.ts @@ -23,7 +23,7 @@ import { TokenBridgeMessage, MessageDirection, } from '../interfaces' -import { toAddress } from '../utils' +import { toAddress, L1_MNT_ADDRESS } from '../utils' /** * Bridge adapter for any token bridge that uses the standard token bridge interface. @@ -173,10 +173,9 @@ export class StandardBridgeAdapter implements IBridgeAdapter { return false } - // Make sure the L1 token matches. + // Make sure the L1 token matches the L1_MNT_ADDRESS associated with this l2ChainId const remoteL1Token = await contract.l1Token() - - if (hexStringEquals(remoteL1Token, toAddress('0x3c3a81e81dc49A522A592e7622A7E711c06bf354'))){ + if (hexStringEquals(remoteL1Token, toAddress(L1_MNT_ADDRESS[this.messenger.l2ChainId]))){ return true } diff --git a/packages/sdk/src/utils/contracts.ts b/packages/sdk/src/utils/contracts.ts index 5bf446ee3..5652a8b80 100644 --- a/packages/sdk/src/utils/contracts.ts +++ b/packages/sdk/src/utils/contracts.ts @@ -48,6 +48,20 @@ const NAME_REMAPPING = { WETH: 'WETH9' as const, } +/** + * Mapping of L2 chain IDs to MNT contract addresses to detect correct token in standard-bridge + */ +export const L1_MNT_ADDRESS: { + [ChainID in L2ChainID]: string +} = { + [L2ChainID.MANTLE]: "0x3c3a81e81dc49A522A592e7622A7E711c06bf354", + [L2ChainID.MANTLE_KOVAN]: "0x3c3a81e81dc49A522A592e7622A7E711c06bf354", + [L2ChainID.MANTLE_GOERLIQA]: "0x3c3a81e81dc49A522A592e7622A7E711c06bf354", + [L2ChainID.MANTLE_TESTNET]: "0xc1dC2d65A2243c22344E725677A3E3BEBD26E604", + [L2ChainID.MANTLE_HARDHAT_LOCAL]: "0x3c3a81e81dc49A522A592e7622A7E711c06bf354", + [L2ChainID.MANTLE_HARDHAT_DEVNET]: "0x3c3a81e81dc49A522A592e7622A7E711c06bf354" +} + /** * Mapping of L1 chain IDs to the appropriate contract addresses for the OE deployments to the * given network. Simplifies the process of getting the correct contract addresses for a given From ba9a7f7faf9c3807f0deee7a22d7c0eb4c314ec2 Mon Sep 17 00:00:00 2001 From: wb Date: Thu, 20 Jul 2023 10:53:45 +0800 Subject: [PATCH 5/6] [R4R] - {develop}: Log/txstatus element not found (#1264) * log: remove txstatus_element_not_found * log: handle nil pointer * api_backend: remove the unformatted space --------- Co-authored-by: Sha3n --- l2geth/eth/api_backend.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/l2geth/eth/api_backend.go b/l2geth/eth/api_backend.go index b90e37200..cb468c482 100644 --- a/l2geth/eth/api_backend.go +++ b/l2geth/eth/api_backend.go @@ -20,12 +20,12 @@ import ( "context" "errors" "fmt" - "github.com/mantlenetworkio/mantle/l2geth/consensus" "math/big" "github.com/mantlenetworkio/mantle/l2geth/accounts" "github.com/mantlenetworkio/mantle/l2geth/common" "github.com/mantlenetworkio/mantle/l2geth/common/math" + "github.com/mantlenetworkio/mantle/l2geth/consensus" "github.com/mantlenetworkio/mantle/l2geth/core" "github.com/mantlenetworkio/mantle/l2geth/core/bloombits" "github.com/mantlenetworkio/mantle/l2geth/core/rawdb" @@ -241,7 +241,7 @@ func (b *EthAPIBackend) GetReceipts(ctx context.Context, hash common.Hash) (type func (b *EthAPIBackend) GetTxStatusByHash(ctx context.Context, blockNumber uint64) (*types.TxStatusResponse, error) { txStatus, err := b.eth.syncService.GetTxStatusByNumber(blockNumber) if err != nil { - log.Error("GetTxStatusByHash", "status error", err.Error()) + log.Info("getTxStatusByHash", "msg", err.Error()) } return txStatus, err } From a037479051cb0ef9f9624ecd1bebb6ecdee97911 Mon Sep 17 00:00:00 2001 From: Tri-stone Date: Fri, 21 Jul 2023 11:59:58 +0800 Subject: [PATCH 6/6] [R4R]-{develop}-[gasoracle]impr: modify token_ratio from int64 to float64 for metrics (#1310) --- gas-oracle/metrics/metrics.go | 4 ++-- gas-oracle/oracle/l1_client.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gas-oracle/metrics/metrics.go b/gas-oracle/metrics/metrics.go index f7264467f..d64225db5 100644 --- a/gas-oracle/metrics/metrics.go +++ b/gas-oracle/metrics/metrics.go @@ -15,7 +15,7 @@ var ( // metrics for L1 base fee, L1 bas price, da fee // TokenRatioGauge token_ratio = eth_price / mnt_price - TokenRatioGauge metrics.Gauge + TokenRatioGauge metrics.GaugeFloat64 // L1BaseFeeGauge (l1_base_fee + l1_priority_fee) * token_ratio L1BaseFeeGauge metrics.Gauge // FeeScalarGauge value to scale the fee up by @@ -44,7 +44,7 @@ func InitAndRegisterStats(r metrics.Registry) { GasOracleStats.TxSendTimer = metrics.NewRegisteredTimer("tx/send", r) // stats for L1 base fee, L1 bas price, da fee - GasOracleStats.TokenRatioGauge = metrics.NewRegisteredGauge("token_ratio", r) + GasOracleStats.TokenRatioGauge = metrics.NewRegisteredGaugeFloat64("token_ratio", r) GasOracleStats.L1BaseFeeGauge = metrics.NewRegisteredGauge("l1_base_fee", r) GasOracleStats.FeeScalarGauge = metrics.NewRegisteredGauge("fee_scalar", r) GasOracleStats.DaFeeGauge = metrics.NewRegisteredGauge("da_fee", r) diff --git a/gas-oracle/oracle/l1_client.go b/gas-oracle/oracle/l1_client.go index 024650e2a..24ad769e0 100644 --- a/gas-oracle/oracle/l1_client.go +++ b/gas-oracle/oracle/l1_client.go @@ -53,7 +53,7 @@ func (c *L1Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types. tip.BaseFee = new(big.Int).Mul(new(big.Int).Add(bestBaseFee, gasTipCap), big.NewInt(int64(ratio))) log.Info("show base fee context", "bestBaseFee", bestBaseFee, "gasTipCap", gasTipCap, "ratio", ratio) ometrics.GasOracleStats.L1GasPriceGauge.Update(new(big.Int).Add(bestBaseFee, gasTipCap).Int64()) - ometrics.GasOracleStats.TokenRatioGauge.Update(int64(ratio)) + ometrics.GasOracleStats.TokenRatioGauge.Update(ratio) return tip, nil }