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

Pullupstream/v0.5.13 #83

Merged
merged 20 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0171536
check unsupported precompiles (#3264)
ToniRamirezM Feb 14, 2024
eb3ae9b
fix RPC closebatch executor error (#3272)
ToniRamirezM Feb 14, 2024
2d76f12
fix executor error closebatch (#3276)
joanestebanr Feb 14, 2024
20fa91f
add oog2 checks for all the oog cheks (#3277)
tclemos Feb 14, 2024
f968d8b
fix oog2 in internal gas estimation (#3280)
ToniRamirezM Feb 16, 2024
ca5a2c2
execution mode (#3285)
ToniRamirezM Feb 16, 2024
0a58f28
update prover image (#3286)
ToniRamirezM Feb 16, 2024
857be17
fix log when error on batch sanity check (#3287)
agnusmor Feb 16, 2024
5a1782f
update prover image to v4.0.13 (#3289)
agnusmor Feb 16, 2024
a7c9c71
update prover image (#3290)
ToniRamirezM Feb 17, 2024
3b25971
fix deltaTimestamp when debug tx (#3291)
tclemos Feb 17, 2024
bfe0166
fix checkStateInconsistency when starting sequencer (#3294)
agnusmor Feb 17, 2024
8cb1842
disable delete addrQueue if empty as a workaround (#3295)
agnusmor Feb 18, 2024
5abad0d
add aggregator.BatchProofL1BlockConfirmations config parameter (#3302)
agnusmor Feb 19, 2024
e767b9e
add SkipVerifyL1InfoRoot as true when debug trace needs to provide th…
tclemos Feb 20, 2024
dd33559
fix tx index provided in the tx log responses (#3303)
tclemos Feb 20, 2024
3ae5a9a
Fix null fields for pending blocks (#3274)
tclemos Feb 20, 2024
93a5a64
Add endpoint to estimate ZK Counters (#3260)
tclemos Feb 20, 2024
6c864ad
add zkevm_estimateGasPrice (#3248) (#3327)
tclemos Feb 20, 2024
df7b227
merge upstream changes
rachit77 Feb 22, 2024
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
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
Loading