Update node and coordinator, fix linters
Eduard S eduard@iden3.io
Wed, 09 Dec 2020 16:22:31 +0100
5 files changed,
31 insertions(+),
33 deletions(-)
M
config/config.go
→
config/config.go
@@ -43,8 +43,9 @@ // ethereum transactions before forgetting about them
ConfirmBlocks int64 `validate:"required"` // L1BatchTimeoutPerc is the portion of the range before the L1Batch // timeout that will trigger a schedule to forge an L1Batch - L1BatchTimeoutPerc float64 `validate:"required"` - L2DB struct { + ProofServerPollInterval Duration `validate:"required"` + L1BatchTimeoutPerc float64 `validate:"required"` + L2DB struct { SafetyPeriod common.BatchNum `validate:"required"` MaxTxs uint32 `validate:"required"` TTL Duration `validate:"required"`@@ -69,10 +70,10 @@ CallGasLimit uint64 `validate:"required"`
DeployGasLimit uint64 `validate:"required"` GasPriceDiv uint64 `validate:"required"` ReceiptTimeout Duration `validate:"required"` - IntervalReceiptLoop Duration `validate:"required"` - // IntervalCheckLoop is the waiting interval between receipt + ReceiptLoopInterval Duration `validate:"required"` + // CheckLoopInterval is the waiting interval between receipt // checks of ethereum transactions in the TxManager - IntervalCheckLoop Duration `validate:"required"` + CheckLoopInterval Duration `validate:"required"` // Attempts is the number of attempts to do an eth client RPC // call before giving up Attempts int `validate:"required"`
M
coordinator/coordinator.go
→
coordinator/coordinator.go
@@ -807,7 +807,7 @@ p.cfg.debugBatchStore(&batchInfo)
// 7. Call the selected idle server proof with BatchBuilder output, // save server proof info for batchNum - err = batchInfo.ServerProof.CalculateProof(zkInputs) + err = batchInfo.ServerProof.CalculateProof(ctx, zkInputs) if err != nil { return nil, tracerr.Wrap(err) }
M
node/node.go
→
node/node.go
@@ -96,7 +96,7 @@ CallGasLimit: coordCfg.EthClient.CallGasLimit,
DeployGasLimit: coordCfg.EthClient.DeployGasLimit, GasPriceDiv: coordCfg.EthClient.GasPriceDiv, ReceiptTimeout: coordCfg.EthClient.ReceiptTimeout.Duration, - IntervalReceiptLoop: coordCfg.EthClient.IntervalReceiptLoop.Duration, + IntervalReceiptLoop: coordCfg.EthClient.ReceiptLoopInterval.Duration, } } client, err := eth.NewClient(ethClient, nil, nil, ð.ClientConfig{@@ -165,7 +165,8 @@ return nil, tracerr.Wrap(err)
} serverProofs := make([]prover.Client, len(coordCfg.ServerProofs)) for i, serverProofCfg := range coordCfg.ServerProofs { - serverProofs[i] = prover.NewProofServerClient(serverProofCfg.URL) + serverProofs[i] = prover.NewProofServerClient(serverProofCfg.URL, + coordCfg.ProofServerPollInterval.Duration) } coord, err = coordinator.NewCoordinator(@@ -175,7 +176,7 @@ ConfirmBlocks: coordCfg.ConfirmBlocks,
L1BatchTimeoutPerc: coordCfg.L1BatchTimeoutPerc, EthClientAttempts: coordCfg.EthClient.Attempts, EthClientAttemptsDelay: coordCfg.EthClient.AttemptsDelay.Duration, - TxManagerCheckInterval: coordCfg.EthClient.IntervalCheckLoop.Duration, + TxManagerCheckInterval: coordCfg.EthClient.CheckLoopInterval.Duration, DebugBatchPath: coordCfg.Debug.BatchPath, Purger: coordinator.PurgerCfg{ PurgeBatchDelay: coordCfg.L2DB.PurgeBatchDelay,
M
prover/prover.go
→
prover/prover.go
@@ -133,7 +133,7 @@ writer *multipart.Writer
body []byte } -//nolint:unused +//nolint:unused,deadcode func newFormFileProvider(payload interface{}) (*formFileProvider, error) { body := new(bytes.Buffer) writer := multipart.NewWriter(body)@@ -239,9 +239,8 @@ if err != nil {
return nil, tracerr.Wrap(err) } return &proof, nil - } else { - return nil, errors.New("State is not Success") } + return nil, errors.New("State is not Success") } // Cancel cancels any current proof computation@@ -262,22 +261,21 @@ }
if !status.Status.IsInitialized() { err := errors.New("Proof Server is not initialized") return err - } else { - if status.Status.IsReady() { - return nil - } - for { - select { - case <-ctx.Done(): - return tracerr.Wrap(common.ErrDone) - case <-time.After(p.timeCons): - status, err := p.apiStatus(ctx) - if err != nil { - return tracerr.Wrap(err) - } - if status.Status.IsReady() { - return nil - } + } + if status.Status.IsReady() { + return nil + } + for { + select { + case <-ctx.Done(): + return tracerr.Wrap(common.ErrDone) + case <-time.After(p.timeCons): + status, err := p.apiStatus(ctx) + if err != nil { + return tracerr.Wrap(err) + } + if status.Status.IsReady() { + return nil } } }@@ -289,7 +287,7 @@ }
// CalculateProof sends the *common.ZKInputs to the ServerProof to compute the // Proof -func (p *MockClient) CalculateProof(zkInputs *common.ZKInputs) error { +func (p *MockClient) CalculateProof(ctx context.Context, zkInputs *common.ZKInputs) error { return nil }
M
prover/prover_test.go
→
prover/prover_test.go
@@ -47,8 +47,7 @@ assert.Equal(t, true, status.Status.IsReady())
} func testCalculateProof(t *testing.T) { - var zkInputs *common.ZKInputs - zkInputs = common.NewZKInputs(100, 16, 512, 24, 32, big.NewInt(1)) + zkInputs := common.NewZKInputs(100, 16, 512, 24, 32, big.NewInt(1)) err := proofServerClient.CalculateProof(context.Background(), zkInputs) require.NoError(t, err) }@@ -64,8 +63,7 @@ require.NotNil(t, proof.Protocol)
} func testCancel(t *testing.T) { - var zkInputs *common.ZKInputs - zkInputs = common.NewZKInputs(100, 16, 512, 24, 32, big.NewInt(1)) + zkInputs := common.NewZKInputs(100, 16, 512, 24, 32, big.NewInt(1)) err := proofServerClient.CalculateProof(context.Background(), zkInputs) require.NoError(t, err) // TODO: remove sleep when the server has been reviewed