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

Adaptation to new HashDB interface #2367

Merged
merged 7 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ install-git-hooks: ## Moves hook files to the .git/hooks directory

.PHONY: generate-code-from-proto
generate-code-from-proto: ## Generates code from proto files
cd proto/src/proto/hashdb/v1 && protoc --proto_path=. --proto_path=../../../../include --go_out=../../../../../merkletree/pb --go-grpc_out=../../../../../merkletree/pb --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative hashdb.proto
cd proto/src/proto/hashdb/v1 && protoc --proto_path=. --proto_path=../../../../include --go_out=../../../../../merkletree/hashdb --go-grpc_out=../../../../../merkletree/hashdb --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative hashdb.proto
cd proto/src/proto/executor/v1 && protoc --proto_path=. --go_out=../../../../../state/runtime/executor --go-grpc_out=../../../../../state/runtime/executor --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative executor.proto
cd proto/src/proto/aggregator/v1 && protoc --proto_path=. --proto_path=../../../../include --go_out=../../../../../aggregator/pb --go-grpc_out=../../../../../aggregator/pb --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative aggregator.proto
cd proto/src/proto/aggregator/v1 && protoc --proto_path=. --proto_path=../../../../include --go_out=../../../../../aggregator/prover --go-grpc_out=../../../../../aggregator/prover --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative aggregator.proto

## Help display.
## Pulls comments from beside commands and prints a nicely formatted
Expand Down
17 changes: 8 additions & 9 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"unicode"

"github.com/0xPolygonHermez/zkevm-node/aggregator/metrics"
"github.com/0xPolygonHermez/zkevm-node/aggregator/pb"
"github.com/0xPolygonHermez/zkevm-node/aggregator/prover"
"github.com/0xPolygonHermez/zkevm-node/config/types"
"github.com/0xPolygonHermez/zkevm-node/encoding"
Expand All @@ -41,12 +40,12 @@ type finalProofMsg struct {
proverName string
proverID string
recursiveProof *state.Proof
finalProof *pb.FinalProof
finalProof *prover.FinalProof
}

// Aggregator represents an aggregator
type Aggregator struct {
pb.UnimplementedAggregatorServiceServer
prover.UnimplementedAggregatorServiceServer

cfg Config

Expand Down Expand Up @@ -129,7 +128,7 @@ func (a *Aggregator) Start(ctx context.Context) error {
}

a.srv = grpc.NewServer()
pb.RegisterAggregatorServiceServer(a.srv, a)
prover.RegisterAggregatorServiceServer(a.srv, a)

healthService := newHealthChecker()
grpchealth.RegisterHealthServer(a.srv, healthService)
Expand Down Expand Up @@ -159,7 +158,7 @@ func (a *Aggregator) Stop() {

// Channel implements the bi-directional communication channel between the
// Prover client and the Aggregator server.
func (a *Aggregator) Channel(stream pb.AggregatorService_ChannelServer) error {
func (a *Aggregator) Channel(stream prover.AggregatorService_ChannelServer) error {
metrics.ConnectedProver()
defer metrics.DisconnectedProver()

Expand Down Expand Up @@ -306,7 +305,7 @@ func (a *Aggregator) handleFailureToAddVerifyBatchToBeMonitored(ctx context.Cont
}

// buildFinalProof builds and return the final proof for an aggregated/batch proof.
func (a *Aggregator) buildFinalProof(ctx context.Context, prover proverInterface, proof *state.Proof) (*pb.FinalProof, error) {
func (a *Aggregator) buildFinalProof(ctx context.Context, prover proverInterface, proof *state.Proof) (*prover.FinalProof, error) {
log := log.WithFields(
"prover", prover.Name(),
"proverId", prover.ID(),
Expand Down Expand Up @@ -972,14 +971,14 @@ func (a *Aggregator) isSynced(ctx context.Context, batchNum *uint64) bool {
return true
}

func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.Batch) (*pb.InputProver, error) {
func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.Batch) (*prover.InputProver, error) {
previousBatch, err := a.State.GetBatchByNumber(ctx, batchToVerify.BatchNumber-1, nil)
if err != nil && err != state.ErrStateNotSynchronized {
return nil, fmt.Errorf("failed to get previous batch, err: %v", err)
}

inputProver := &pb.InputProver{
PublicInputs: &pb.PublicInputs{
inputProver := &prover.InputProver{
PublicInputs: &prover.PublicInputs{
OldStateRoot: previousBatch.StateRoot.Bytes(),
OldAccInputHash: previousBatch.AccInputHash.Bytes(),
OldBatchNum: previousBatch.BatchNumber,
Expand Down
8 changes: 4 additions & 4 deletions aggregator/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/0xPolygonHermez/zkevm-node/aggregator/mocks"
"github.com/0xPolygonHermez/zkevm-node/aggregator/pb"
"github.com/0xPolygonHermez/zkevm-node/aggregator/prover"
configTypes "github.com/0xPolygonHermez/zkevm-node/config/types"
ethmanTypes "github.com/0xPolygonHermez/zkevm-node/etherman/types"
"github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
Expand Down Expand Up @@ -53,7 +53,7 @@ func TestSendFinalProof(t *testing.T) {
BatchNumber: batchNum,
BatchNumberFinal: batchNumFinal,
}
finalProof := &pb.FinalProof{}
finalProof := &prover.FinalProof{}
cfg := Config{SenderAddress: from.Hex()}

testCases := []struct {
Expand Down Expand Up @@ -1000,9 +1000,9 @@ func TestTryBuildFinalProof(t *testing.T) {
proverName := "proverName"
proverID := "proverID"
finalProofID := "finalProofID"
finalProof := pb.FinalProof{
finalProof := prover.FinalProof{
Proof: "",
Public: &pb.PublicInputsExtended{
Public: &prover.PublicInputsExtended{
NewStateRoot: []byte("newStateRoot"),
NewLocalExitRoot: []byte("newLocalExitRoot"),
},
Expand Down
6 changes: 3 additions & 3 deletions aggregator/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"math/big"

"github.com/0xPolygonHermez/zkevm-node/aggregator/pb"
"github.com/0xPolygonHermez/zkevm-node/aggregator/prover"
ethmanTypes "github.com/0xPolygonHermez/zkevm-node/etherman/types"
"github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
"github.com/0xPolygonHermez/zkevm-node/state"
Expand All @@ -19,11 +19,11 @@ type proverInterface interface {
ID() string
Addr() string
IsIdle() (bool, error)
BatchProof(input *pb.InputProver) (*string, error)
BatchProof(input *prover.InputProver) (*string, error)
AggregatedProof(inputProof1, inputProof2 string) (*string, error)
FinalProof(inputProof string, aggregatorAddr string) (*string, error)
WaitRecursiveProof(ctx context.Context, proofID string) (string, error)
WaitFinalProof(ctx context.Context, proofID string) (*pb.FinalProof, error)
WaitFinalProof(ctx context.Context, proofID string) (*prover.FinalProof, error)
}

// ethTxManager contains the methods required to send txs to
Expand Down
20 changes: 10 additions & 10 deletions aggregator/mocks/mock_prover.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading