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

feat: remove DS from aggregator #138

Merged
merged 27 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ae4014d
feat: remove DS from aggregator
ToniRamirezM Oct 22, 2024
00c00eb
feat: remove DS from aggregator
ToniRamirezM Oct 22, 2024
4bd18c4
feat: unit tests
ToniRamirezM Oct 22, 2024
74c71fb
feat: unit tests
ToniRamirezM Oct 22, 2024
a8b6240
feat: unit tests
ToniRamirezM Oct 22, 2024
6742b5b
fix: rust
ToniRamirezM Oct 22, 2024
df22143
fix: seq-sender tests
ToniRamirezM Oct 22, 2024
e13cf99
fix: local_config script
ToniRamirezM Oct 22, 2024
c27575a
fix: remove unused file
ToniRamirezM Oct 22, 2024
016d99d
fix: default config
ToniRamirezM Oct 22, 2024
ed6daaf
fix: default config
ToniRamirezM Oct 22, 2024
a8f617c
fix: test config
ToniRamirezM Oct 22, 2024
0bc6f27
fix: nil l1inforoot
ToniRamirezM Oct 23, 2024
f7d214b
feat: improve coverage
ToniRamirezM Oct 23, 2024
e62c8eb
feat: improve coverage
ToniRamirezM Oct 23, 2024
ad5f822
feat: improve coverage
ToniRamirezM Oct 23, 2024
c87bd02
feat: improve coverage
ToniRamirezM Oct 23, 2024
d823403
feat: improve coverage
ToniRamirezM Oct 23, 2024
f2bfb99
feat: improve coverage
ToniRamirezM Oct 23, 2024
f90fbff
feat: improve coverage
ToniRamirezM Oct 23, 2024
65a7bdd
feat: improve coverage
ToniRamirezM Oct 23, 2024
a1558cc
feat: improve coverage
ToniRamirezM Oct 23, 2024
dca013e
feat: improve coverage
ToniRamirezM Oct 23, 2024
a516b33
feat: improve coverage
ToniRamirezM Oct 23, 2024
b4d77ca
fix: comments
ToniRamirezM Oct 24, 2024
249a47c
feat: remove DS lib
ToniRamirezM Oct 28, 2024
1cd576a
feat: resolve conflicts
ToniRamirezM Oct 28, 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
652 changes: 102 additions & 550 deletions aggregator/aggregator.go

Large diffs are not rendered by default.

531 changes: 193 additions & 338 deletions aggregator/aggregator_test.go

Large diffs are not rendered by default.

