Skip to content

Commit

Permalink
Merge branch 'develop' into ethan/rollup_service_optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethanncnm committed Jul 21, 2023
2 parents 969590e + a037479 commit 3fed71b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
4 changes: 2 additions & 2 deletions gas-oracle/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gas-oracle/oracle/l1_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion l2geth/core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions l2geth/eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion l2geth/eth/api_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/contracts/L2/predeploys/BVM_MANTLE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ 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.");
}

function transferFrom(
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.");
}

Expand Down
7 changes: 3 additions & 4 deletions packages/sdk/src/adapters/standard-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down
14 changes: 14 additions & 0 deletions packages/sdk/src/utils/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3fed71b

Please sign in to comment.