Skip to content

Commit

Permalink
Pullupstream/v0.5.13 (#83)
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)

* add SkipVerifyL1InfoRoot as true when debug trace needs to provide the l1 info tree data (0xPolygonHermez#3321)

* fix tx index provided in the tx log responses (0xPolygonHermez#3303)

* Fix null fields for pending blocks (0xPolygonHermez#3274)

* Add endpoint to estimate ZK Counters (0xPolygonHermez#3260)

* add zkevm_estimateGasPrice (0xPolygonHermez#3248) (0xPolygonHermez#3327)

---------

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>
  • Loading branch information
7 people authored Feb 22, 2024
1 parent 80c8ad6 commit 3953b4e
Show file tree
Hide file tree
Showing 39 changed files with 1,737 additions and 789 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN cd /src/db && packr2
RUN cd /src && make build

# CONTAINER FOR RUNNING BINARY
FROM alpine:3.18.4
FROM alpine:3.18
COPY --from=build /src/dist/zkevm-node /app/zkevm-node
RUN apk update && apk add postgresql15-client
EXPOSE 8123
Expand Down
17 changes: 16 additions & 1 deletion aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,23 @@ func (a *Aggregator) getAndLockBatchToProve(ctx context.Context, prover proverIn
return nil, nil, err
}

// Get header of the last L1 block
lastL1BlockHeader, err := a.Ethman.GetLatestBlockHeader(ctx)
if err != nil {
log.Errorf("Failed to get last L1 block header, err: %v", err)
return nil, nil, err
}
lastL1BlockNumber := lastL1BlockHeader.Number.Uint64()

// Calculate max L1 block number for getting next virtual batch to prove
maxL1BlockNumber := uint64(0)
if a.cfg.BatchProofL1BlockConfirmations <= lastL1BlockNumber {
maxL1BlockNumber = lastL1BlockNumber - a.cfg.BatchProofL1BlockConfirmations
}
log.Debugf("Max L1 block number for getting next virtual batch to prove: %d", maxL1BlockNumber)

// Get virtual batch pending to generate proof
batchToVerify, err := a.State.GetVirtualBatchToProve(ctx, lastVerifiedBatch.BatchNumber, nil)
batchToVerify, err := a.State.GetVirtualBatchToProve(ctx, lastVerifiedBatch.BatchNumber, maxL1BlockNumber, nil)
if err != nil {
return nil, nil, err
}
Expand Down
16 changes: 11 additions & 5 deletions aggregator/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/0xPolygonHermez/zkevm-node/state"
"github.com/0xPolygonHermez/zkevm-node/test/testutils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -775,7 +776,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
m.proverMock.On("ID").Return(proverID).Twice()
m.proverMock.On("Addr").Return("addr")
m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, nil).Return(&batchToProve, nil).Once()
m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
func(args mock.Arguments) {
proof := args[1].(*state.Proof)
Expand All @@ -798,6 +799,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
L1InfoRoot: &l1InfoRoot,
TimestampBatchEtrog: &t,
}
m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once()
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)
Expand All @@ -817,7 +819,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
m.proverMock.On("ID").Return(proverID).Twice()
m.proverMock.On("Addr").Return("addr")
m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, nil).Return(&batchToProve, nil).Once()
m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
func(args mock.Arguments) {
proof := args[1].(*state.Proof)
Expand All @@ -840,6 +842,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
L1InfoRoot: &l1InfoRoot,
TimestampBatchEtrog: &t,
}
m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once()
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)
Expand All @@ -860,7 +863,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
m.proverMock.On("ID").Return(proverID).Twice()
m.proverMock.On("Addr").Return(proverID)
m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, nil).Return(&batchToProve, nil).Once()
m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
func(args mock.Arguments) {
proof := args[1].(*state.Proof)
Expand All @@ -883,6 +886,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
L1InfoRoot: &l1InfoRoot,
TimestampBatchEtrog: &t,
}
m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once()
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)
Expand All @@ -903,7 +907,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
m.proverMock.On("ID").Return(proverID).Times(3)
m.proverMock.On("Addr").Return("addr")
m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, nil).Return(&batchToProve, nil).Once()
m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
func(args mock.Arguments) {
proof := args[1].(*state.Proof)
Expand All @@ -926,6 +930,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
L1InfoRoot: &l1InfoRoot,
TimestampBatchEtrog: &t,
}
m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once()
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)
Expand Down Expand Up @@ -960,7 +965,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
m.proverMock.On("ID").Return(proverID).Times(3)
m.proverMock.On("Addr").Return("addr")
m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, nil).Return(&batchToProve, nil).Once()
m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
func(args mock.Arguments) {
proof := args[1].(*state.Proof)
Expand Down Expand Up @@ -995,6 +1000,7 @@ func TestTryGenerateBatchProof(t *testing.T) {
On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).
Return(&state.VerifiedBatch{BatchNumber: uint64(42)}, nil).Once()
m.etherman.On("GetLatestVerifiedBatchNum").Return(uint64(42), nil).Once()
m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once()
// make tryBuildFinalProof fail ASAP
m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, errBanana).Once().NotBefore(isSyncedCall)
m.stateMock.On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), mock.Anything, nil).Run(
Expand Down
3 changes: 3 additions & 0 deletions aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,7 @@ type Config struct {

// SequencerPrivateKey Private key of the trusted sequencer
SequencerPrivateKey types.KeystoreFileConfig `mapstructure:"SequencerPrivateKey"`

// BatchProofL1BlockConfirmations is number of L1 blocks to consider we can generate the proof for a virtual batch
BatchProofL1BlockConfirmations uint64 `mapstructure:"BatchProofL1BlockConfirmations"`
}
4 changes: 3 additions & 1 deletion aggregator/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
"github.com/0xPolygonHermez/zkevm-node/state"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/jackc/pgx/v4"
)

