Skip to content

Commit

Permalink
Fetch upstream v0.6.4 (#108)
Browse files Browse the repository at this point in the history
* check unsupported precompiles  (0xPolygonHermez#3264)

* check unsupported precompiles

* downgrade prover

* restore solc version

* update SC

* new errors

* fix as workaround to close batch on tx oog (0xPolygonHermez#3271)

Co-authored-by: agnusmor <agnusmor@gmail.com>

* handle executor close batch

* added sanity check closing an empty batch

* change log

---------

Co-authored-by: agnusmor <agnusmor@gmail.com>

* fix RPC closebatch executor error (0xPolygonHermez#3272)

* fix RPC closebatch executor error

* fix close batch

* fix close batch

* fix close batch

* fix close batch

* fix close batch

---------

Co-authored-by: agnusmor <agnusmor@gmail.com>

* fix executor error closebatch (0xPolygonHermez#3276)

* fix executor error closebatch

* fix linter

---------

Co-authored-by: agnusmor <agnusmor@gmail.com>

* add oog2 checks for all the oog cheks (0xPolygonHermez#3277)

* fix oog2 in internal gas estimation (0xPolygonHermez#3280)

* fix oog2

* fix oog2 for estimateGas

---------

Co-authored-by: tclemos <thiago@polygon.technology>

* execution mode (0xPolygonHermez#3285)

* execution mode

* execution mode

* execution mode

* update prover image (0xPolygonHermez#3286)

* fix log when error on batch sanity check (0xPolygonHermez#3287)

* update prover image to v4.0.13 (0xPolygonHermez#3289)

* update prover image (0xPolygonHermez#3290)

* fix deltaTimestamp when debug tx (0xPolygonHermez#3291)

* fix deltaTimestamp when debug tx

* fix deltaTimeStamp for unsigned txs execution for specific block

* fix deltaTimeStamp for unsigned txs execution for specific block

* Revert "fix deltaTimeStamp for unsigned txs execution for specific block"

This reverts commit eb77e04.

* Revert "fix deltaTimeStamp for unsigned txs execution for specific block"

This reverts commit d2cfa78.

* fix debug trace l1 info tree index and add l1 info tree data

* move MockL1InfoRoot from sequencer to state to allow multiple components to use the same value

---------

Co-authored-by: agnusmor <agnusmor@gmail.com>

* fix checkStateInconsistency when starting sequencer (0xPolygonHermez#3294)

* disable delete addrQueue if empty as a workaround (0xPolygonHermez#3295)

* add aggregator.BatchProofL1BlockConfirmations config parameter (0xPolygonHermez#3302) (0xPolygonHermez#3313)

* Feature remove executor errors (0xPolygonHermez#3317)

* remove executor errors

* readd check

* support to elderberry fork (0xPolygonHermez#3301)

* add new sequenceBatches parameters
* update SMC Elderberry, contract dockers and genesis
* elderberry seq-sender (0xPolygonHermez#3312)
* elderberry seq-sender
* updated prover  image to v5.0.0-RC4
* increase timeout  to e2e-group7

---------

Co-authored-by: Toni Ramírez <58293609+ToniRamirezM@users.noreply.github.com>
Co-authored-by: dPunisher <dpunish3r@users.noreply.github.com>

* update prover image (0xPolygonHermez#3322)

* update prover image

* udpate prover docker memory limits

* downgrade prover

* upgrade prover

* Get last l2 block in a batch by batch number (0xPolygonHermez#3335)

* last l2 block by batch number

* optimization

* change returned err in query

* add selector for trusted sync to prevent from executing from an old trusted node  (0xPolygonHermez#3336)

* add selector for trusted sync to check that batches  correspond to the supported forkids

* synchronizer adopt GetLastL2BlockByBatchNumber to check elderberry tstamp baches (0xPolygonHermez#3340)

* synchronizer adopt GetLastL2BlockByBatchNumber to check elderberry bacthes tstamp

* reserved zk counters (0xPolygonHermez#3343)

* reserved zk counters

* new prover image

* udpate counters names

* udpate counters names

* add gas used to reserved zkCounters

* add ReservedZKCounters to pool trasactions

* Add reserved zk counters to pool transactions (0xPolygonHermez#3346)

* add reserved zk counters to pool transaction

* add reserved zk counters to pool transaction

* correct migration test

* Merge v0.5.13 into v0.6.0 (0xPolygonHermez#3350)

* Update reserved counters with used in pool db during migration (0xPolygonHermez#3352)

* return used if reserved counters are 0

* refactor

* refactor

* fix initial sequenced batch event (0xPolygonHermez#3347)

* fix initial sequenced batch event

* Add executor reserved ZK counters (0xPolygonHermez#3348)

* add executor reserved ZK counters

* update prover image to v5.0.0-RC6

* fix typos

* add check reserved counters when executing L2 block

* remove closeBatch

* update prover image v5.0.0-RC7

* fixes and logs improvements

* update prover image v5.0.0-RC8

* fix return on node OOC. Fix logs (0xPolygonHermez#3359)

* to decode ETROG processBatches use ETROG contract (0xPolygonHermez#3360)

* decode old ETROG processBatches use ETROG contract
* fix sanity genesis

* Synchronized inform field state.batch.closing_reason from DB

* Add reasons to the field `state.batch.closing_reason` (issue 0xPolygonHermez#3243)

* remove unnecessary eventlog call when processing unsigned txs (0xPolygonHermez#3365)

* Fix batch 0 timestamp (0xPolygonHermez#3364)

* ignore forkid events from another rollup (0xPolygonHermez#3383)

* Add l2block/interval metrics. Use timeoutCond when waiting for worker readyTxs (0xPolygonHermez#3380)

* Feature/cherry pick 3370 3374 synchronizer, fix bugs, ReprocessFullBatchOnClose and AcceptEmptyClosedBatches (0xPolygonHermez#3384)

* synchronizer accepts empty closed batches from trusted depending on config (0xPolygonHermez#3370)

* accept empty closed batches depending on config
* if trusted synchronization dont create L2 sync classes

* sync reprocess full batch on close, check GER, and fix minor bugs (0xPolygonHermez#3374)

* sync reprocess full batch on close
* reduce the of live of batch cache from 1hour to 5min
* fix reprocess, check virtualBatch before reseting state
* 0xPolygonHermez#3376 - check GlobalExitRoot before working on a batch
* update same data as updateWIPBatch do in the cache of batches

* set Synchronizer.L2Synchronization.ReprocessFullBatchOnClose to false

* update documentation

* fix metrics cleanUp (0xPolygonHermez#3385)

* fix check poseidonHashes exhausted (0xPolygonHermez#3393)

* remove execution mode (0xPolygonHermez#3395)

* fix metrics estimatedTxsPerSec (0xPolygonHermez#3396)

* Fix metrics estimatedTxsPerSec division (0xPolygonHermez#3398)

* fix metrics estimatedTxsPerSec div

* remove unneeded cast

* Get IM State root from receipt for data stream. (0xPolygonHermez#3400)

* get im state root from receipt

* get im state root from receipt

* get im state root from receipt

* Add gas per second estimation in metrics (0xPolygonHermez#3401)

* add gas estimation in metrics

* fix linter

* Feature/cherry pick 3375 sync add check l2block hash (0xPolygonHermez#3406)

* check L2Block hash on closed batch during sync from TrustedNode (0xPolygonHermez#3390)

* update prover image to v5.0.3 (0xPolygonHermez#3407)

* keep empty RPC.SequencerNodeURI config parameter to get node URI from the SC (0xPolygonHermez#3430)

* add log0 debug trace e2e tests (0xPolygonHermez#3422)

* add log0 debug trace e2e tests

* add log0 debug trace e2e tests

* Elderberry blockhash adjustments (0xPolygonHermez#3424)

* remove intermediate state root from receipts after Etrog

* use receipt state returned by executor instead of checking the RomError

* use receipt status from executor only after Etrog

* fix gasLimit and cumulativeGasUsed for Elderberry txs (0xPolygonHermez#3428)

* keep im state root in db (0xPolygonHermez#3427)

* generate receipt refactor (0xPolygonHermez#3436)

* generate receipt refactor

* update prover image

* downgrade prover image

---------

Co-authored-by: agnusmor <100322135+agnusmor@users.noreply.github.com>
Co-authored-by: Toni Ramírez <58293609+ToniRamirezM@users.noreply.github.com>

* update prover to v5.0.6 (0xPolygonHermez#3437)

* remove intermediate state root from receipts after Etrog

* use receipt state returned by executor instead of checking the RomError

* use receipt status from executor only after Etrog

* fix gasLimit and cumulativeGasUsed for Elderberry txs (0xPolygonHermez#3428)

* keep im state root in db (0xPolygonHermez#3427)

* generate receipt refactor (0xPolygonHermez#3436)

* generate receipt refactor

* update prover image

* downgrade prover image

* update prover

* adapt test

* undo adapt test

* upgrade prover

---------

Co-authored-by: tclemos <thiago@polygon.technology>
Co-authored-by: agnusmor <100322135+agnusmor@users.noreply.github.com>

* use empty byte array instead of all zeros for receipt poststate (0xPolygonHermez#3449)

* L1 Synchronization process check some L2Blocks from TrustedNode (0xPolygonHermez#3445)

* L1 Synchronization process check some L2Blocks from TrustedNode

* l1sync: if local batch is WIP need to be reprocess (0xPolygonHermez#3443)

* Synchronizer accept forkids that are the same as in database (0xPolygonHermez#3452)

* 0xPolygonHermez#3451 accept same forkid from L1
* if same forkid recived and is the last one and same FromBatchNumber update blockNumber

* remove unnecessary eventlog call when estimating tx gas (0xPolygonHermez#3457)

* fix debug trace for injected tx (0xPolygonHermez#3469) (0xPolygonHermez#3473)

* Add sanity-check on checkL1InfoTreeUpdate to check state L1 blockhash matches ethereum blockhash (L1 reorg check) (0xPolygonHermez#3480)

* Add sanity check on checkL1InfoTreeUpdate to check state L1 blockhash matches ethereum blockhash (L1 reorg check)

* fix L1 block is 0 (empty l1infotree)

* Update Prover image to v5.0.9

* support forkid 9 (0xPolygonHermez#3496)

* fix aggregator l1 info tree (0xPolygonHermez#3490) (0xPolygonHermez#3491) (0xPolygonHermez#3484)  (0xPolygonHermez#3495)

* fix aggregator l1 info tree (0xPolygonHermez#3491)

* fix aggregator l1 info tree

* Fix case you want to proof a 0 (0xPolygonHermez#3492)

* Fix case you want to proof a 0

* init timestamp

---------

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

* force forkid 9

* update prover

---------

Co-authored-by: Jordi Baylina <jordi@baylina.cat>
Co-authored-by: agnusmor <agnusmor@gmail.com>

* fix debug trace receipt index (0xPolygonHermez#3490)

* conflicts

* fix ooc

* fix tx index calculation on receipt (0xPolygonHermez#3488)

* remove 3495

---------

Co-authored-by: Jordi Baylina <jordi@baylina.cat>
Co-authored-by: agnusmor <agnusmor@gmail.com>

* Update the diff file

* Align trace.go with the upstream

---------

Co-authored-by: Toni Ramírez <58293609+ToniRamirezM@users.noreply.github.com>
Co-authored-by: agnusmor <agnusmor@gmail.com>
Co-authored-by: Joan Esteban <129153821+joanestebanr@users.noreply.github.com>
Co-authored-by: Thiago Coimbra Lemos <tclemos@users.noreply.github.com>
Co-authored-by: tclemos <thiago@polygon.technology>
Co-authored-by: agnusmor <100322135+agnusmor@users.noreply.github.com>
Co-authored-by: dPunisher <dpunish3r@users.noreply.github.com>
Co-authored-by: Jordi Baylina <jordi@baylina.cat>
  • Loading branch information
9 people committed Mar 26, 2024
1 parent 54f6b28 commit dc85fb7
Show file tree
Hide file tree
Showing 15 changed files with 8,833 additions and 44,060 deletions.
16 changes: 11 additions & 5 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const (

ethTxManagerOwner = "aggregator"
monitoredIDFormat = "proof-from-%v-to-%v"

forkId9 = uint64(9)
)

type finalProofMsg struct {
Expand Down Expand Up @@ -194,7 +196,7 @@ func (a *Aggregator) Channel(stream prover.AggregatorService_ChannelServer) erro
log.Info("Establishing stream connection with prover")

// Check if prover supports the required Fork ID
if !prover.SupportsForkID(a.cfg.ForkId) {
if !prover.SupportsForkID(forkId9) {
err := errors.New("prover does not support required fork ID")
log.Warn(FirstToUpper(err.Error()))
return err
Expand Down Expand Up @@ -1149,9 +1151,13 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.
for _, l2blockRaw := range batchRawData.Blocks {
_, contained := l1InfoTreeData[l2blockRaw.IndexL1InfoTree]
if !contained && l2blockRaw.IndexL1InfoTree != 0 {
l1InfoTreeExitRootStorageEntry, err := a.State.GetL1InfoRootLeafByIndex(ctx, l2blockRaw.IndexL1InfoTree, nil)
if err != nil {
return nil, err
l1InfoTreeExitRootStorageEntry := state.L1InfoTreeExitRootStorageEntry{}
l1InfoTreeExitRootStorageEntry.Timestamp = time.Unix(0, 0)
if l2blockRaw.IndexL1InfoTree <= leaves[len(leaves)-1].L1InfoTreeIndex {
l1InfoTreeExitRootStorageEntry, err = a.State.GetL1InfoRootLeafByIndex(ctx, l2blockRaw.IndexL1InfoTree, nil)
if err != nil {
return nil, err
}
}

// Calculate smt proof
Expand Down Expand Up @@ -1204,7 +1210,7 @@ func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.
OldAccInputHash: previousBatch.AccInputHash.Bytes(),
OldBatchNum: previousBatch.BatchNumber,
ChainId: a.cfg.ChainID,
ForkId: a.cfg.ForkId,
ForkId: forkId9,
BatchL2Data: batchToVerify.BatchL2Data,
L1InfoRoot: l1InfoRoot.Bytes(),
TimestampLimit: uint64(batchToVerify.Timestamp.Unix()),
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ services:
zkevm-prover:
container_name: zkevm-prover
restart: unless-stopped
image: hermeznetwork/zkevm-prover:v5.0.6
image: hermeznetwork/zkevm-prover:v6.0.0
depends_on:
zkevm-state-db:
condition: service_healthy
Expand Down
52,547 changes: 8,601 additions & 43,946 deletions docs/diff/diff.html

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions l1infotree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,13 @@ func (mt *L1InfoTree) ComputeMerkleProof(gerIndex uint32, leaves [][32]byte) ([]
if len(leaves)%2 == 1 {
leaves = append(leaves, mt.zeroHashes[h])
}
if index%2 == 1 { //If it is odd
siblings = append(siblings, leaves[index-1])
} else { // It is even
if len(leaves) > 1 {
if index >= uint32(len(leaves)) {
// siblings = append(siblings, mt.zeroHashes[h])
siblings = append(siblings, leaves[index-1])
} else {
siblings = append(siblings, leaves[index+1])
}
if index >= uint32(len(leaves)) {
siblings = append(siblings, mt.zeroHashes[h])
} else {
if index%2 == 1 { //If it is odd
siblings = append(siblings, leaves[index-1])
} else { // It is even
siblings = append(siblings, leaves[index+1])
}
}
var (
Expand Down
35 changes: 31 additions & 4 deletions sequencer/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,19 @@ func (f *finalizer) updateFlushIDs(newPendingFlushID, newStoredFlushID uint64) {

func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) {
firstL1InfoRootUpdate := true
skipFirstSleep := true

for {
if skipFirstSleep {
skipFirstSleep = false
} else {
time.Sleep(f.cfg.L1InfoTreeCheckInterval.Duration)
}

lastL1BlockNumber, err := f.etherman.GetLatestBlockNumber(ctx)
if err != nil {
log.Errorf("error getting latest L1 block number, error: %v", err)
continue
}

maxBlockNumber := uint64(0)
Expand All @@ -246,9 +254,30 @@ func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) {
}

if firstL1InfoRootUpdate || l1InfoRoot.L1InfoTreeIndex > f.lastL1InfoTree.L1InfoTreeIndex {
firstL1InfoRootUpdate = false
log.Infof("received new L1InfoRoot, l1InfoTreeIndex: %d, l1InfoTreeRoot: %s, l1Block: %d",
l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.BlockNumber)

log.Debugf("received new L1InfoRoot. L1InfoTreeIndex: %d", l1InfoRoot.L1InfoTreeIndex)
// Sanity check l1BlockState (l1InfoRoot.BlockNumber) blockhash matches blockhash on ethereum. We skip it if l1InfoRoot.BlockNumber == 0 (empty tree)
if l1InfoRoot.BlockNumber > 0 {
l1BlockState, err := f.stateIntf.GetBlockByNumber(ctx, l1InfoRoot.BlockNumber, nil)
if err != nil {
log.Errorf("error getting L1 block %d from the state, error: %v", l1InfoRoot.BlockNumber, err)
continue
}

l1BlockEth, err := f.etherman.HeaderByNumber(ctx, new(big.Int).SetUint64(l1InfoRoot.BlockNumber))
if err != nil {
log.Errorf("error getting L1 block %d from ethereum, error: %v", l1InfoRoot.BlockNumber, err)
continue
}
if l1BlockState.BlockHash != l1BlockEth.Hash() {
log.Warnf("skipping use of l1InfoTreeIndex %d, L1 block %d blockhash %s doesn't match blockhash on ethereum %s (L1 reorg?)",
l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber, l1BlockState.BlockHash, l1BlockEth.Hash())
continue
}
}

firstL1InfoRootUpdate = false

f.lastL1InfoTreeMux.Lock()
f.lastL1InfoTree = l1InfoRoot
Expand All @@ -261,8 +290,6 @@ func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) {
f.lastL1InfoTreeCond.L.Unlock()
}
}

time.Sleep(f.cfg.L1InfoTreeCheckInterval.Duration)
}
}

Expand Down
1 change: 1 addition & 0 deletions sequencer/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type etherman interface {
TrustedSequencer() (common.Address, error)
GetLatestBatchNumber() (uint64, error)
GetLatestBlockNumber(ctx context.Context) (uint64, error)
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
}

// stateInterface gathers the methods required to interact with the state.
Expand Down
33 changes: 33 additions & 0 deletions sequencer/mock_etherman.go

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

1 change: 1 addition & 0 deletions state/batchV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ func (s *State) sendBatchRequestToExecutorV2(ctx context.Context, batchRequest *
log.Warn(batchResponseToString)
s.eventLog.LogExecutorErrorV2(ctx, batchResponse.Error, batchRequest)
} else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR && executor.IsROMOutOfCountersError(batchResponse.ErrorRom) {
err = executor.RomErr(batchResponse.ErrorRom)
log.Warnf("executor batch %d response, ROM OOC, error: %v", newBatchNum, err)
log.Warn(batchResponseToString)
} else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR {
Expand Down
2 changes: 2 additions & 0 deletions state/forkid.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const (
FORKID_ETROG = 7
// FORKID_ELDERBERRY is the fork id 8
FORKID_ELDERBERRY = 8
// FORKID_9 is the fork id 9
FORKID_9 = 9
)

// ForkIDInterval is a fork id interval
Expand Down
Loading

0 comments on commit dc85fb7

Please sign in to comment.