Skip to content

Commit

Permalink
Pullupstream/v0.5.0 (#63)
Browse files Browse the repository at this point in the history
* fix migration batch wip field. fix sequence when no wip batch (0xPolygonHermez#3126)

* fix Leaves smtproof (0xPolygonHermez#3127)

* fix Leaves smtproof

* pointer protection

* fix unit test

* Add l2block log dump when storing error. Refactor ProcessBatchV2 logs (0xPolygonHermez#3129)

* add l2block log dump when storing error. refactor ProcessBatchV2 logs

* add AddL2Block log

* fix index AddL2Block log

* use aux variable to avoid reusing poiner

---------

Co-authored-by: Toni Ramírez <toni@polygon.technology>

* fix panic etherman (0xPolygonHermez#3133)

* Fix GetL2Hash function. Use tx L2 hash returned by the executor when storing L2Block. Logs changes (0xPolygonHermez#3134)

* fix l2 hash when to is nill

* get l2 hash from executor

* fix use tx L2 hash returned by the executor when storing L2Block. Logs changes

* fix linter

* add L2block tracking number to process tx logs

* fix ProcessBatchV2 log format

* fix UTs. set useMainExecGenerated to true

* set prover image to v4.0.0-RC30

* test setting useMainExecGenerated = false

* fix independent_test

* fix non-e2e tests

---------

Co-authored-by: Toni Ramírez <toni@polygon.technology>

* remove l2 tx hash computation and use data stored in the state returned by the executor (0xPolygonHermez#3139)

* etrog: fix permissionless errors (0xPolygonHermez#3140)

* if got an error getting lastBlock produce a SIGSEGV

* reduce info logs

* fix unittest

* Fix missing batch bookmark (0xPolygonHermez#3122)

* fix missingBookMark

* fix missingBookMark

* fixes

* fix

* fix

* fix seq-sender config

* fixes

* doc

* fix wipL2Block deltaTimestamp (0xPolygonHermez#3142)

* improve open new wipL2Block logs

* fix wipL2Block deltaTimestamp

* ensure tx order in stream (0xPolygonHermez#3144)

* fix wipL2Block stateRoot (0xPolygonHermez#3145)

* fix panic NewStackTrie (0xPolygonHermez#3146)

* fix sync initalization for etrog (0xPolygonHermez#3147)

* fix wipL2block imStateRoot (0xPolygonHermez#3148)

* fix tracer to work by block stateroot instead of by tx (0xPolygonHermez#3150)

* update prover image (0xPolygonHermez#3151)

* if a trusted batch is empty and WIP just create the entry in state.batch (0xPolygonHermez#3152)

* fix trace for tx index greater than 0 (0xPolygonHermez#3153)

* add cardona.zip (0xPolygonHermez#3154)

* Fix default value when creating transaction.used_sha256_hashes field in the pool (0xPolygonHermez#3156)

* set DEFAULT 0 when creatingtransaction.used_sha256_hashes field in the pool

* update prover image to v4.0.0

* add cardona testnet (0xPolygonHermez#2909) (0xPolygonHermez#3155)

* add cardona testnet (0xPolygonHermez#2909)
* update config
* update cardona genesis

---------

Co-authored-by: Thiago Coimbra Lemos <tclemos@users.noreply.github.com>

* new fields in stream (0xPolygonHermez#3149)

* new fields in stream

* update test

* remove unused constant

* add UpgradeEtrogBatchNumber handling to stream

* doc

* add log to test

* add log to test

* add protection

* add check

* fix

* fix

* set stateManagerPurge to false in Cardona (0xPolygonHermez#3158)

* synchronizer: fix case emtpy batch and unittest (0xPolygonHermez#3159)

* fix case emtpy batch and unittest

* fix error in conversion

* fix unittest

* update prover image to v4.0.1 (0xPolygonHermez#3160)

* update prover image to v4.0.2 (0xPolygonHermez#3162)

* Add a note in deployment instruction to restart rpc after forkId 7 (0xPolygonHermez#3163)

* note to restart zkevm-rpc

* update comment

* change position of point 10

* add point 11

* add lines

* add breakline

* add lines

* add line

* addressed comments

* wip

* updated mocks

* CDK DAC interfaces got renamed, apply those updates to the Makefile mockery generation

* Linter errors fixes

* testnet files are needed for docker

* revert go-ethereum to 1.13.2

* Bump only the version of the cdk-dac dependency to v0.0.4

* updated docs

* Try removing testnet configuration

* docs update

---------

Co-authored-by: agnusmor <100322135+agnusmor@users.noreply.github.com>
Co-authored-by: Alonso Rodriguez <ARR552@users.noreply.github.com>
Co-authored-by: Toni Ramírez <toni@polygon.technology>
Co-authored-by: Thiago Coimbra Lemos <tclemos@users.noreply.github.com>
Co-authored-by: Joan Esteban <129153821+joanestebanr@users.noreply.github.com>
Co-authored-by: Toni Ramírez <58293609+ToniRamirezM@users.noreply.github.com>
Co-authored-by: agnusmor <agnusmor@gmail.com>
Co-authored-by: Stefan Negovanović <stefan@ethernal.tech>
  • Loading branch information
9 people authored Feb 7, 2024
1 parent b423092 commit 283971e
Show file tree
Hide file tree
Showing 101 changed files with 30,924 additions and 27,126 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ RUN cd /src && make build
# CONTAINER FOR RUNNING BINARY
FROM alpine:3.18.4
COPY --from=build /src/dist/zkevm-node /app/zkevm-node
COPY --from=build /src/config/environments/testnet/node.config.toml /app/example.config.toml
RUN apk update && apk add postgresql15-client
EXPOSE 8123
CMD ["/bin/sh", "-c", "/app/zkevm-node run"]
30 changes: 19 additions & 11 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,15 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.
if err != nil {
return nil, err
}
leaves, err := a.State.GetLeafsByL1InfoRoot(ctx, *l1InfoRoot, nil)
if err != nil {
return nil, err
}

aLeaves := make([][32]byte, len(leaves))
for i, leaf := range leaves {
aLeaves[i] = l1infotree.HashLeafData(leaf.GlobalExitRoot.GlobalExitRoot, leaf.PreviousBlockHash, uint64(leaf.Timestamp.Unix()))
}

for _, l2blockRaw := range batchRawData.Blocks {
_, contained := l1InfoTreeData[l2blockRaw.IndexL1InfoTree]
Expand All @@ -1013,21 +1022,20 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.
return nil, err
}

leaves, err := a.State.GetLeafsByL1InfoRoot(ctx, l1InfoTreeExitRootStorageEntry.L1InfoTreeRoot, nil)
if err != nil {
return nil, err
}

aLeaves := make([][32]byte, len(leaves))
for i, leaf := range leaves {
aLeaves[i] = l1infotree.HashLeafData(leaf.GlobalExitRoot.GlobalExitRoot, leaf.PreviousBlockHash, uint64(leaf.Timestamp.Unix()))
}

// Calculate smt proof
smtProof, _, err := tree.ComputeMerkleProof(l2blockRaw.IndexL1InfoTree, aLeaves)
smtProof, calculatedL1InfoRoot, err := tree.ComputeMerkleProof(l2blockRaw.IndexL1InfoTree, aLeaves)
if err != nil {
return nil, err
}
if l1InfoRoot != nil && *l1InfoRoot != calculatedL1InfoRoot {
for i, l := range aLeaves {
log.Info("AllLeaves[%d]: %s", i, common.Bytes2Hex(l[:]))
}
for i, s := range smtProof {
log.Info("smtProof[%d]: %s", i, common.Bytes2Hex(s[:]))
}
return nil, fmt.Errorf("error: l1InfoRoot mismatch. L1InfoRoot: %s, calculatedL1InfoRoot: %s. l1InfoTreeIndex: %d", l1InfoRoot.String(), calculatedL1InfoRoot.String(), l2blockRaw.IndexL1InfoTree)
}

protoProof := make([][]byte, len(smtProof))
for i, proof := range smtProof {
Expand Down
5 changes: 5 additions & 0 deletions aggregator/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
TimestampBatchEtrog: &t,
}
m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice()
m.stateMock.On("GetLeafsByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice()
expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve)
require.NoError(err)
m.proverMock.On("BatchProof", expectedInputProver).Return(nil, errBanana).Once()
Expand Down Expand Up @@ -840,6 +841,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
TimestampBatchEtrog: &t,
}
m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice()
m.stateMock.On("GetLeafsByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice()
expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve)
require.NoError(err)
m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once()
Expand Down Expand Up @@ -882,6 +884,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
TimestampBatchEtrog: &t,
}
m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice()
m.stateMock.On("GetLeafsByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice()
expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve)
require.NoError(err)
m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once()
Expand Down Expand Up @@ -924,6 +927,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
TimestampBatchEtrog: &t,
}
m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice()
m.stateMock.On("GetLeafsByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice()
expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve)
require.NoError(err)
m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once()
Expand Down Expand Up @@ -980,6 +984,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
TimestampBatchEtrog: &t,
}
m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice()
m.stateMock.On("GetLeafsByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice()
expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve)
require.NoError(err)
m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once()
Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
networkFlag = cli.StringFlag{
Name: config.FlagNetwork,
Aliases: []string{"net"},
Usage: "Load default network configuration. Supported values: [`mainnet`, `testnet`, `custom`]",
Usage: "Load default network configuration. Supported values: [`custom`]",
Required: true,
}
customNetworkFlag = cli.StringFlag{
Expand Down
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func newDataAvailability(c config.Config, st *state.State, etherman *etherman.Cl
c.Etherman.URL,
dacAddr,
pk,
&dataCommitteeClient.Factory{},
dataCommitteeClient.NewFactory(),
)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
FlagYes = "yes"
// FlagCfg is the flag for cfg.
FlagCfg = "cfg"
// FlagNetwork is the flag for the network name. Valid values: ["testnet", "mainnet", "custom"].
// FlagNetwork is the flag for the network name. Valid values: ["custom"].
FlagNetwork = "network"
// FlagCustomNetwork is the flag for the custom network file. This is required if --network=custom
FlagCustomNetwork = "custom-network-file"
Expand Down
9 changes: 0 additions & 9 deletions config/environments/mainnet/example.env

This file was deleted.

94 changes: 0 additions & 94 deletions config/environments/mainnet/node.config.toml

This file was deleted.

Loading

0 comments on commit 283971e

Please sign in to comment.