20 changes: 3 additions & 17 deletions aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,18 @@ type Config struct {
// final gas: 1100
GasOffset uint64 `mapstructure:"GasOffset"`

// RPCURL is the URL of the RPC server
RPCURL string `mapstructure:"RPCURL"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it checked that this conf param works with the new templated config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested locally on Kurtosis and it looks ok to me.


// WitnessURL is the URL of the witness server
WitnessURL string `mapstructure:"WitnessURL"`

// UseL1BatchData is a flag to enable the use of L1 batch data in the aggregator
UseL1BatchData bool `mapstructure:"UseL1BatchData"`

// UseFullWitness is a flag to enable the use of full witness in the aggregator
UseFullWitness bool `mapstructure:"UseFullWitness"`

// DB is the database configuration
DB db.Config `mapstructure:"DB"`

// StreamClient is the config for the stream client
StreamClient StreamClientCfg `mapstructure:"StreamClient"`

// EthTxManager is the config for the ethtxmanager
EthTxManager ethtxmanager.Config `mapstructure:"EthTxManager"`

Expand All @@ -149,22 +146,11 @@ type Config struct {
// AggLayerURL url of the agglayer service
AggLayerURL string `mapstructure:"AggLayerURL"`

// MaxWitnessRetrievalWorkers is the maximum number of workers that will be used to retrieve the witness
MaxWitnessRetrievalWorkers int `mapstructure:"MaxWitnessRetrievalWorkers"`

// SyncModeOnlyEnabled is a flag that activates sync mode exclusively.
// When enabled, the aggregator will sync data only from L1 and will not generate or read the data stream.
SyncModeOnlyEnabled bool `mapstructure:"SyncModeOnlyEnabled"`
}

// StreamClientCfg contains the data streamer's configuration properties
type StreamClientCfg struct {
// Datastream server to connect
Server string `mapstructure:"Server"`
// Log is the log configuration
Log log.Config `mapstructure:"Log"`
}

// newKeyFromKeystore creates a private key from a keystore file
func newKeyFromKeystore(cfg types.KeystoreFileConfig) (*ecdsa.PrivateKey, error) {
if cfg.Path == "" && cfg.Password == "" {
Expand Down
23 changes: 23 additions & 0 deletions aggregator/db/migrations/0004.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- +migrate Down
CREATE TABLE aggregator.batch (
batch_num BIGINT NOT NULL,
batch jsonb NOT NULL,
datastream varchar NOT NULL,
PRIMARY KEY (batch_num)
);
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved

ALTER TABLE aggregator.proof
ADD CONSTRAINT proof_batch_num_fkey FOREIGN KEY (batch_num) REFERENCES aggregator.batch (batch_num) ON DELETE CASCADE;

Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
ALTER TABLE aggregator.sequence
ADD CONSTRAINT sequence_from_batch_num_fkey FOREIGN KEY (from_batch_num) REFERENCES aggregator.batch (batch_num) ON DELETE CASCADE;

Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved

-- +migrate Up
ALTER TABLE aggregator.proof
DROP CONSTRAINT IF EXISTS proof_batch_num_fkey;

ALTER TABLE aggregator.sequence
DROP CONSTRAINT IF EXISTS sequence_from_batch_num_fkey;

DROP TABLE IF EXISTS aggregator.batch;
38 changes: 11 additions & 27 deletions aggregator/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ import (

ethmanTypes "github.com/0xPolygon/cdk/aggregator/ethmantypes"
"github.com/0xPolygon/cdk/aggregator/prover"
"github.com/0xPolygon/cdk/rpc/types"
"github.com/0xPolygon/cdk/state"
"github.com/0xPolygon/zkevm-ethtx-manager/ethtxmanager"
ethtxtypes "github.com/0xPolygon/zkevm-ethtx-manager/types"
"github.com/0xPolygonHermez/zkevm-data-streamer/datastreamer"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/jackc/pgx/v4"
)

// Consumer interfaces required by the package.
type RPCInterface interface {
GetBatch(batchNumber uint64) (*types.RPCBatch, error)
GetWitness(batchNumber uint64, fullWitness bool) ([]byte, error)
}

type ProverInterface interface {
Name() string
Expand All @@ -37,9 +41,9 @@ type Etherman interface {
BuildTrustedVerifyBatchesTxData(
lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address,
) (to *common.Address, data []byte, err error)
GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
GetLatestBlockHeader(ctx context.Context) (*ethtypes.Header, error)
GetBatchAccInputHash(ctx context.Context, batchNumber uint64) (common.Hash, error)
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
HeaderByNumber(ctx context.Context, number *big.Int) (*ethtypes.Header, error)
}

// aggregatorTxProfitabilityChecker interface for different profitability
Expand All @@ -62,26 +66,6 @@ type StateInterface interface {
CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error)
CheckProofExistsForBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (bool, error)
AddSequence(ctx context.Context, sequence state.Sequence, dbTx pgx.Tx) error
AddBatch(ctx context.Context, dbBatch *state.DBBatch, dbTx pgx.Tx) error
GetBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.DBBatch, error)
DeleteBatchesOlderThanBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
DeleteBatchesNewerThanBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
}

// StreamClient represents the stream client behaviour
type StreamClient interface {
Start() error
ExecCommandStart(fromEntry uint64) error
ExecCommandStartBookmark(fromBookmark []byte) error
ExecCommandStop() error
ExecCommandGetHeader() (datastreamer.HeaderEntry, error)
ExecCommandGetEntry(fromEntry uint64) (datastreamer.FileEntry, error)
ExecCommandGetBookmark(fromBookmark []byte) (datastreamer.FileEntry, error)
GetFromStream() uint64
GetTotalEntries() uint64
SetProcessEntryFunc(f datastreamer.ProcessEntryFunc)
ResetProcessEntryFunc()
IsStarted() bool
}

// EthTxManagerClient represents the eth tx manager interface
Expand All @@ -92,19 +76,19 @@ type EthTxManagerClient interface {
value *big.Int,
data []byte,
gasOffset uint64,
sidecar *types.BlobTxSidecar,
sidecar *ethtypes.BlobTxSidecar,
) (common.Hash, error)
AddWithGas(
ctx context.Context,
to *common.Address,
value *big.Int,
data []byte,
gasOffset uint64,
sidecar *types.BlobTxSidecar,
sidecar *ethtypes.BlobTxSidecar,
gas uint64,
) (common.Hash, error)
EncodeBlobData(data []byte) (kzg4844.Blob, error)
MakeBlobSidecar(blobs []kzg4844.Blob) *types.BlobTxSidecar
MakeBlobSidecar(blobs []kzg4844.Blob) *ethtypes.BlobTxSidecar
ProcessPendingMonitoredTxs(ctx context.Context, resultHandler ethtxmanager.ResultHandler)
Remove(ctx context.Context, id common.Hash) error
RemoveAll(ctx context.Context) error
Expand Down
Loading
Loading