Skip to content

Commit

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

Core changes:

### Features
- Changed the rollup method from Layer1 CTC contract to
EigenDA([#779](#779))
- Added support for data verification and recovery based on DA‘s api
service in the Verifier
node([#803](#803))

### Improvements
- Optimized re-rollup
process([#789](#789))
- Optimized code for contract
upgrades([#798](#798))
  • Loading branch information
agnarsong authored Apr 14, 2023
2 parents 2b6d540 + cc00a78 commit 0b1f375
Show file tree
Hide file tree
Showing 64 changed files with 5,018 additions and 700 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Changelog
## [0.3.1] - 2023-04-13

## [0.3.0] - 2023-02-20
### Features
- Changed the rollup method from Layer1 CTC contract to EigenDA([#779](https://github.com/mantlenetworkio/mantle/pull/779))
- Added support for data verification and recovery based on DA‘s api service in the Verifier node([#803](https://github.com/mantlenetworkio/mantle/pull/803))

### Improvements
- Optimized re-rollup process([#789](https://github.com/mantlenetworkio/mantle/pull/789))
- Optimized code for contract upgrades([#798](https://github.com/mantlenetworkio/mantle/pull/798))

## [0.3.0](https://github.com/mantlenetworkio/mantle/commits/v0.3.0) - 2023-03-16

### Features
- Verifier syncs data from the DA network, verifies and generates new blocks([#638](https://github.com/mantlenetworkio/mantle/pull/638))
Expand Down Expand Up @@ -72,4 +81,4 @@
- MPC validators module in Layer 2 network, to minimize the trust risk of L2 execution results by threshold signature scheme(TSS).
- Native Token replacement in Layer 2 Network, to empower BitDAO's ecosystem by replacing the native token with BIT.
- Token Reward, to inspire community, organization and individual to run a l2geth-node and TSS-node.
- Gas fee adjustment, the Bit destruction mechanism will be triggered after collecting enough GasFee in the special contract.
- Gas fee adjustment, the Bit destruction mechanism will be triggered after collecting enough GasFee in the special contract.
20 changes: 19 additions & 1 deletion batch-submitter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ LDFLAGS := -ldflags "$(LDFLAGSSTRING)"

CTC_ABI_ARTIFACT := ../packages/contracts/artifacts/contracts/L1/rollup/CanonicalTransactionChain.sol/CanonicalTransactionChain.json
SCC_ABI_ARTIFACT := ../packages/contracts/artifacts/contracts/L1/rollup/StateCommitmentChain.sol/StateCommitmentChain.json
DA_ABI_ARTIFACT := ../packages/contracts/artifacts/contracts/da/BVM_EigenDataLayrChain.sol/BVM_EigenDataLayrChain.json

batch-submitter:
env GO111MODULE=on go build -v $(LDFLAGS) ./cmd/batch-submitter
Expand All @@ -22,7 +23,7 @@ test:
lint:
golangci-lint run ./...

bindings: bindings-ctc bindings-scc
bindings: bindings-ctc bindings-scc bindings-da

bindings-ctc:
$(eval temp := $(shell mktemp))
Expand Down Expand Up @@ -56,11 +57,28 @@ bindings-scc:

rm $(temp)

bindings-da:
$(eval temp := $(shell mktemp))

cat $(DA_ABI_ARTIFACT) \
| jq -r .bytecode > $(temp)

cat $(DA_ABI_ARTIFACT) \
| jq .abi \
| abigen --pkg da \
--abi - \
--out bindings/da/bvm_eigen_datalayr_chain.go \
--type BVM_EigenDataLayrChain \
--bin $(temp)

rm $(temp)

.PHONY: \
batch-submitter \
bindings \
bindings-ctc \
bindings-scc \
bindings-da \
clean \
test \
lint
4 changes: 4 additions & 0 deletions batch-submitter/batch_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package batchsubmitter

import (
"context"
ethc "github.com/ethereum/go-ethereum/common"
"github.com/mantlenetworkio/mantle/l2geth/common"
"os"
"time"

Expand Down Expand Up @@ -132,6 +134,8 @@ func Main(gitVersion string) func(ctx *cli.Context) error {
MinTxSize: cfg.MinL1TxSize,
MaxTxSize: cfg.MaxL1TxSize,
MaxPlaintextBatchSize: cfg.MaxPlaintextBatchSize,
DaUpgradeBlock: cfg.DaUpgradeBlock,
DAAddr: ethc.Address(common.HexToAddress(cfg.DAAddress)),
CTCAddr: ctcAddress,
ChainID: chainID,
PrivKey: sequencerPrivKey,
Expand Down
60 changes: 56 additions & 4 deletions batch-submitter/bindings/ctc/canonical_transaction_chain.go

Large diffs are not rendered by default.

1,868 changes: 1,868 additions & 0 deletions batch-submitter/bindings/da/bvm_eigen_datalayr_chain.go

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions batch-submitter/bindings/scc/state_commitment_chain.go

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions batch-submitter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ type Config struct {
// Tss manager client Url
TssClientUrl string

// eigen layer upgrade block.
DaUpgradeBlock uint64

// DAAddress is the CTC contract address.
DAAddress string

// CTCAddress is the CTC contract address.
CTCAddress string

Expand Down Expand Up @@ -207,6 +213,8 @@ func NewConfig(ctx *cli.Context) (Config, error) {
L1EthRpc: ctx.GlobalString(flags.L1EthRpcFlag.Name),
L2EthRpc: ctx.GlobalString(flags.L2EthRpcFlag.Name),
TssClientUrl: ctx.GlobalString(flags.TssClientUrl.Name),
DaUpgradeBlock: ctx.GlobalUint64(flags.DaUpgradeBlockFlag.Name),
DAAddress: ctx.GlobalString(flags.DaAddressFlag.Name),
CTCAddress: ctx.GlobalString(flags.CTCAddressFlag.Name),
SCCAddress: ctx.GlobalString(flags.SCCAddressFlag.Name),
MinL1TxSize: ctx.GlobalUint64(flags.MinL1TxSizeFlag.Name),
Expand Down
4 changes: 0 additions & 4 deletions batch-submitter/drivers/sequencer/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package sequencer
import (
"errors"
"fmt"

l2types "github.com/mantlenetworkio/mantle/l2geth/core/types"
)

Expand Down Expand Up @@ -79,7 +78,6 @@ func GenSequencerBatchParams(
blockOffset uint64,
batch []BatchElement,
) (*AppendSequencerBatchParams, error) {

var (
contexts []BatchContext
groupedBlocks []groupedBlock
Expand All @@ -88,7 +86,6 @@ func GenSequencerBatchParams(
lastTimestamp uint64
lastBlockNumber uint64
)

// Iterate over the batch elements, grouping the elements according to
// the following criteria:
// - All txs in the same group must have the same timestamp.
Expand Down Expand Up @@ -182,7 +179,6 @@ func GenSequencerBatchParams(
BlockNumber: blockNumber,
})
}

return &AppendSequencerBatchParams{
ShouldStartAtElement: shouldStartAtElement - blockOffset,
TotalElementsToAppend: uint64(len(batch)),
Expand Down
78 changes: 59 additions & 19 deletions batch-submitter/drivers/sequencer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"math/big"
"strings"

"github.com/ethereum/go-ethereum"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -16,6 +16,7 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/mantlenetworkio/mantle/batch-submitter/bindings/ctc"
"github.com/mantlenetworkio/mantle/batch-submitter/bindings/da"
"github.com/mantlenetworkio/mantle/bss-core/drivers"
"github.com/mantlenetworkio/mantle/bss-core/metrics"
"github.com/mantlenetworkio/mantle/bss-core/txmgr"
Expand All @@ -37,18 +38,23 @@ type Config struct {
MaxTxSize uint64
MaxPlaintextBatchSize uint64
CTCAddr common.Address
DaUpgradeBlock uint64
DAAddr common.Address
ChainID *big.Int
PrivKey *ecdsa.PrivateKey
BatchType BatchType
}

type Driver struct {
cfg Config
ctcContract *ctc.CanonicalTransactionChain
rawCtcContract *bind.BoundContract
walletAddr common.Address
ctcABI *abi.ABI
metrics *Metrics
cfg Config
ctcContract *ctc.CanonicalTransactionChain
daContract *da.BVMEigenDataLayrChain
rawCtcContract *bind.BoundContract
rawDaCtcContract *bind.BoundContract
walletAddr common.Address
ctcABI *abi.ABI
DaABI *abi.ABI
metrics *Metrics
}

func NewDriver(cfg Config) (*Driver, error) {
Expand Down Expand Up @@ -76,15 +82,41 @@ func NewDriver(cfg Config) (*Driver, error) {
cfg.L1Client,
)

daContract, err := da.NewBVMEigenDataLayrChain(
cfg.DAAddr, cfg.L1Client,
)
if err != nil {
return nil, err
}
daParsed, err := abi.JSON(strings.NewReader(
da.BVMEigenDataLayrChainABI,
))
if err != nil {
return nil, err
}

daABI, err := da.BVMEigenDataLayrChainMetaData.GetAbi()
if err != nil {
return nil, err
}

rawDaCtcContract := bind.NewBoundContract(
cfg.DAAddr, daParsed, cfg.L1Client, cfg.L1Client,
cfg.L1Client,
)

walletAddr := crypto.PubkeyToAddress(cfg.PrivKey.PublicKey)

return &Driver{
cfg: cfg,
ctcContract: ctcContract,
rawCtcContract: rawCtcContract,
walletAddr: walletAddr,
ctcABI: ctcABI,
metrics: NewMetrics(cfg.Name),
cfg: cfg,
ctcContract: ctcContract,
daContract: daContract,
rawCtcContract: rawCtcContract,
rawDaCtcContract: rawDaCtcContract,
walletAddr: walletAddr,
ctcABI: ctcABI,
DaABI: daABI,
metrics: NewMetrics(cfg.Name),
}, nil
}

Expand Down Expand Up @@ -139,15 +171,23 @@ func (d *Driver) GetBatchBlockRange(
if err != nil {
return nil, nil, err
}

// Add one because end is *exclusive*.
end := new(big.Int).Add(latestHeader.Number, bigOne)

var end *big.Int
// for upgrade
if latestHeader.Number.Cmp(big.NewInt(int64(d.cfg.DaUpgradeBlock))) < 0 {
// Add one because end is *exclusive*.
end = new(big.Int).Add(latestHeader.Number, bigOne)
} else {
end, err = d.daContract.GetL2ConfirmedBlockNumber(&bind.CallOpts{
Context: context.Background(),
})
if err != nil {
return nil, nil, err
}
}
if start.Cmp(end) > 0 {
return nil, nil, fmt.Errorf("invalid range, "+
"end(%v) < start(%v)", end, start)
}

return start, end, nil
}

Expand Down Expand Up @@ -214,7 +254,7 @@ func (d *Driver) CraftBatchTx(
}

// Encode the batch arguments using the configured encoding type.
batchArguments, err := batchParams.Serialize(d.cfg.BatchType)
batchArguments, err := batchParams.Serialize(d.cfg.BatchType, start, big.NewInt(int64(d.cfg.DaUpgradeBlock)))
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 0b1f375

Please sign in to comment.