Skip to content

Commit

Permalink
fix/revert rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiden-araki committed Jan 6, 2025
1 parent 32b447d commit 76c89e6
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 52 deletions.
8 changes: 4 additions & 4 deletions sequencer/common/ethrollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ type BucketUpdate struct {

// RollupVariables are the variables of the Rollup Smart Contract
type RollupVariables struct {
EthBlockNum int64 `meddler:"eth_block_num"`
ForgeL1BatchTimeout int64 `meddler:"forge_l1_timeout" validate:"required"`
Buckets []BucketParams `meddler:"buckets,json"`
SafeMode bool `meddler:"safe_mode"`
EthBlockNum int64 `meddler:"eth_block_num"`
ForgeL1L2BatchTimeout int64 `meddler:"forge_l1_timeout" validate:"required"`
Buckets []BucketParams `meddler:"buckets,json"`
SafeMode bool `meddler:"safe_mode"`
}

// RollupVerifierStruct is the information about verifiers of the Rollup Smart Contract
Expand Down
2 changes: 1 addition & 1 deletion sequencer/coordinator/txmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (t *TxManager) mustL1Batch(blockNum int64) bool {
if t.stats.Sync.LastL1BatchBlock > lastL1BatchBlockNum {
lastL1BatchBlockNum = t.stats.Sync.LastL1BatchBlock
}
return blockNum-lastL1BatchBlockNum >= t.vars.Rollup.ForgeL1BatchTimeout-1
return blockNum-lastL1BatchBlockNum >= t.vars.Rollup.ForgeL1L2BatchTimeout-1
}

func (t *TxManager) shouldSendRollupForgeBatch(batchInfo *BatchInfo) error {
Expand Down
2 changes: 1 addition & 1 deletion sequencer/database/historydb/historydb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ func exampleInitSCVars() *common.RollupVariables { // *common.AuctionVariables,
rollup := &common.RollupVariables{
EthBlockNum: 0,
// FeeAddToken: big.NewInt(10),
ForgeL1BatchTimeout: 12,
ForgeL1L2BatchTimeout: 12,
// WithdrawalDelay: 13,
Buckets: []common.BucketParams{},
SafeMode: false,
Expand Down
2 changes: 1 addition & 1 deletion sequencer/database/historydb/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func NewRollupVariablesAPI(rollupVariables *common.RollupVariables) *RollupVaria
rollupVars := RollupVariablesAPI{
EthBlockNum: rollupVariables.EthBlockNum,
// FeeAddToken: apitypes.NewBigIntStr(rollupVariables.FeeAddToken),
ForgeL1BatchTimeout: rollupVariables.ForgeL1BatchTimeout,
ForgeL1BatchTimeout: rollupVariables.ForgeL1L2BatchTimeout,
// WithdrawalDelay: rollupVariables.WithdrawalDelay,
SafeMode: rollupVariables.SafeMode,
Buckets: buckets,
Expand Down
68 changes: 34 additions & 34 deletions sequencer/eth/rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type RollupState struct {
// ExitNullifierMap map[[256 / 8]byte]bool
ExitNullifierMap map[int64]map[int64]bool // batchNum -> idx -> bool
MapL1TxQueue map[int64]*QueueStruct
LastL1Batch int64
LastL1L2Batch int64
CurrentToForgeL1TxsNum int64
LastToForgeL1TxsNum int64
CurrentIdx int64
Expand All @@ -50,9 +50,9 @@ type RollupState struct {
// RollupEventInitialize is the InitializeHermezEvent event of the
// Smart Contract
type RollupEventInitialize struct {
ForgeL1BatchTimeout uint8
FeeAddToken *big.Int
WithdrawalDelay uint64
ForgeL1L2BatchTimeout uint8
FeeAddToken *big.Int
WithdrawalDelay uint64
}

// RollupEventL1UserTx is an event of the Rollup Smart Contract
Expand All @@ -79,9 +79,9 @@ type RollupEventForgeBatch struct {
GasPrice *big.Int
}

// RollupEventUpdateForgeL1BatchTimeout is an event of the Rollup Smart Contract
type RollupEventUpdateForgeL1BatchTimeout struct {
NewForgeL1BatchTimeout int64
// RollupEventUpdateForgeL1L2BatchTimeout is an event of the Rollup Smart Contract
type RollupEventUpdateForgeL1L2BatchTimeout struct {
NewForgeL1L2BatchTimeout int64
}

// RollupEventUpdateFeeAddToken is an event of the Rollup Smart Contract
Expand Down Expand Up @@ -146,26 +146,26 @@ type RollupEventSafeMode struct{}

// RollupEvents is the list of events in a block of the Rollup Smart Contract
type RollupEvents struct {
L1UserTx []RollupEventL1UserTx
ForgeBatch []RollupEventForgeBatch
UpdateForgeL1BatchTimeout []RollupEventUpdateForgeL1BatchTimeout
UpdateFeeAddToken []RollupEventUpdateFeeAddToken
Withdraw []RollupEventWithdraw
UpdateWithdrawalDelay []RollupEventUpdateWithdrawalDelay
UpdateBucketWithdraw []RollupEventUpdateBucketWithdraw
UpdateBucketsParameters []RollupEventUpdateBucketsParameters
UpdateTokenExchange []RollupEventUpdateTokenExchange
SafeMode []RollupEventSafeMode
L1UserTx []RollupEventL1UserTx
ForgeBatch []RollupEventForgeBatch
UpdateForgeL1L2BatchTimeout []RollupEventUpdateForgeL1L2BatchTimeout
UpdateFeeAddToken []RollupEventUpdateFeeAddToken
Withdraw []RollupEventWithdraw
UpdateWithdrawalDelay []RollupEventUpdateWithdrawalDelay
UpdateBucketWithdraw []RollupEventUpdateBucketWithdraw
UpdateBucketsParameters []RollupEventUpdateBucketsParameters
UpdateTokenExchange []RollupEventUpdateTokenExchange
SafeMode []RollupEventSafeMode
}

// NewRollupEvents creates an empty RollupEvents with the slices initialized.
func NewRollupEvents() RollupEvents {
return RollupEvents{
L1UserTx: make([]RollupEventL1UserTx, 0),
ForgeBatch: make([]RollupEventForgeBatch, 0),
UpdateForgeL1BatchTimeout: make([]RollupEventUpdateForgeL1BatchTimeout, 0),
UpdateFeeAddToken: make([]RollupEventUpdateFeeAddToken, 0),
Withdraw: make([]RollupEventWithdraw, 0),
L1UserTx: make([]RollupEventL1UserTx, 0),
ForgeBatch: make([]RollupEventForgeBatch, 0),
UpdateForgeL1L2BatchTimeout: make([]RollupEventUpdateForgeL1L2BatchTimeout, 0),
UpdateFeeAddToken: make([]RollupEventUpdateFeeAddToken, 0),
Withdraw: make([]RollupEventWithdraw, 0),
}
}

Expand Down Expand Up @@ -195,7 +195,7 @@ type rollupForgeBatchArgsAux struct {
NewScoreRoot *big.Int
NewExitRoot *big.Int
EncodedL1CoordinatorTx []byte
L1TxsData []byte
L1L2TxsData []byte
FeeIdxCoordinator []byte
// Circuit selector
VerifierIdx uint8
Expand Down Expand Up @@ -246,10 +246,10 @@ type RollupClient struct {
// RollupVariables returns the RollupVariables from the initialize event
func (ei *RollupEventInitialize) RollupVariables() *common.RollupVariables {
return &common.RollupVariables{
EthBlockNum: 0,
ForgeL1BatchTimeout: int64(ei.ForgeL1BatchTimeout),
Buckets: []common.BucketParams{},
SafeMode: false,
EthBlockNum: 0,
ForgeL1L2BatchTimeout: int64(ei.ForgeL1L2BatchTimeout),
Buckets: []common.BucketParams{},
SafeMode: false,
}
}

Expand Down Expand Up @@ -320,8 +320,8 @@ var (
"L1UserTxEvent(uint32,uint8,bytes)"))
logSYBForgeBatch = crypto.Keccak256Hash([]byte(
"ForgeBatch(uint32,uint16)"))
logSYBUpdateForgeL1BatchTimeout = crypto.Keccak256Hash([]byte(
"UpdateForgeL1BatchTimeout(uint8)"))
logSYBUpdateForgeL1L2BatchTimeout = crypto.Keccak256Hash([]byte(
"UpdateForgeL1L2BatchTimeout(uint8)"))
logSYBWithdrawEvent = crypto.Keccak256Hash([]byte(
"WithdrawEvent(uint48,uint32,bool)"))
logSYBUpdateBucketWithdraw = crypto.Keccak256Hash([]byte(
Expand Down Expand Up @@ -414,7 +414,7 @@ func (c *RollupClient) RollupEventsByBlock(blockNum int64,
}
forgeBatch.GasUsed = txReceipt.GasUsed
rollupEvents.ForgeBatch = append(rollupEvents.ForgeBatch, forgeBatch)
case logSYBUpdateForgeL1BatchTimeout:
case logSYBUpdateForgeL1L2BatchTimeout:
var updateForgeL1BatchTimeout struct {
NewForgeL1BatchTimeout uint8
}
Expand All @@ -423,9 +423,9 @@ func (c *RollupClient) RollupEventsByBlock(blockNum int64,
if err != nil {
return nil, common.Wrap(err)
}
rollupEvents.UpdateForgeL1BatchTimeout = append(rollupEvents.UpdateForgeL1BatchTimeout,
RollupEventUpdateForgeL1BatchTimeout{
NewForgeL1BatchTimeout: int64(updateForgeL1BatchTimeout.NewForgeL1BatchTimeout),
rollupEvents.UpdateForgeL1L2BatchTimeout = append(rollupEvents.UpdateForgeL1L2BatchTimeout,
RollupEventUpdateForgeL1L2BatchTimeout{
NewForgeL1L2BatchTimeout: int64(updateForgeL1BatchTimeout.NewForgeL1BatchTimeout),
})
case logSYBWithdrawEvent:
var withdraw RollupEventWithdraw
Expand Down Expand Up @@ -588,7 +588,7 @@ func (c *RollupClient) RollupForgeBatchArgs(ethTxHash ethCommon.Hash,
numTxsL1Coord := len(aux.EncodedL1CoordinatorTx) / common.RollupConstL1CoordinatorTotalBytes
l1UserTxsData := []byte{}
if l1UserTxsLen > 0 {
l1UserTxsData = aux.L1TxsData[:numBytesL1TxUser]
l1UserTxsData = aux.L1L2TxsData[:numBytesL1TxUser]
}
for i := 0; i < int(l1UserTxsLen); i++ {
l1Tx, err :=
Expand Down
4 changes: 2 additions & 2 deletions sequencer/synchronizer/synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,8 @@ func (s *Synchronizer) rollupSync(ethBlock *common.Block) (*common.RollupData, e

varsUpdate := false

for _, evt := range rollupEvents.UpdateForgeL1BatchTimeout {
s.vars.Rollup.ForgeL1BatchTimeout = evt.NewForgeL1BatchTimeout
for _, evt := range rollupEvents.UpdateForgeL1L2BatchTimeout {
s.vars.Rollup.ForgeL1L2BatchTimeout = evt.NewForgeL1L2BatchTimeout
varsUpdate = true
}

Expand Down
4 changes: 2 additions & 2 deletions sequencer/synchronizer/synchronizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ func TestSyncGeneral(t *testing.T) {
// Update variables manually
rollupVars, err := s.historyDB.GetSCVars()
require.NoError(t, err)
rollupVars.ForgeL1BatchTimeout = 42
_, err = client.RollupUpdateForgeL1BatchTimeout(rollupVars.ForgeL1BatchTimeout)
rollupVars.ForgeL1L2BatchTimeout = 42
_, err = client.RollupUpdateForgeL1BatchTimeout(rollupVars.ForgeL1L2BatchTimeout)
require.NoError(t, err)

client.CtlMineBlock()
Expand Down
14 changes: 7 additions & 7 deletions sequencer/test/ethClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ func NewClientSetupExample() *ClientSetup {
TokamakGovernanceAddress: governanceAddress,
}
rollupVariables := &common.RollupVariables{
ForgeL1BatchTimeout: 10,
Buckets: []common.BucketParams{},
ForgeL1L2BatchTimeout: 10,
Buckets: []common.BucketParams{},
}
return &ClientSetup{
RollupConstants: rollupConstants,
Expand Down Expand Up @@ -191,7 +191,7 @@ func NewClient(l bool, timer Timer, addr *ethCommon.Address, setup *ClientSetup)
ExitRoots: make([]*big.Int, 1),
ExitNullifierMap: make(map[int64]map[int64]bool),
MapL1TxQueue: mapL1TxQueue,
LastL1Batch: 0,
LastL1L2Batch: 0,
CurrentToForgeL1TxsNum: 0,
LastToForgeL1TxsNum: 1,
CurrentIdx: 0,
Expand Down Expand Up @@ -764,9 +764,9 @@ func (c *Client) RollupUpdateForgeL1BatchTimeout(newForgeL1Timeout int64) (tx *t

nextBlock := c.nextBlock()
r := nextBlock.Rollup
r.Vars.ForgeL1BatchTimeout = newForgeL1Timeout
r.Events.UpdateForgeL1BatchTimeout = append(r.Events.UpdateForgeL1BatchTimeout,
eth.RollupEventUpdateForgeL1BatchTimeout{NewForgeL1BatchTimeout: newForgeL1Timeout})
r.Vars.ForgeL1L2BatchTimeout = newForgeL1Timeout
r.Events.UpdateForgeL1L2BatchTimeout = append(r.Events.UpdateForgeL1L2BatchTimeout,
eth.RollupEventUpdateForgeL1L2BatchTimeout{NewForgeL1L2BatchTimeout: newForgeL1Timeout})

return r.addTransaction(c.newTransaction("updateForgeL1L2BatchTimeout", newForgeL1Timeout)), nil
}
Expand Down Expand Up @@ -815,7 +815,7 @@ func (c *Client) RollupEventsByBlock(blockNum int64,
func (c *Client) RollupEventInit(genesisBlockNum int64) (*eth.RollupEventInitialize, int64, error) {
vars := c.blocks[0].Rollup.Vars
return &eth.RollupEventInitialize{
ForgeL1BatchTimeout: uint8(vars.ForgeL1BatchTimeout),
ForgeL1L2BatchTimeout: uint8(vars.ForgeL1L2BatchTimeout),
}, 1, nil
}

Expand Down

0 comments on commit 76c89e6

Please sign in to comment.