Skip to content

Commit

Permalink
reimplement stateroot
Browse files Browse the repository at this point in the history
  • Loading branch information
Intizar-T committed Dec 10, 2024
1 parent 76942aa commit 5dc3c9a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
36 changes: 23 additions & 13 deletions sequencer/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,14 @@ type Config struct {
}

type fromBatch struct {
BatchNum common.BatchNum
ForgerAddr ethCommon.Address
AccountStateRoot *big.Int
VouchStateRoot *big.Int
ScoreStateRoot *big.Int
BatchNum common.BatchNum
ForgerAddr ethCommon.Address

// TODO: implement
StateRoot *big.Int
// AccountStateRoot *big.Int
// VouchStateRoot *big.Int
// ScoreStateRoot *big.Int
}

// Coordinator implements the Coordinator type
Expand Down Expand Up @@ -264,11 +267,14 @@ func NewCoordinator(cfg Config,
c := Coordinator{
pipelineNum: 0,
pipelineFromBatch: fromBatch{
BatchNum: 0,
ForgerAddr: ethCommon.Address{},
AccountStateRoot: big.NewInt(0),
VouchStateRoot: big.NewInt(0),
ScoreStateRoot: big.NewInt(0),
BatchNum: 0,
ForgerAddr: ethCommon.Address{},

// TODO: implement
StateRoot: big.NewInt(0),
// AccountStateRoot: big.NewInt(0),
// VouchStateRoot: big.NewInt(0),
// ScoreStateRoot: big.NewInt(0),
},
prover: prover,
consts: *scConsts,
Expand Down Expand Up @@ -465,16 +471,20 @@ func (c *Coordinator) syncStats(ctx context.Context, stats *synchronizer.Stats)
ForgerAddr: stats.Sync.LastBatch.ForgerAddr,

// TODO: implement
StateRoot: stats.Sync.LastBatch.StateRoot,
// AccountStateRoot: stats.Sync.LastBatch.AccountStateRoot,
// VouchStateRoot: stats.Sync.LastBatch.VouchStateRoot,
// ScoreStateRoot: stats.Sync.LastBatch.ScoreStateRoot,
}
if c.lastNonFailedBatchNum > fromBatch.BatchNum {
fromBatch.BatchNum = c.lastNonFailedBatchNum
fromBatch.ForgerAddr = c.cfg.ForgerAddress
fromBatch.AccountStateRoot = big.NewInt(0)
fromBatch.VouchStateRoot = big.NewInt(0)
fromBatch.ScoreStateRoot = big.NewInt(0)

// TODO: implement
fromBatch.StateRoot = big.NewInt(0)
// fromBatch.AccountStateRoot = big.NewInt(0)
// fromBatch.VouchStateRoot = big.NewInt(0)
// fromBatch.ScoreStateRoot = big.NewInt(0)
}

var err error
Expand Down
2 changes: 1 addition & 1 deletion sequencer/synchronizer/synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ func (s *Synchronizer) rollupSync(ethBlock *common.Block) (*common.RollupData, e
ForgerAddr: *sender,

// TODO: add AccountStateRoot, VouchStateRoot, ScoreStateRoot to Rollup
// StateRoot: forgeBatchArgs.NewStRoot,
StateRoot: forgeBatchArgs.NewStRoot,
NumAccounts: len(batchData.CreatedAccounts),
LastIdx: forgeBatchArgs.NewLastIdx,
ExitRoot: forgeBatchArgs.NewExitRoot,
Expand Down
3 changes: 1 addition & 2 deletions sequencer/test/ethClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,7 @@ func (c *Client) CtlAddBlocks(blocks []common.BlockData) (err error) {
NewLastIdx: batch.Batch.LastIdx,

// TODO: add AccountStateRoot, VouchStateRoot, ScoreStateRoot to Rollup
// NewStRoot: batch.Batch.StateRoot,

NewStRoot: batch.Batch.StateRoot,
NewExitRoot: batch.Batch.ExitRoot,
L1CoordinatorTxs: batch.L1CoordinatorTxs,
L1CoordinatorTxsAuths: auths,
Expand Down

0 comments on commit 5dc3c9a

Please sign in to comment.