Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R4R]-{develop}:Optimize the rollup service #1301

Merged
merged 30 commits into from
Aug 2, 2023

Conversation

Ethanncnm
Copy link
Contributor

@Ethanncnm Ethanncnm commented Jul 18, 2023

Goals of PR

Core changes:

  • Add a timeout mechanism for mt-batcher. The new mechanism rely on new environment config RollupTimeout,
    MinTimeoutRollupTxn.

  • Delete the transaction size check for sequencer driver in batch-submitter. And change the size check to transaction amount check which rely on new environment config MaxRollupTxn and MinRollupTxn.

  • Delete the constrain of rollup mechanism which requires every rollup action must contains a L2 transaction at least.

  • Add a timeout transaction constrain for proposer in batch-submitter which rely on new environment config MinTimeoutStateRootElements.
    Notes:

  • MaxRollupTxn : Maximum number of transaction from l2geth which is used to submit to rollup.

  • MinRollupTxn : Minimum number of transaction from l2geth which is used to submit to rollup.

  • MinTimeoutStateRootElements: Minimum number of elements required to submit a state root batch.

  • RollupTimeout: Duration we will wait before rollup batch transaction to Mantle Da.

  • MinTimeoutRollupTxn : minimum of timeout Rollup transaction amount for Mantle da.
    Related Issues:

  • Link issues here


MinTimeoutRollupTxnFlag = cli.Uint64Flag{
Name: "min-rollup-txn-timeout",
Usage: "Rollup transaction timeout transactions for mantle da",
Copy link
Collaborator

@Tri-stone Tri-stone Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls modify these usages, can not understand what they are used for

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specific criterion for determining whether a Rollup can occur when a timeout happens:the minimum number of accumulated transactions that need to be met.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed

batch-submitter/config.go Show resolved Hide resolved
rangeLen := end.Uint64() - start.Uint64()
if rangeLen < d.cfg.MinStateRootElements {
rollupTxn := end.Uint64() - start.Uint64()
if rollupTxn < d.cfg.MinStateRootElements && (time.Now().Add(-d.cfg.RollupTimeout).Before(d.lastCommitTime) || rollupTxn < d.cfg.MinTimeoutStateRootElements) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Sub instead of Add maybe better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use sub will cost more code change.I suggest just use add.

@guoshijiang guoshijiang changed the title [WIP]:Optimize the rollup service [R4R]-{develop}:Optimize the rollup service Jul 26, 2023
mt-batcher/services/sequencer/driver.go Outdated Show resolved Hide resolved
mt-batcher/services/sequencer/driver.go Outdated Show resolved Hide resolved
batch-submitter/drivers/sequencer/encoding.go Outdated Show resolved Hide resolved
@@ -234,6 +236,22 @@ func (d *Driver) GetBatchBlockRange(ctx context.Context) (*big.Int, *big.Int, er
return start, end, nil
}

func (d *Driver) GetRollupTimeInterval(ctx context.Context, start *big.Int) (time.Duration, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (d *Driver) RollupTimeInterval(ctx context.Context) (*big.Int, *big.Int, error) {
	log.Debug("RollupTimeInterval start")
	pollingInterval := 500 * time.Millisecond
	rollupTimout := time.Minute * 15
	exit := time.NewTimer(rollupTimout)
	ticker := time.NewTicker(pollingInterval)
	for {
		// normal logic
		start, end, err := d.GetBatchBlockRange(d.Ctx)
		if err != nil {
			return nil, nil, err
		}
		return start, end, nil

		select {
		case <-exit.C:
			// timeout exit
		case <-ticker.C:
		}
	}
}

You can use this to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. And add function GetBatchBlockRangeWithTimeout

@@ -775,7 +782,10 @@ func (d *Driver) RollupMainWorker() {
for {
select {
case <-ticker.C:
log.Info("MtBatcher eigen da sequencer fetching current block range")
if d.Cfg.MinTimeoutRollupTxn > d.Cfg.RollUpMinTxn {
log.Error("MtBatcher MinTimeoutRollupTxn more than RollUpMinTxn error ", "MinTimeoutRollupTxn(%v)>RollUpMinTxn(%v)", d.Cfg.MinTimeoutRollupTxn, d.Cfg.RollUpMinTxn)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation of the log should be placed at the initialization of the service, and if it is unreasonable, then panic. Instead of repeatedly logging the same content in this loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. add function GetBatchBlockRangeWithTimeout.

wukongcheng
wukongcheng previously approved these changes Aug 1, 2023
byteflyfunny
byteflyfunny previously approved these changes Aug 2, 2023
guoshijiang
guoshijiang previously approved these changes Aug 2, 2023
@Sha3nS Sha3nS mentioned this pull request Aug 2, 2023
}
if cfg.MinTimeoutRollupTxn > cfg.RollUpMinTxn {
log.Error("new driver fail", "err", "MinTimeoutRollupTxn(%v)>RollUpMinTxn(%v)", cfg.MinTimeoutRollupTxn, cfg.RollUpMinTxn)
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error information is incorrect, it is recommended to use errors.new() to return an error

@wukongcheng wukongcheng merged commit ba52077 into develop Aug 2, 2023
1 of 4 checks passed
@wukongcheng wukongcheng deleted the ethan/rollup_service_optimize branch August 2, 2023 11:18
tw5428561 added a commit that referenced this pull request Aug 9, 2023
# Goals of PR

Core changes:

- modify for Rollup services optimization code. 

Notes:

- associated pr: #1301

Related Issues:

- no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants