Skip to content

Commit

Permalink
Release/v0.4.3 (#1324)
Browse files Browse the repository at this point in the history
# Goals of PR

Core changes:
merge release/v04.3 into main

Notes:
no

Related Issues:
no
  • Loading branch information
Sha3nS authored Aug 3, 2023
2 parents 0b7733c + 3b6e38e commit 17e97d7
Show file tree
Hide file tree
Showing 142 changed files with 1,517 additions and 1,523 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ There are plenty of ways to contribute, in particular we appreciate support in t
- Reporting issues. For security issues see [Security policy](https://github.com/mantlenetworkio/mantle/blob/main/SECURITY.md).
- Fixing and responding to existing issues. You can start off with those tagged ["good first issue"](https://github.com/mantlenetworkio/mantle/contribute) which are meant as introductory issues for external contributors.
- Improving the [documentation](https://github.com/mantlenetworkio/documents) and [tutorials](https://docs.mantle.xyz/network/for-devs/tutorials).
- Become an "Mantler" and answer questions in the [mantle Discord](https://discord.com/invite/0xMantle).
- Become a "Mantler" and answer questions in the [mantle Discord](https://discord.com/invite/0xMantle).
- Get involved in the protocol design process by proposing changes or new features or write parts of the spec yourself in the [mantle-specs](https://docs.mantle.xyz/network/intro/overview).

Note that we have a [Code of Conduct](https://github.com/mantlenetworkio/.github/blob/main/CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Mantle's modular architecture helps achieve greater network efficiency for resou

Different parts of the Mantle tech stack are specialized to tackle specific issues.

- [**Data Availability**](https://docs.mantle.xyz/introducing-mantle/a-gentle-introduction/solving-data-availability): Implementing EigenDA, an innovative re-staking solution that leverages Ethereum's validator network to bring the security of L1 to L2
- [**Data Availability**](https://docs.mantle.xyz/introducing-mantle/a-gentle-introduction/solving-data-availability): Data Availability powered by EigenDA technology, an innovative re-staking solution that leverages Ethereum's validator network to bring the security of L1 to L2
- [**EVM-level Fraud Proofs**](https://docs.mantle.xyz/introducing-mantle/a-gentle-introduction/fraud-proofs): Improved fraud proofs that are evaluated using EVM-level instructions

> We encourage you to check out the [**Mantle tech docs**](https://docs.mantle.xyz) to learn more about the inner workings of Mantle.
Expand Down Expand Up @@ -149,7 +149,7 @@ root
├── <a href="./bss-core">bss-core</a>: Core batch-submitter logic and utilities
├── <a href="./gas-oracle">gas-oracle</a>: Service for updating L1 gas prices on L2
├── <a href="./integration-tests">integration-tests</a>: Various integration tests for the Mantle network
├── <a href="./l2geth">l2geth</a>: Mantle client software, a fork of <a href="https://github.com/ethereum/go-ethereum/tree/v1.9.10">geth v1.9.10</a>
├── <a href="./l2geth">l2geth</a>: Mantle client software, a fork of <a href="https://github.com/ethereum/go-ethereum/tree/v1.9.10">geth v1.9.10</a> (deprecated for BEDROCK upgrade)
├── <a href="./l2geth-exporter">l2geth-exporter</a>: A prometheus exporter to collect/serve metrics from an L2 geth node
├── <a href="./proxyd">proxyd</a>: Configurable RPC request router and proxy
</pre>
Expand All @@ -165,4 +165,7 @@ Then check out our list of [good first issues](https://github.com/mantlenetworki

## License

Code forked from [`optimism`](https://github.com/ethereum-optimism) under the name [`optimism`](https://github.com/ethereum-optimism/optimism) is licensed under the [MIT License](https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt) in accordance with the [original license](https://github.com/ethereum/go-ethereum/blob/master/COPYING).
Code forked from [`optimism`](https://github.com/ethereum-optimism/optimism) under the name [`optimism`](https://github.com/mantlenetworkio/bitnetwork/tree/master/l2geth) is licensed under the [GNU GPLv3](https://gist.github.com/kn9ts/cbe95340d29fc1aaeaa5dd5c059d2e60) in accordance with the [original license](https://github.com/ethereum-optimism/optimism/blob/master/COPYING).


All other files within this repository are licensed under the [MIT License](https://github.com/mantlenetworkio/bitnetwork/blob/master/LICENSE) unless stated otherwise.
4 changes: 2 additions & 2 deletions batch-submitter/drivers/proposer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ func (d *Driver) RequestTssSignature(requestType uint64, start, offsetStartsAtIn
var tssResponse tssClient.TssResponse
tssReqParams := tss_types.SignStateRequest{
Type: requestType,
StartBlock: start.String(),
OffsetStartsAtIndex: offsetStartsAtIndex.String(),
StartBlock: start,
OffsetStartsAtIndex: offsetStartsAtIndex,
Challenge: challenge,
StateRoots: stateRoots,
}
Expand Down
3 changes: 3 additions & 0 deletions bss-core/metrics/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ type Metrics interface {

// TssRollbackSignal tracks the signal due to state fork between sequencer and varifier
TssRollbackSignal() prometheus.Gauge

// SccRollupTimeDuration state root rollup time duration
SccRollupTimeDuration() prometheus.Gauge
}
21 changes: 21 additions & 0 deletions bss-core/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ type Base struct {
// tssRollbackSignal indicate tss group force rollback or send signal to rollback l2geth
// due to a fork state root between sequencer and verifier
tssRollbackSignal prometheus.Gauge

// ctcRollupTimeDuration number of sequencer and enqueue rollup time duration
ctcRollupTimeDuration prometheus.Gauge

// sccRollupTimeDuration state root rollup time duration
sccRollupTimeDuration prometheus.Gauge
}

func NewBase(serviceName, subServiceName string) *Base {
Expand Down Expand Up @@ -105,6 +111,16 @@ func NewBase(serviceName, subServiceName string) *Base {
Help: "l2 rollback signal to indicate there is a fork state between sequencer and verifier",
Subsystem: subsystem,
}),
ctcRollupTimeDuration: promauto.NewGauge(prometheus.GaugeOpts{
Name: "ctc_rollup_time_duration",
Help: "",
Subsystem: subsystem,
}),
sccRollupTimeDuration: promauto.NewGauge(prometheus.GaugeOpts{
Name: "scc_rollup_time_duration",
Help: "state root rollup time duration",
Subsystem: subsystem,
}),
}
}

Expand Down Expand Up @@ -166,6 +182,11 @@ func (b *Base) TssRollbackSignal() prometheus.Gauge {
return b.tssRollbackSignal
}

// SccRollupTimeDuration state root rollup time duration
func (b *Base) SccRollupTimeDuration() prometheus.Gauge {
return b.sccRollupTimeDuration
}

// MakeSubsystemName builds the subsystem name for a group of metrics, which
// prometheus will use to prefix all metrics in the group. If two non-empty
// strings are provided, they are joined with an underscore. If only one
Expand Down
26 changes: 24 additions & 2 deletions bss-core/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,24 @@ func NewService(cfg ServiceConfig) *Service {
}
}

func (s *Service) InitService() error {
balance, err := s.cfg.L1Client.BalanceAt(
s.ctx, s.cfg.Driver.WalletAddr(), nil,
)
if err != nil {
log.Error(s.cfg.Driver.Name()+" unable to get current balance", "err", err)
return err
}
s.metrics.BalanceETH().Set(weiToEth64(balance))
return nil
}

func (s *Service) Start() error {
err := s.InitService()
if err != nil {
log.Error("Service init fail", "err", err)
return err
}
s.wg.Add(1)
go s.eventLoop()
return nil
Expand Down Expand Up @@ -186,8 +203,13 @@ func (s *Service) eventLoop() {
s.ctx, start, end, nonce,
)
if err != nil {
log.Error(name+" unable to craft batch tx",
"err", err)
if err.Error() == "malformed batch" {
log.Warn(name+" unable to craft batch tx",
"err", err)
} else {
log.Error(name+" unable to craft batch tx",
"err", err)
}
continue
} else if tx == nil {
continue
Expand Down
4 changes: 3 additions & 1 deletion bss-core/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ func (m *SimpleTxManager) Send(
tx, err := updateGasPrice(ctxc)
if err != nil {
if err == context.Canceled ||
strings.Contains(err.Error(), "context canceled") {
strings.Contains(err.Error(), "context canceled") ||
err.Error() == "execution reverted: EmptyAssertion" {
log.Warn(name+" unable to update txn gas price", "err", err)
return
}
log.Error(name+" unable to update txn gas price", "err", err)
Expand Down
45 changes: 24 additions & 21 deletions fraud-proof/LICENSE
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
(The MIT License)
// SPDX-License-Identifier: Apache-2.0

Copyright 2022-2023 Mantle

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Modifications Copyright 2022, Specular contributors
*
* This file was changed in accordance to Apache License, Version 2.0.
*
* Copyright 2021, Offchain Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Modifications Copyright 2023, Mantle contributors
*
* This file was changed in accordance to Apache License, Version 2.0.
*
4 changes: 2 additions & 2 deletions gas-oracle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $ make gas-oracle

### Running the service

Use the `--help` flag when running the `gas-oracle` to see it's configuration
Use the `--help` flag when running the `gas-oracle` to see its configuration
options.

```
Expand All @@ -49,7 +49,7 @@ VERSION:
0.0.0-1.10.4-stable
DESCRIPTION:
Configure with a private key and an Mantle HTTP endpoint to send transactions that update the L2 gas price.
Configure with a private key and a Mantle HTTP endpoint to send transactions that update the L2 gas price.
COMMANDS:
help, h Shows a list of commands or help for one command
Expand Down
2 changes: 1 addition & 1 deletion gas-oracle/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ var (
MetricsPortFlag = cli.IntFlag{
Name: "metrics.port",
Usage: "Metrics HTTP server listening port",
Value: 6060,
Value: 9107,
EnvVar: "GAS_PRICE_ORACLE_METRICS_PORT",
}
MetricsEnableInfluxDBFlag = cli.BoolFlag{
Expand Down
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/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ configuration file via:
$ geth --config /path/to/your_config.toml
```

To get an idea how the file should look like you can use the `dumpconfig` subcommand to
To get an idea of how the file should look like you can use the `dumpconfig` subcommand to
export your existing configuration:

```shell
Expand Down
9 changes: 7 additions & 2 deletions l2geth/accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/mantlenetworkio/mantle/l2geth/eth/filters"
"github.com/mantlenetworkio/mantle/l2geth/ethdb"
"github.com/mantlenetworkio/mantle/l2geth/event"
"github.com/mantlenetworkio/mantle/l2geth/log"
"github.com/mantlenetworkio/mantle/l2geth/params"
"github.com/mantlenetworkio/mantle/l2geth/rpc"
)
Expand Down Expand Up @@ -436,8 +437,12 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
// about the transaction and calling mechanisms.
vmenv := vm.NewEVM(evmContext, statedb, b.config, vm.Config{})
gaspool := new(core.GasPool).AddGas(math.MaxUint64)

return core.NewStateTransition(vmenv, msg, gaspool).TransitionDb()
stateTransition, err := core.NewStateTransition(vmenv, msg, gaspool)
if err != nil {
log.Error("new state transition fail", "err", err)
return nil, 0, false, err
}
return stateTransition.TransitionDb()
}

// SendTransaction updates the pending block to include the given transaction.
Expand Down
24 changes: 19 additions & 5 deletions l2geth/core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,31 @@ func IntrinsicGas(data []byte, contractCreation, isHomestead bool, isEIP2028 boo
}

// NewStateTransition initialises and returns a new state transition object.
func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition {
func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) (*StateTransition, error) {
l1Fee := new(big.Int)
daFee := new(big.Int)
var err error
gasPrice := msg.GasPrice()
if rcfg.UsingBVM {
if msg.GasPrice().Cmp(common.Big0) != 0 {
// Compute the L1 fee before the state transition
// so it only has to be read from state one time.
l1Fee, _ = fees.CalculateL1MsgFee(msg, evm.StateDB, nil)
l1Fee, err = fees.CalculateL1MsgFee(msg, evm.StateDB, nil)
if err != nil {
log.Error("calculate l1 message fee fail", "err", err)
return nil, err
}
charge := evm.StateDB.GetState(rcfg.L2GasPriceOracleAddress, rcfg.ChargeSlot).Big()
if charge.Cmp(common.Big0) == 0 {
gasPrice = common.Big0
}
daCharge := evm.StateDB.GetState(rcfg.L2GasPriceOracleAddress, rcfg.DaSwitchSlot).Big()
if daCharge.Cmp(common.Big1) == 0 {
daFee, _ = fees.CalculateDAMsgFee(msg, evm.StateDB, nil)
daFee, err = fees.CalculateDAMsgFee(msg, evm.StateDB, nil)
if err != nil {
log.Error("calculate mantle da message fee fail", "err", err)
return nil, err
}
}
}
}
Expand All @@ -157,7 +166,7 @@ func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition
state: evm.StateDB,
l1Fee: l1Fee,
daFee: daFee,
}
}, nil
}

// ApplyMessage computes the new state by applying the given message
Expand All @@ -168,7 +177,12 @@ func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition
// indicates a core error meaning that the message would always fail for that particular
// state and would never be accepted within a block.
func ApplyMessage(evm *vm.EVM, msg Message, gp *GasPool) ([]byte, uint64, bool, error) {
return NewStateTransition(evm, msg, gp).TransitionDb()
stateTransition, err := NewStateTransition(evm, msg, gp)
if err != nil {
log.Error("apply message fall", "err", err)
return nil, 0, false, err
}
return stateTransition.TransitionDb()
}

// to returns the recipient of the message.
Expand Down
20 changes: 7 additions & 13 deletions l2geth/core/upgrade/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"math/big"
"testing"

"github.com/stretchr/testify/require"

"github.com/mantlenetworkio/mantle/l2geth/params"
)

Expand Down Expand Up @@ -87,26 +89,18 @@ func TestConfig_IsEigenDa(t *testing.T) {

func TestConfig_IsUpdateGasLimitBlock(t *testing.T) {
upgradeConfig := NewMantleUpgradeConfig(params.MantleMainnetChainID)
result := upgradeConfig.IsUpdateGasLimitBlock(big.NewInt(222_073))
if result {
t.Error("update gaslimit upgrade could not used for mainnet")
}
result := upgradeConfig.IsUpdateGasLimitBlock(big.NewInt(222_073)) && (upgradeConfig.chainID == params.MantleTestnetChainID)
require.Equal(t, result, false, "update gaslimit upgrade could not used for mainnet")

upgradeConfig = NewMantleUpgradeConfig(params.MantleTestnetChainID)
result = upgradeConfig.IsUpdateGasLimitBlock(big.NewInt(222_073))
if !result {
t.Error("update gaslimit upgrade should used for testnet")
}
require.Equal(t, result, true, "update gaslimit upgrade should used for testnet")

upgradeConfig = NewMantleUpgradeConfig(params.MantleTestnetChainID)
result = upgradeConfig.IsUpdateGasLimitBlock(big.NewInt(222_074))
if !result {
t.Error("update gaslimit upgrade take effect after 222_073")
}
require.Equal(t, result, true, "update gaslimit upgrade take effect after 222_073")

upgradeConfig = NewMantleUpgradeConfig(params.MantleTestnetChainID)
result = upgradeConfig.IsUpdateGasLimitBlock(big.NewInt(222_072))
if result {
t.Error("update gaslimit upgrade height does not reach to")
}
require.Equal(t, result, false, "update gaslimit upgrade height does not reach to")
}
3 changes: 3 additions & 0 deletions l2geth/core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
return nil, common.Address{}, gas, ErrInsufficientBalance
}
nonce := evm.StateDB.GetNonce(caller.Address())
if nonce+1 < nonce {
return nil, common.Address{}, gas, ErrNonceUintOverflow
}
evm.StateDB.SetNonce(caller.Address(), nonce+1)
// We add this to the access list _before_ taking a snapshot. Even if the creation fails,
// the access-list change should not be rolled back
Expand Down
Loading

0 comments on commit 17e97d7

Please sign in to comment.