Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion node/db/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s *Store) ReadLatestDerivationL1Height() *uint64 {
panic(fmt.Sprintf("Failed to read batch index from database,err:%v", err))
}
if len(data) == 0 {
return new(uint64)
return nil
}

number := new(big.Int).SetBytes(data)
Expand Down
4 changes: 0 additions & 4 deletions node/derivation/batch_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import (
"morph-l2/node/types"
)

//type Chunk struct {
// blockContextes []*BlockContext
//}

type BlockContext struct {
Number uint64 `json:"number"`
Timestamp uint64 `json:"timestamp"`
Expand Down
2 changes: 0 additions & 2 deletions node/derivation/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ type Database interface {

type Reader interface {
ReadLatestDerivationL1Height() *uint64
//ReadLatestBatchBls() types.BatchBls
}

type Writer interface {
WriteLatestDerivationL1Height(latest uint64)
//WriteLatestBatchBls(batchBls types.BatchBls)
}
13 changes: 9 additions & 4 deletions node/derivation/derivation.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Derivation struct {

cancel context.CancelFunc

startHeight uint64
fetchBlockRange uint64
pollInterval time.Duration
logProgressInterval time.Duration
Expand Down Expand Up @@ -107,6 +108,7 @@ func NewDerivationClient(ctx context.Context, cfg *Config, syncer *sync.Syncer,
l2Client: types.NewRetryableClient(aClient, eClient, tmlog.NewTMLogger(tmlog.NewSyncWriter(os.Stdout))),
cancel: cancel,
stop: make(chan struct{}),
startHeight: cfg.StartHeight,
fetchBlockRange: cfg.FetchBlockRange,
pollInterval: cfg.PollInterval,
logProgressInterval: cfg.LogProgressInterval,
Expand Down Expand Up @@ -156,7 +158,12 @@ func (d *Derivation) Stop() {
func (d *Derivation) derivationBlock(ctx context.Context) {
latestDerivation := d.db.ReadLatestDerivationL1Height()
latest := d.syncer.LatestSynced()
start := *latestDerivation + 1
var start uint64
if latestDerivation == nil {
start = d.startHeight
} else {
start = *latestDerivation + 1
}
end := latest
if latest < start {
d.logger.Info("latest less than start", "latest", latest, "start", start)
Expand All @@ -170,9 +177,7 @@ func (d *Derivation) derivationBlock(ctx context.Context) {
d.logger.Error("eth_getLogs failed", "err", err)
return
}
latestBatchIndex, err := d.rollup.LastCommittedBatchIndex(&bind.CallOpts{
BlockNumber: big.NewInt(int64(latest)),
})
latestBatchIndex, err := d.rollup.LastCommittedBatchIndex(nil)
if err != nil {
d.logger.Error("query rollup latestCommitted batch Index failed", "err", err)
return
Expand Down