Skip to content

Commit

Permalink
[R4R]-{changelog}: add change log for v0.4.3-alpha.0 (#1325)
Browse files Browse the repository at this point in the history
# Goals of PR

Core changes:
add change log for v0.4.3-alpha.0
merge main into develop

Notes:
no

Related Issues:
no
  • Loading branch information
Sha3nS authored Aug 9, 2023
2 parents 2562dab + 78091f2 commit 446e2af
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ ops/data/**
dist/
packages/contracts/test/data/
packages/contracts/abi/
gas-oracle/gas-oracle-data/
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Changelog

## [v0.4.3-alpha.0](https://github.com/mantlenetworkio/mantle/commits/v0.4.3-alpha.0) - 2023-08-03

### Features
- DTL
- Optimized performance by separating L1 and L2 process execution time for synchronous data ([#1298](https://github.com/mantlenetworkio/mantle/pull/1298))
- SDK
- Enhanced compatibility by aligning the standard-bridge with the selected chainID ([#1268](https://github.com/mantlenetworkio/mantle/pull/1268))
- GasOracle
- Improved metric accuracy by modifying token_ratio ([#1310](https://github.com/mantlenetworkio/mantle/pull/1310))

### Bug Fixes
- Resolved a 'nonce too high' error caused by the DA verifier([#1313](https://github.com/mantlenetworkio/mantle/pull/1313))
- Fixed a panic issue during traceCall operation, eliminating unexpected program crashes ([#1305](https://github.com/mantlenetworkio/mantle/pull/1305))
- Handled unhandled errors in DA upgrade tool and NewStateTransition of l2geth, enhancing error handling and preventing potential issues ([#1288](https://github.com/mantlenetworkio/mantle/pull/1288), [#1295](https://github.com/mantlenetworkio/mantle/pull/1295))
- Strengthened seed generation process security by introducing passphrase protection ([#1297](https://github.com/mantlenetworkio/mantle/pull/1297))
- Addressed nonce overflow and other security-related concerns, bolstering system security ([#1293](https://github.com/mantlenetworkio/mantle/pull/1293), [#1292](https://github.com/mantlenetworkio/mantle/pull/1292))
- Improved JWT secret key configuration and handling for enhanced security ([#1226](https://github.com/mantlenetworkio/mantle/pull/1226))
- Renamed 'rollup' to 'Accepted on layer1', enhancing clarity and reflecting its role in the network's hierarchy ([#1314](https://github.com/mantlenetworkio/mantle/pull/1314))
- Resolved the issue of the 'Log/txstatus' element not found, addressing a gap in log information ([#1264](https://github.com/mantlenetworkio/mantle/pull/1264))
- Cleaned up unused DA contracts, optimizing the codebase by removing redundant contracts ([#1283](https://github.com/mantlenetworkio/mantle/pull/1283))
- Rectified Mantle token compilation errors on the Foundry platform, ensuring successful compilation ([#1282](https://github.com/mantlenetworkio/mantle/pull/1282))
- Fixed go mod and mt-challenger configuration issues, modified 'WMANTLE9' to 'WMANTLE' for compatibility and clarity ([#1302](https://github.com/mantlenetworkio/mantle/pull/1302), [#1281](https://github.com/mantlenetworkio/mantle/pull/1281))
- Addressed 'sigma MNT-35' issue, conducted a TSS security audit fix, ensuring accurate handling of 'sigma MNT-35' and enhancing TSS security ([#1257](https://github.com/mantlenetworkio/mantle/pull/1257))
- Fixed ConsenSys audit issue: cs-6.18, ensuring compliance with audit requirements ([#1243](https://github.com/mantlenetworkio/mantle/pull/1243))
- Addressed various ConsenSys audit issues (cs-6.30, cs-6.42, cs-6.40, cs-6.37, cs-6.14, cs-6.34, cs-6.22, cs-6.33), ensuring codebase compliance ([#1219](https://github.com/mantlenetworkio/mantle/pull/1219), [#1212](https://github.com/mantlenetworkio/mantle/pull/1212), [#1210](https://github.com/mantlenetworkio/mantle/pull/1210), [#1207](https://github.com/mantlenetworkio/mantle/pull/1207), [#1204](https://github.com/mantlenetworkio/mantle/pull/1204), [#1194](https://github.com/mantlenetworkio/mantle/pull/1194), [#1191](https://github.com/mantlenetworkio/mantle/pull/1191), [#1188](https://github.com/mantlenetworkio/mantle/pull/1188))
- Resolved lock threshold validation issue, enhancing security and preventing potential vulnerabilities ([#1227](https://github.com/mantlenetworkio/mantle/pull/1227))
- Fixed jwt secret key configuration issue, improving the handling of secret keys ([#1226](https://github.com/mantlenetworkio/mantle/pull/1226))
- Resolved ConsenSys minor audit issues (cs-6.35, cs-6.43, cs-6.44, cs-6.45), ensuring adherence to audit recommendations ([#1217](https://github.com/mantlenetworkio/mantle/pull/1217), [#1183](https://github.com/mantlenetworkio/mantle/pull/1183))
- Removed unused struct related to 'mnt-37', added a default message handler for function ProcessOneMessage:cs-6.26 ([#1202](https://github.com/mantlenetworkio/mantle/pull/1202), [#1198](https://github.com/mantlenetworkio/mantle/pull/1198))


## [v0.4.2](https://github.com/mantlenetworkio/mantle/commits/v0.4.2) - 2023-07-10

### Features
Expand Down
Binary file not shown.
Binary file not shown.
Binary file added audits/Mantle Secure3 Audit Report.pdf
Binary file not shown.
Binary file added audits/Mantle Sigma Prime Review.pdf
Binary file not shown.
Binary file not shown.
Binary file added audits/Mantle Zellic Audit Report.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions gas-oracle/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ var (
Usage: "Setup StateRollupGasUsed",
EnvVar: "GAS_PRICE_ORACLE_STATE_ROLLUP_GAS_USED",
}
StateHashGasUsed = cli.IntFlag{
Name: "set-state-hash-gas-used",
Value: 1412,
Usage: "Setup StateHashGasUsed",
EnvVar: "GAS_PRICE_ORACLE_STATE_HASH_GAS_USED",
}
DataRollupGasUsed = cli.IntFlag{
Name: "set-data-rollup-gas-used",
Value: 137893,
Expand Down Expand Up @@ -323,6 +329,7 @@ var Flags = []cli.Flag{
BatchSizeCap,
SizeGap,
StateRollupGasUsed,
StateHashGasUsed,
DataRollupGasUsed,
EnableHsmFlag,
HsmAddressFlag,
Expand Down
2 changes: 2 additions & 0 deletions gas-oracle/oracle/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Config struct {
batchSizeCap int
sizeGap int
stateRollupGasUsed *big.Int
stateHashGasUsed *big.Int
dataRollupGasUsed *big.Int
// Metrics config
MetricsEnabled bool
Expand Down Expand Up @@ -108,6 +109,7 @@ func NewConfig(ctx *cli.Context) *Config {
cfg.batchSizeBottom = ctx.GlobalInt(flags.BatchSizeBottom.Name)
cfg.sizeGap = ctx.GlobalInt(flags.SizeGap.Name)
cfg.stateRollupGasUsed = big.NewInt(ctx.GlobalInt64(flags.StateRollupGasUsed.Name))
cfg.stateHashGasUsed = big.NewInt(ctx.GlobalInt64(flags.StateHashGasUsed.Name))
cfg.dataRollupGasUsed = big.NewInt(ctx.GlobalInt64(flags.DataRollupGasUsed.Name))

if cfg.EnableHsm {
Expand Down
98 changes: 91 additions & 7 deletions gas-oracle/oracle/gas_price_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package oracle

import (
"context"
"encoding/binary"
"errors"
"fmt"
"math/big"
Expand All @@ -17,8 +18,12 @@ import (
"github.com/mantlenetworkio/mantle/gas-oracle/gasprices"
ometrics "github.com/mantlenetworkio/mantle/gas-oracle/metrics"
"github.com/mantlenetworkio/mantle/gas-oracle/tokenprice"
"github.com/mantlenetworkio/mantle/l2geth/core/rawdb"
"github.com/mantlenetworkio/mantle/l2geth/ethdb"
)

const GAS_ORACLE_SYNC_HEIGHT = "GAS_ORACLE_SYNC_HEIGHT"

var (
// errInvalidSigningKey represents the error when the signing key used
// is not the Owner of the contract and therefore cannot update the gasprice
Expand Down Expand Up @@ -194,12 +199,16 @@ func (g *GasPriceOracle) DaFeeLoop() {
}

func (g *GasPriceOracle) OverHeadLoop() {
// set ticker
ticker := time.NewTicker(5 * time.Second)

// read gas-oracle synced height
db, height := readGasOracleSyncHeight()
log.Info("ReadGasOracleSyncHeight", "height", height)
// set channel
stateBatchAppendChan := make(chan *bindings.StateCommitmentChainStateBatchAppended, 10)
stateAppendSub, err := g.sccBackend.WatchStateBatchAppended(&bind.WatchOpts{Context: g.ctx}, stateBatchAppendChan, nil)
if err != nil {
panic(err)
}
defer stateAppendSub.Unsubscribe()

// set context
ctcTotalBatches, err := g.ctcBackend.GetTotalBatches(&bind.CallOpts{})
if err != nil {
panic(err)
Expand All @@ -209,8 +218,41 @@ func (g *GasPriceOracle) OverHeadLoop() {
panic(err)
}

var end uint64
for {
select {
case <-ticker.C:
log.Info("OverHeadLoop is living, HeartBeat It!")
latestHeader, err := g.l1Backend.HeaderByNumber(g.ctx, nil)
if err != nil {
log.Warn("get latest header in error", "error", err)
continue
}
// repeat query latest block is not allowed
if height != nil && height.Uint64() != 0 && height.Uint64() == latestHeader.Number.Uint64() {
continue
}
if height == nil || height.Uint64() == 0 {
height = latestHeader.Number
}
end = latestHeader.Number.Uint64()

iter, err := g.sccBackend.FilterStateBatchAppended(&bind.FilterOpts{
Start: height.Uint64(),
End: &end,
Context: g.ctx,
}, nil)
for iter.Next() {
select {
case stateBatchAppendChan <- iter.Event:
log.Info("write event into channel", "channel length is", len(stateBatchAppendChan))
default:
log.Error("write too many event into channel, increase channel length")
}
}
_ = writeGasOracleSyncHeight(db, latestHeader.Number)
height = latestHeader.Number
log.Info("Update synced height", "height", height)
case ev := <-stateBatchAppendChan:
currentCtcBatches, err := g.ctcBackend.GetTotalBatches(&bind.CallOpts{})
if err != nil {
Expand All @@ -219,10 +261,11 @@ func (g *GasPriceOracle) OverHeadLoop() {
log.Info("current scc batch size", "size", ev.BatchSize)
log.Info("CTC circle num in SCC circle", "count", new(big.Int).Sub(currentCtcBatches, ctcTotalBatches))
if err := updateOverhead(new(big.Int).Sub(currentCtcBatches, ctcTotalBatches), ev.BatchSize); err != nil {
log.Error("cannot update da fee", "messgae", err)
log.Error("cannot update overhead", "message", err)
}
ctcTotalBatches = currentCtcBatches
case <-g.ctx.Done():
db.Close()
g.Stop()
}
}
Expand Down Expand Up @@ -266,7 +309,7 @@ func NewGasPriceOracle(cfg *Config) (*GasPriceOracle, error) {
return nil, err
}

l1Client, err := NewL1Client(cfg.ethereumWssUrl, tokenPricer)
l1Client, err := NewL1Client(cfg.ethereumHttpUrl, tokenPricer)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -435,3 +478,44 @@ func ensureConnection(client *ethclient.Client) error {
}
return nil
}

func readGasOracleSyncHeight() (ethdb.Database, *big.Int) {
// read synced height
db, err := rawdb.NewLevelDBDatabase("gas-oracle-data", 0, 0, "")
if err != nil {
log.Error("NewLevelDBDatabase in error", "err", err)
panic(err)
}
// will close connection at once
//defer db.Close()

has, err := db.Has([]byte(GAS_ORACLE_SYNC_HEIGHT))
if err != nil {
log.Error("check db has GAS_ORACLE_SYNC_HEIGHT in error", "err", err)
panic(err)
}
if !has {
return db, nil
}

height, err := db.Get([]byte(GAS_ORACLE_SYNC_HEIGHT))
if err != nil {
log.Error("check db Get GAS_ORACLE_SYNC_HEIGHT in error", "err", err)
panic(err)
}
return db, big.NewInt(0).SetUint64(binary.BigEndian.Uint64(height))
}

func writeGasOracleSyncHeight(db ethdb.Database, height *big.Int) error {
// will close connection at once
//defer db.Close()

var indexBz = make([]byte, 8)
binary.BigEndian.PutUint64(indexBz, height.Uint64())
err := db.Put([]byte(GAS_ORACLE_SYNC_HEIGHT), indexBz)
if err != nil {
log.Error("put GAS_ORACLE_SYNC_HEIGHT in error", "err", err)
return err
}
return nil
}
2 changes: 1 addition & 1 deletion gas-oracle/oracle/overhead.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func calculateJumpTable(diff *big.Int, cfg *Config) {
// calculate jump table
for levelSize := cfg.batchSizeBottom; levelSize <= cfg.batchSizeCap; {
orderedSizes = append(orderedSizes, levelSize)
jumpTable[levelSize] = new(big.Int).Add(new(big.Int).Div(OverheadGasUsedOnL1, new(big.Int).SetUint64(uint64(levelSize))), new(big.Int).SetUint64(1330))
jumpTable[levelSize] = new(big.Int).Add(new(big.Int).Div(OverheadGasUsedOnL1, new(big.Int).SetUint64(uint64(levelSize))), cfg.stateHashGasUsed)
levelSize += cfg.sizeGap
}
}
Expand Down
7 changes: 7 additions & 0 deletions l2geth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ GOBIN = ./build/bin
GO ?= latest
GORUN = env GO111MODULE=on go run

# workaround for datalayr, remove in the future
geth:
@echo "exclude github.com/Layr-Labs/datalayr/common v0.0.0" >> go.mod
@echo "exclude github.com/Layr-Labs/datalayr/lib/merkzg v0.0.0" >> go.mod
$(GORUN) build/ci.go install ./cmd/geth
@echo "Done building."
@echo "Run \"$(GOBIN)/geth\" to launch geth."
@sed -i.a '/^exclude.*datalayr/d' go.mod && rm -f go.mod.a

all:
@echo "exclude github.com/Layr-Labs/datalayr/common v0.0.0" >> go.mod
@echo "exclude github.com/Layr-Labs/datalayr/lib/merkzg v0.0.0" >> go.mod
$(GORUN) build/ci.go install
@sed -i.a '/^exclude.*datalayr/d' go.mod && rm -f go.mod.a

android:
$(GORUN) build/ci.go aar --local
Expand Down

0 comments on commit 446e2af

Please sign in to comment.