Expand Down Expand Up @@ -40,6 +41,7 @@ type etherman interface {
GetRollupId() uint32
GetLatestVerifiedBatchNum() (uint64, error)
BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address) (to *common.Address, data []byte, err error)
GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
}

// aggregatorTxProfitabilityChecker interface for different profitability
Expand All @@ -54,7 +56,7 @@ type stateInterface interface {
CheckProofContainsCompleteSequences(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) (bool, error)
GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)
GetProofReadyToVerify(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*state.Proof, error)
GetVirtualBatchToProve(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
GetVirtualBatchToProve(ctx context.Context, lastVerfiedBatchNumber uint64, maxL1Block uint64, dbTx pgx.Tx) (*state.Batch, error)
GetProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*state.Proof, *state.Proof, error)
GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
AddGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error
Expand Down
35 changes: 35 additions & 0 deletions aggregator/mocks/mock_etherman.go

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

18 changes: 9 additions & 9 deletions aggregator/mocks/mock_state.go

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

10 changes: 10 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,16 @@ func runJSONRPCServer(c config.Config, etherman *etherman.Client, chainID uint64
storage := jsonrpc.NewStorage()
c.RPC.MaxCumulativeGasUsed = c.State.Batch.Constraints.MaxCumulativeGasUsed
c.RPC.L2Coinbase = c.SequenceSender.L2Coinbase
c.RPC.ZKCountersLimits = jsonrpc.ZKCountersLimits{
MaxKeccakHashes: c.State.Batch.Constraints.MaxKeccakHashes,
MaxPoseidonHashes: c.State.Batch.Constraints.MaxPoseidonHashes,
MaxPoseidonPaddings: c.State.Batch.Constraints.MaxPoseidonPaddings,
MaxMemAligns: c.State.Batch.Constraints.MaxMemAligns,
MaxArithmetics: c.State.Batch.Constraints.MaxArithmetics,
MaxBinaries: c.State.Batch.Constraints.MaxBinaries,
MaxSteps: c.State.Batch.Constraints.MaxSteps,
MaxSHA256Hashes: c.State.Batch.Constraints.MaxSHA256Hashes,
}
if !c.IsTrustedSequencer {
if c.RPC.SequencerNodeURI == "" {
log.Debug("getting trusted sequencer URL from smc")
Expand Down
4 changes: 4 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ func Test_Defaults(t *testing.T) {
path: "Aggregator.UpgradeEtrogBatchNumber",
expectedValue: uint64(0),
},
{
path: "Aggregator.BatchProofL1BlockConfirmations",
expectedValue: uint64(2),
},
{
path: "State.Batch.Constraints.MaxTxsPerBatch",
expectedValue: uint64(300),
Expand Down
1 change: 1 addition & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ SettlementBackend = "agglayer"
AggLayerTxTimeout = "5m"
AggLayerURL = "http://zkevm-agglayer"
SequencerPrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
BatchProofL1BlockConfirmations = 2
[L2GasPriceSuggester]
Type = "follower"
Expand Down
1 change: 1 addition & 0 deletions config/environments/local/local.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ SenderAddress = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8"
CleanupLockedProofsInterval = "2m"
GeneratingProofCleanupThreshold = "10m"
UpgradeEtrogBatchNumber = 0
BatchProofL1BlockConfirmations = 2

[EthTxManager]
ForcedGas = 0
Expand Down
Loading

0 comments on commit 3953b4e

Please sign in to comment.