Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM committed Apr 16, 2024
1 parent 78faadb commit e6e432c
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 1,110 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# zkevm-aggregator

Aggregator implementation for the zkEVM network that uses a stateless prover.

23 changes: 10 additions & 13 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,11 @@ func (a *Aggregator) Start(ctx context.Context) error {
}

// Get last verified batch number to set the starting point for verifications

lastVerifiedBatchNumber, err := a.etherman.GetLatestVerifiedBatchNum()
if err != nil {
return err
}

// lastVerifiedBatchNumber := uint64(1138)

// Cleanup data base
err = a.state.DeleteBatchesOlderThanBatchNumber(ctx, lastVerifiedBatchNumber, nil)
if err != nil {
Expand Down Expand Up @@ -1365,16 +1362,16 @@ func getLER(blockNumber uint64, URL string, LERContract string) (common.Hash, er
}

func printInputProver(inputProver *prover.StatelessInputProver) {
log.Infof("Witness length: %v", len(inputProver.PublicInputs.Witness))
log.Infof("DataStream length: %v", len(inputProver.PublicInputs.DataStream))
// log.Infof("Full DataStream: %v", common.Bytes2Hex(inputProver.PublicInputs.DataStream))
log.Infof("OldAccInputHash: %v", common.BytesToHash(inputProver.PublicInputs.OldAccInputHash))
log.Infof("L1InfoRoot: %v", common.BytesToHash(inputProver.PublicInputs.L1InfoRoot))
log.Infof("TimestampLimit: %v", inputProver.PublicInputs.TimestampLimit)
log.Infof("SequencerAddr: %v", inputProver.PublicInputs.SequencerAddr)
log.Infof("AggregatorAddr: %v", inputProver.PublicInputs.AggregatorAddr)
log.Infof("L1InfoTreeData: %+v", inputProver.PublicInputs.L1InfoTreeData)
log.Infof("ForcedBlockhashL1: %v", common.Bytes2Hex(inputProver.PublicInputs.ForcedBlockhashL1))
log.Debugf("Witness length: %v", len(inputProver.PublicInputs.Witness))
log.Debugf("DataStream length: %v", len(inputProver.PublicInputs.DataStream))
// log.Debugf("Full DataStream: %v", common.Bytes2Hex(inputProver.PublicInputs.DataStream))
log.Debugf("OldAccInputHash: %v", common.BytesToHash(inputProver.PublicInputs.OldAccInputHash))
log.Debugf("L1InfoRoot: %v", common.BytesToHash(inputProver.PublicInputs.L1InfoRoot))
log.Debugf("TimestampLimit: %v", inputProver.PublicInputs.TimestampLimit)
log.Debugf("SequencerAddr: %v", inputProver.PublicInputs.SequencerAddr)
log.Debugf("AggregatorAddr: %v", inputProver.PublicInputs.AggregatorAddr)
log.Debugf("L1InfoTreeData: %+v", inputProver.PublicInputs.L1InfoTreeData)
log.Debugf("ForcedBlockhashL1: %v", common.Bytes2Hex(inputProver.PublicInputs.ForcedBlockhashL1))
}

// healthChecker will provide an implementation of the HealthCheck interface.
Expand Down
23 changes: 1 addition & 22 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,6 @@ var (
Usage: "Load the network configuration file if --network=custom",
Required: false,
}
yesFlag = cli.BoolFlag{
Name: config.FlagYes,
Aliases: []string{"y"},
Usage: "Automatically accepts any confirmation to execute the command",
Required: false,
}
componentsFlag = cli.StringSliceFlag{
Name: config.FlagComponents,
Aliases: []string{"co"},
Usage: "List of components to run",
Required: false,
Value: cli.NewStringSlice(AGGREGATOR),
}
migrationsFlag = cli.BoolFlag{
Name: config.FlagMigrations,
Aliases: []string{"mig"},
Usage: "Blocks the migrations in stateDB to not run them",
Required: false,
}
)

func main() {
Expand All @@ -69,8 +50,6 @@ func main() {
app.Version = zkevm.Version
flags := []cli.Flag{
&configFileFlag,
&yesFlag,
&componentsFlag,
}
app.Commands = []*cli.Command{
{
Expand All @@ -84,7 +63,7 @@ func main() {
Aliases: []string{},
Usage: "Run the zkevm-node",
Action: start,
Flags: append(flags, &networkFlag, &customNetworkFlag, &migrationsFlag),
Flags: append(flags, &networkFlag, &customNetworkFlag),
},
}

Expand Down
18 changes: 6 additions & 12 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func start(cliCtx *cli.Context) error {
if c.Metrics.Enabled {
metrics.Init()
}
components := cliCtx.StringSlice(config.FlagComponents)

// Migrations
if !cliCtx.Bool(config.FlagMigrations) {
Expand Down Expand Up @@ -111,18 +110,13 @@ func start(cliCtx *cli.Context) error {
c.Aggregator.Synchronizer.Etherman.Contracts.RollupManagerAddr = c.NetworkConfig.L1Config.RollupManagerAddr
c.Aggregator.Synchronizer.Etherman.Contracts.ZkEVMAddr = c.NetworkConfig.L1Config.ZkEVMAddr

for _, component := range components {
switch component {
case AGGREGATOR:
ev.Component = event.Component_Aggregator
ev.Description = "Running aggregator"
err := eventLog.LogEvent(cliCtx.Context, ev)
if err != nil {
log.Fatal(err)
}
go runAggregator(cliCtx.Context, c.Aggregator, etherman, st)
}
ev.Component = event.Component_Aggregator
ev.Description = "Running aggregator"
err = eventLog.LogEvent(cliCtx.Context, ev)
if err != nil {
log.Fatal(err)
}
go runAggregator(cliCtx.Context, c.Aggregator, etherman, st)

if c.Metrics.Enabled {
go startMetricsHttpServer(c.Metrics)
Expand Down
12 changes: 0 additions & 12 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,12 @@ const (
FlagNetwork = "network"
// FlagCustomNetwork is the flag for the custom network file. This is required if --network=custom
FlagCustomNetwork = "custom-network-file"
// FlagAmount is the flag for amount.
FlagAmount = "amount"
// FlagRemoteMT is the flag for remote-merkletree.
FlagRemoteMT = "remote-merkletree"
// FlagComponents is the flag for components.
FlagComponents = "components"
// FlagHTTPAPI is the flag for http.api.
FlagHTTPAPI = "http.api"
// FlagKeyStorePath is the path of the key store file containing the private key of the account going to sing and approve the tokens
FlagKeyStorePath = "key-store-path"
// FlagPassword is the password needed to decrypt the key store
FlagPassword = "password"
// FlagMigrations is the flag for migrations.
FlagMigrations = "migrations"
// FlagOutputFile is the flag for the output file
FlagOutputFile = "output"
// FlagMaxAmount is the flag to avoid to use the flag FlagAmount
FlagMaxAmount = "max-amount"
// FlagDocumentationFileType is the flag for the choose which file generate json-schema
FlagDocumentationFileType = "config-file"
)
Expand Down
Loading

0 comments on commit e6e432c

Please sign in to comment.