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

Fix: remove l2db #29

Merged
merged 7 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 0 additions & 1 deletion .github/workflows/synchronizer.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
paths:
- "sequencer/synchronizer/**"
- "sequencer/database/historydb/**"
- "sequencer/database/l2db/**"
- "sequencer/database/statedb/**"
- "sequencer/txprocessor/**"
- "sequencer/test/til/**"
Expand Down
7 changes: 0 additions & 7 deletions sequencer/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"tokamak-sybil-resistance/api/coordinatornetwork"
"tokamak-sybil-resistance/common"
"tokamak-sybil-resistance/database/historydb"
"tokamak-sybil-resistance/database/l2db"
"tokamak-sybil-resistance/database/statedb"

ethCommon "github.com/ethereum/go-ethereum/common"
Expand All @@ -20,7 +19,6 @@ import (
type API struct {
historyDB *historydb.HistoryDB
config *configAPI
l2DB *l2db.L2DB
stateDB *statedb.StateDB
hermezAddress ethCommon.Address
validate *validator.Validate
Expand All @@ -39,7 +37,6 @@ type Config struct {
ExplorerEndpoints bool
Server *gin.Engine
HistoryDB *historydb.HistoryDB
L2DB *l2db.L2DB
StateDB *statedb.StateDB
EthClient *ethclient.Client
ForgerAddress *ethCommon.Address
Expand All @@ -49,9 +46,6 @@ type Config struct {
// NewAPI sets the endpoints and the appropriate handlers, but doesn't start the server
func NewAPI(setup Config) (*API, error) {
// Check input
if setup.CoordinatorEndpoints && setup.L2DB == nil {
return nil, common.Wrap(errors.New("cannot serve Coordinator endpoints without L2DB"))
}
if setup.ExplorerEndpoints && setup.HistoryDB == nil {
return nil, common.Wrap(errors.New("cannot serve Explorer endpoints without HistoryDB"))
}
Expand All @@ -66,7 +60,6 @@ func NewAPI(setup Config) (*API, error) {
RollupConstants: *newRollupConstants(consts.Rollup),
ChainID: consts.ChainID,
},
l2DB: setup.L2DB,
stateDB: setup.StateDB,
hermezAddress: consts.HermezAddress,
validate: nil, //TODO: Add validations
Expand Down
21 changes: 0 additions & 21 deletions sequencer/cfg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ SyncRetryInterval = "1s"
#ForgeDelay = "600s"
### Delay after a forged batch if there are no txs to forge. If It is set to 0s, the coordinator will continuously forge even if the batches are empty
#ForgeNoTxsDelay = "86400s"
### Interval between calls to the PurgeByExternalDelete function of the l2db which deletes pending txs externally marked by the column `external_delete`
PurgeByExtDelInterval = "1m"
### Enables the coordinator to forge in slots if the empty slots reach the slot deadline
#MustForgeAtSlotDeadline = true
### It will make the coordinator forge at most one batch per slot, only if there are included txs in that batch, or pending l1UserTxs in the smart contract. Setting this parameter overrides `ForgeDelay`, `ForgeNoTxsDelay`, `MustForgeAtSlotDeadline` and `IgnoreSlotCommitment`.
Expand All @@ -116,25 +114,6 @@ Address = "0x56232B1c5B10038125Bc7345664B4AFD745bcF8E"
## BJJ is the baby jub jub public key of the account that will receive the fees
BJJ = "0x130c5c7f294792559f469220274f3d3b2dca6e89f4c5ec88d3a08bf73262171b"

[Coordinator.L2DB]
### Number of batches after which non-pending L2Txs are deleted from the pool
SafetyPeriod = 10
### Maximum number of pending L2Txs that can be stored in the pool
MaxTxs = 1000000
### Minimum fee in USD that a tx must pay in order to be accepted into the pool
MinFeeUSD = 0.10
### Maximum fee in USD that a tx must pay in order to be accepted into the pool
MaxFeeUSD = 10.00
### Time To Live for L2Txs in the pool. L2Txs older than TTL will be deleted.
TTL = "24h"
### Delay between batches to purge outdated transactions. Outdated L2Txs are those that have been forged or marked as invalid for longer than the SafetyPeriod and pending L2Txs that have been in the pool for longer than TTL once there are MaxTxs
PurgeBatchDelay = 10
### Delay between batches to mark invalid transactions due to nonce lower than the account nonce
InvalidateBatchDelay = 20
### Delay between blocks to purge outdated transactions. Outdated L2Txs are those that have been forged or marked as invalid for longer than the SafetyPeriod and pending L2Txs that have been in the pool for longer than TTL once there are MaxTxs.
PurgeBlockDelay = 10
### Delay between blocks to mark invalid transactions due to nonce lower than the account nonce
InvalidateBlockDelay = 20

[Coordinator.TxSelector]
### Path where the TxSelector StateDB is stored
Expand Down
4 changes: 0 additions & 4 deletions sequencer/common/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ type BatchData struct {
L1Batch bool
// L1UserTxs that were forged in the batch
L1UserTxs []L1Tx
// L1CoordinatorTxs []L1Tx
// L2Txs []L2Tx
CreatedAccounts []Account
UpdatedAccounts []AccountUpdate
ExitTree []ExitInfo
Expand All @@ -78,8 +76,6 @@ func NewBatchData() *BatchData {
return &BatchData{
L1Batch: false,
L1UserTxs: make([]L1Tx, 0),
// L1CoordinatorTxs: make([]L1Tx, 0),
// L2Txs: make([]L2Tx, 0),
CreatedAccounts: make([]Account, 0),
ExitTree: make([]ExitInfo, 0),
Batch: Batch{},
Expand Down
65 changes: 0 additions & 65 deletions sequencer/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,54 +109,8 @@ type Coordinator struct {
// SyncRetryInterval is the waiting interval between calls to the main
// handler of a synced block after an error
SyncRetryInterval Duration `validate:"required" env:"TONNODE_COORDINATOR_SYNCRETRYINTERVAL"`
// PurgeByExtDelInterval is the waiting interval between calls
// to the PurgeByExternalDelete function of the l2db which deletes
// pending txs externally marked by the column `external_delete`
PurgeByExtDelInterval Duration `validate:"required" env:"TONNODE_COORDINATOR_PURGEBYEXTDELINTERVAL"`
// ProverWaitReadTimeout
ProverWaitReadTimeout Duration `env:"TONNODE_COORDINATOR_PROVERWAITREADTIMEOUT"`
// L2DB is the DB that holds the pool of L2Txs
L2DB struct {
// SafetyPeriod is the number of batches after which
// non-pending L2Txs are deleted from the pool
SafetyPeriod common.BatchNum `validate:"required" env:"TONNODE_L2DB_SAFETYPERIOD"`
// MaxTxs is the maximum number of pending L2Txs that can be
// stored in the pool. Once this number of pending L2Txs is
// reached, inserts to the pool will be denied until some of
// the pending txs are forged.
MaxTxs uint32 `validate:"required" env:"TONNODE_L2DB_MAXTXS"`
// MinFeeUSD is the minimum fee in USD that a tx must pay in
// order to be accepted into the pool. Txs with lower than
// minimum fee will be rejected at the API level.
MinFeeUSD float64 `validate:"gte=0" env:"TONNODE_L2DB_MINFEEUSD"`
// MaxFeeUSD is the maximum fee in USD that a tx must pay in
// order to be accepted into the pool. Txs with greater than
// maximum fee will be rejected at the API level.
MaxFeeUSD float64 `validate:"required,gte=0" env:"TONNODE_L2DB_MAXFEEUSD"`
// TTL is the Time To Live for L2Txs in the pool. L2Txs older
// than TTL will be deleted.
TTL Duration `validate:"required" env:"TONNODE_L2DB_TTL"`
// PurgeBatchDelay is the delay between batches to purge
// outdated transactions. Outdated L2Txs are those that have
// been forged or marked as invalid for longer than the
// SafetyPeriod and pending L2Txs that have been in the pool
// for longer than TTL once there are MaxTxs.
PurgeBatchDelay int64 `validate:"required,gte=0" env:"TONNODE_L2DB_PURGEBATCHDELAY"`
// InvalidateBatchDelay is the delay between batches to mark
// invalid transactions due to nonce lower than the account
// nonce.
InvalidateBatchDelay int64 `validate:"required" env:"TONNODE_L2DB_INVALIDATEBATCHDELAY"`
// PurgeBlockDelay is the delay between blocks to purge
// outdated transactions. Outdated L2Txs are those that have
// been forged or marked as invalid for longer than the
// SafetyPeriod and pending L2Txs that have been in the pool
// for longer than TTL once there are MaxTxs.
PurgeBlockDelay int64 `validate:"required,gte=0" env:"TONNODE_L2DB_PURGEBLOCKDELAY"`
// InvalidateBlockDelay is the delay between blocks to mark
// invalid transactions due to nonce lower than the account
// nonce.
InvalidateBlockDelay int64 `validate:"required,gte=0" env:"TONNODE_L2DB_INVALIDATEBLOCKDELAY"`
} `validate:"required"`
TxSelector struct {
// Path where the TxSelector StateDB is stored
Path string `validate:"required" env:"TONNODE_TXSELECTOR_PATH"`
Expand Down Expand Up @@ -337,10 +291,6 @@ type APIConfigParameters struct {
UpdateMetricsInterval Duration `validate:"required" env:"TONNODE_API_UPDATEMETRICSINTERVAL"`
// UpdateRecommendedFeeInterval is the interval between updates of the recommended fees
UpdateRecommendedFeeInterval Duration `validate:"required" env:"TONNODE_API_UPDATERECOMMENDEDFEEINTERVAL"`
// CoordinatorNetwork enables a pubsub p2p network to share L2 related information among coordinators.
// Only used when running in coordinator mode, as the L2DB is required. Port 3598 will be used and must be open.
// KeyStore must be configured with the Ethereum private key of the coordinator
CoordinatorNetwork bool `env:"TONNODE_API_COORDINATORNETWORK"`
// FindPeersCoordinatorNetworkInterval time elapsed between peer discovery process for the coordinators p2p network
FindPeersCoordinatorNetworkInterval Duration `env:"TONNODE_API_COORDINATORNETWORK_FINDPEERSINTERVAL"`
}
Expand All @@ -358,21 +308,6 @@ type APIServer struct {
// Coordinator enables the coordinator API endpoints
Coordinator bool `env:"TONNODE_COORDINATORAPI_COORDINATOR"`
} `validate:"required"`
L2DB struct {
// MaxTxs is the maximum number of pending L2Txs that can be
// stored in the pool. Once this number of pending L2Txs is
// reached, inserts to the pool will be denied until some of
// the pending txs are forged.
MaxTxs uint32 `validate:"required" env:"TONNODE_L2DB_MAXTXS"`
// MinFeeUSD is the minimum fee in USD that a tx must pay in
// order to be accepted into the pool. Txs with lower than
// minimum fee will be rejected at the API level.
MinFeeUSD float64 `validate:"gte=0" env:"TONNODE_L2DB_MINFEEUSD"`
// MaxFeeUSD is the maximum fee in USD that a tx must pay in
// order to be accepted into the pool. Txs with greater than
// maximum fee will be rejected at the API level.
MaxFeeUSD float64 `validate:"required,gte=0" env:"TONNODE_L2DB_MAXFEEUSD"`
} `validate:"required"`
// Keystore is the ethereum keystore where private keys are kept.
// Required if API.CoordinatorNetwork == true
Keystore struct {
Expand Down
3 changes: 1 addition & 2 deletions sequencer/coordinator/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ type BatchInfo struct {
L1UserTxs []common.L1Tx
// L1CoordTxs []common.L1Tx
L1CoordinatorTxsAuths [][]byte
// L2Txs []common.L2Tx
// CoordIdxs []common.AccountIdx

ForgeBatchArgs *eth.RollupForgeBatchArgs
Auth *bind.TransactOpts `json:"-"`
EthTxs []*types.Transaction
Expand Down
27 changes: 0 additions & 27 deletions sequencer/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ type Config struct {
// SyncRetryInterval is the waiting interval between calls to the main
// handler of a synced block after an error
SyncRetryInterval time.Duration
// PurgeByExtDelInterval is the waiting interval between calls
// to the PurgeByExternalDelete function of the l2db which deletes
// pending txs externally marked by the column `external_delete`
PurgeByExtDelInterval time.Duration
// EthClientAttemptsDelay is delay between attempts do do an eth client
// RPC call
EthClientAttemptsDelay time.Duration
Expand All @@ -164,7 +160,6 @@ type Config struct {
// DebugBatchPath if set, specifies the path where batchInfo is stored
// in JSON in every step/update of the pipeline
DebugBatchPath string
Purger PurgerCfg
// VerifierIdx is the index of the verifier contract registered in the
// smart contract
// VerifierIdx uint8
Expand Down Expand Up @@ -218,7 +213,6 @@ type Coordinator struct {
pipeline *Pipeline
lastNonFailedBatchNum common.BatchNum

purger *Purger
txManager *TxManager
}

Expand Down Expand Up @@ -262,13 +256,6 @@ func NewCoordinator(cfg Config,
}
}

purger := Purger{
cfg: cfg.Purger,
lastPurgeBlock: 0,
lastPurgeBatch: 0,
lastInvalidateBlock: 0,
lastInvalidateBatch: 0,
}

ctx, cancel := context.WithCancel(context.Background())
c := Coordinator{
Expand All @@ -291,8 +278,6 @@ func NewCoordinator(cfg Config,
txSelector: txSelector,
batchBuilder: batchBuilder,

purger: &purger,

msgCh: make(chan interface{}, queueLen),
ctx: ctx,
// wg
Expand Down Expand Up @@ -406,7 +391,6 @@ func NewPipeline(
historyDB *historydb.HistoryDB,
txSelector *txselector.TxSelector,
batchBuilder *batchbuilder.BatchBuilder,
purger *Purger,
coord *Coordinator,
txManager *TxManager,
prover prover.Client,
Expand All @@ -425,7 +409,6 @@ func NewPipeline(
txSelector: txSelector,
batchBuilder: batchBuilder,
prover: prover,
purger: purger,
coord: coord,
txManager: txManager,
consts: *scConsts,
Expand All @@ -442,7 +425,6 @@ func (c *Coordinator) newPipeline(ctx context.Context) (*Pipeline, error) {
c.historyDB,
c.txSelector,
c.batchBuilder,
c.purger,
c,
c.txManager,
c.prover,
Expand Down Expand Up @@ -500,15 +482,6 @@ func (c *Coordinator) syncStats(ctx context.Context, stats *synchronizer.Stats)
return common.Wrap(err)
}

// TODO: Purging seems to be relevant to only L2 txs, need to confirm
// if _, err := c.purger.InvalidateMaybe(c.l2DB, c.txSelector.LocalAccountsDB(),
// stats.Sync.LastBlock.Num, int64(stats.Sync.LastBatch.BatchNum)); err != nil {
// return common.Wrap(err)
// }
// if _, err := c.purger.PurgeMaybe(c.l2DB, stats.Sync.LastBlock.Num,
// int64(stats.Sync.LastBatch.BatchNum)); err != nil {
// return common.Wrap(err)
// }
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion sequencer/coordinator/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type Pipeline struct {
historyDB *historydb.HistoryDB
txSelector *txselector.TxSelector
batchBuilder *batchbuilder.BatchBuilder
purger *Purger

stats synchronizer.Stats
vars common.SCVariables
Expand Down Expand Up @@ -148,6 +147,7 @@ func (p *Pipeline) getErrAtBatchNum() common.BatchNum {
// handleForgeBatch waits for an available proof server, calls p.forgeBatch to
// forge the batch and get the zkInputs, and then sends the zkInputs to the
// selected proof server so that the proof computation begins.

func (p *Pipeline) handleForgeBatch(
ctx context.Context,
batchNum common.BatchNum,
Expand Down
32 changes: 0 additions & 32 deletions sequencer/coordinator/purger.go

This file was deleted.

Loading
Loading