Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
994cb2c
Check flushID != 0 (#2406)
ARR552 Aug 14, 2023
f494784
Show tx.GasPrice in the worker logs (instead of tx.Cost) (#2416)
agnusmor Aug 17, 2023
caf26bd
Check flushID != 0 in Sequencer (#2415)
agnusmor Aug 17, 2023
5040346
update config params for Prover v2.1.0 (#2418)
agnusmor Aug 17, 2023
59eaa75
cherry-pick #2385 and #2396 from develop into v0.2.6 (#2412)
tclemos Aug 17, 2023
c95cce4
new block endpoints and improvements to batch endpoint (#2411)
tclemos Aug 17, 2023
3b98022
Add forced batches tx to addrQueue (#2398)
ToniRamirezM Aug 18, 2023
4e31815
bugifx: adding missing tx.BreakEvenGasPrice nil check
Psykepro Aug 23, 2023
9d9801f
Merge pull request #2452 from 0xPolygonHermez/bugfix/effectiveGasPric…
Psykepro Aug 23, 2023
667d846
Sync halt (#2428)
ARR552 Aug 23, 2023
c1dd19c
cherry-pick #2245 and #2424 from develop into v0.2.6 (#2447)
tclemos Aug 23, 2023
2983243
New executor errors refactor (#2438)
ToniRamirezM Aug 23, 2023
da77be4
Reprocess full batch in parallel (sanity check) (#2425)
agnusmor Aug 23, 2023
9537f04
Speed up deleting batches from stateDB creating an index for state.re…
ToniRamirezM Aug 24, 2023
eb11e0f
Feature/#2429 fork id improvement (#2450)
ARR552 Aug 24, 2023
f1440a3
fix check storedFlushID (#2458)
ToniRamirezM Aug 24, 2023
5bdc061
remove stored flush id 0 (#2459)
ToniRamirezM Aug 24, 2023
f16d9ae
Feature/#2403 snap (#2404)
ARR552 Aug 28, 2023
307e83e
bugfix: removing measuring of metrics from async batch reprocessing f…
Psykepro Aug 28, 2023
4257f3f
update prover images (#2473)
ToniRamirezM Aug 28, 2023
375bffa
Update production-setup.md
agnusmor Aug 28, 2023
ecc75fb
Fix conflicts
arnaubennassar Aug 29, 2023
eee7def
Doc gen
arnaubennassar Aug 29, 2023
88ffe6a
Remove unnecesary image on docker-compose
arnaubennassar Aug 30, 2023
834a385
Remove unnecesary docker-compose
arnaubennassar Aug 30, 2023
538100a
WIP
arnaubennassar Aug 30, 2023
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
210 changes: 105 additions & 105 deletions aggregator/prover/aggregator.pb.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ci/e2e-group9/forced_batches_vector_group1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

const (
forkID5 = 5
forkID5 uint64 = 5
)

func TestForcedBatchesVectorFiles(t *testing.T) {
Expand Down Expand Up @@ -64,6 +64,7 @@ func TestForcedBatchesVectorFiles(t *testing.T) {
log.Info("###################")
genesisActions := vectors.GenerateGenesisActions(testCase.Genesis)
require.NoError(t, opsman.SetGenesis(genesisActions))
require.NoError(t, opsman.SetForkID(forkID5))
require.NoError(t, opsman.Setup())

// Check initial root
Expand Down
4 changes: 2 additions & 2 deletions cmd/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

### Create snapshots
```
go run ./cmd snapshot --cfg config/environments/local/local.node.config.toml
go run ./cmd snapshot --cfg config/environments/local/local.node.config.toml --output ./folder/
```

### Restore snapshots
```
go run ./cmd restore --cfg config/environments/local/local.node.config.toml -is zkevmpubliccorestatedb_1685614455_v0.1.0_undefined.sql.tar.gz -ih zkevmpublicstatedb_1685615051_v0.1.0_undefined.sql.tar.gz
go run ./cmd restore --cfg config/environments/local/local.node.config.toml -is ./folder/zkevmpubliccorestatedb_1685614455_v0.1.0_undefined.sql.tar.gz -ih ./folder/zkevmpublicstatedb_1685615051_v0.1.0_undefined.sql.tar.gz
```
84 changes: 70 additions & 14 deletions cmd/restore.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package main

import (
"bufio"
"errors"
"fmt"
"io"
"os"
"os/exec"
"strconv"
"strings"

Expand Down Expand Up @@ -45,9 +50,16 @@ func restore(ctx *cli.Context) error {
return errors.New("stateDB input file must end in .sql.tar.gz")
}

// Run migrations to create schemas and tables
runStateMigrations(c.StateDB)

d, err := db.NewSQLDB(c.StateDB)
if err != nil {
log.Error("error conecting to stateDB. Error: ", err)
return err
}
_, err = d.Exec(ctx.Context, "DROP SCHEMA IF EXISTS state CASCADE; DROP TABLE IF EXISTS gorp_migrations;")
if err != nil {
log.Error("error dropping state schema or migration table. Error: ", err)
return err
}
port, err := strconv.Atoi(c.StateDB.Port)
if err != nil {
log.Error("error converting port to int. Error: ", err)
Expand All @@ -64,12 +76,11 @@ func restore(ctx *cli.Context) error {
log.Error("error: ", err)
return err
}
restore.Role = c.StateDB.User
restore.Schemas = append(restore.Schemas, "state")
params := []string{"--no-owner", "--no-acl", "--format=c"}
log.Info("Restore stateDB snapshot started, please wait...")
restoreExec := restore.Exec(inputFileStateDB, pg.ExecOptions{StreamPrint: false})
restoreExec := execCommand(restore, inputFileStateDB, pg.ExecOptions{StreamPrint: false}, params)
if restoreExec.Error != nil {
log.Error("error restoring snapshot. Error: ", restoreExec.Error.Err)
log.Error("error restoring stateDB snapshot. Error: ", restoreExec.Error.Err)
log.Debug("restoreExec.Output: ", restoreExec.Output)
return err
}
Expand All @@ -84,12 +95,12 @@ func restore(ctx *cli.Context) error {
log.Error("error converting port to int. Error: ", err)
return err
}
d, err := db.NewSQLDB(c.HashDB)
d, err = db.NewSQLDB(c.HashDB)
if err != nil {
log.Error("error conecting to hashdb. Error: ", err)
return err
}
_, err = d.Exec(ctx.Context, "DROP SCHEMA IF EXISTS state CASCADE; CREATE SCHEMA IF NOT EXISTS state;")
_, err = d.Exec(ctx.Context, "DROP SCHEMA IF EXISTS state CASCADE;")
if err != nil {
log.Error("error dropping and creating state schema. Error: ", err)
return err
Expand All @@ -105,17 +116,62 @@ func restore(ctx *cli.Context) error {
log.Error("error: ", err)
return err
}
restore.Role = c.HashDB.User
restore.Schemas = append(restore.Schemas, "state")
restore.Options = []string{"--no-owner", "--no-acl"}

log.Info("Restore HashDB snapshot started, please wait...")
restoreExec = restore.Exec(inputFileHashDB, pg.ExecOptions{StreamPrint: false})
restoreExec = execCommand(restore, inputFileHashDB, pg.ExecOptions{StreamPrint: false}, params)
if restoreExec.Error != nil {
log.Error("error restoring snapshot. Error: ", restoreExec.Error.Err)
log.Error("error restoring hashDB snapshot. Error: ", restoreExec.Error.Err)
log.Debug("restoreExec.Output: ", restoreExec.Output)
return err
}

log.Info("Restore HashDB snapshot success")
return nil
}

func execCommand(x *pg.Restore, filename string, opts pg.ExecOptions, params []string) pg.Result {
result := pg.Result{}
options := append(params, x.Postgres.Parse()...)
options = append(options, fmt.Sprintf("%s%s", x.Path, filename))
log.Debug("Options: ", options)

result.FullCommand = strings.Join(options, " ")
cmd := exec.Command(pg.PGRestoreCmd, options...) //nolint:gosec
cmd.Env = append(os.Environ(), x.EnvPassword)
stderrIn, _ := cmd.StderrPipe()
go func(stderrIn io.ReadCloser, opts pg.ExecOptions, result *pg.Result) {
output := ""
reader := bufio.NewReader(stderrIn)
for {
line, err := reader.ReadString('\n')
if err != nil {
if errors.Is(err, io.EOF) {
result.Output = output
break
}
result.Error = &pg.ResultError{Err: fmt.Errorf("error reading output: %w", err), CmdOutput: output}
break
}

if opts.StreamPrint {
_, err = fmt.Fprint(opts.StreamDestination, line)
if err != nil {
result.Error = &pg.ResultError{Err: fmt.Errorf("error writing output: %w", err), CmdOutput: output}
break
}
}

output += line
}
}(stderrIn, opts, &result)
err := cmd.Start()
if err != nil {
result.Error = &pg.ResultError{Err: err, CmdOutput: result.Output}
}
err = cmd.Wait()
if exitError, ok := err.(*exec.ExitError); ok {
result.Error = &pg.ResultError{Err: err, ExitCode: exitError.ExitCode(), CmdOutput: result.Output}
}

return result
}
Loading