From 0f511435ff8e060753ab265fa3ff59233de1cc72 Mon Sep 17 00:00:00 2001 From: Victor Castell <0x@vcastellm.xyz> Date: Fri, 22 Mar 2024 09:11:39 +0000 Subject: [PATCH] Basic scaffolding for CDK --- api/.gitkeep | 0 build/docker-compose.yml | 0 cmd/main.go | 1 + go.mod | 3 +++ go.sum | 0 internal/.gitkeep | 0 pkg/aggregatormanager/.gitkeep | 0 pkg/cdk/sequencermanager/.gitkeep | 0 pkg/dataavailability/.gitkeep | 0 pkg/rpcproxy/.gitkeep | 0 pkg/sequencesender/.gitkeep | 0 pkg/syncer/.gitkeep | 0 scripts/.gitkeep | 0 sequencermanager/.gitkeep | 0 sequencesender/.gitkeep | 0 syncer/ethprovider/ethprovider.go | 9 +++++++++ syncer/interfaces.go | 9 +++++++++ syncer/provider.go | 1 + syncer/storage/inmem/inmem.go | 8 ++++++++ syncer/storage/storage.go | 7 +++++++ syncer/syncer.go | 23 +++++++++++++++++++++++ test/e2e.go | 1 + 22 files changed, 62 insertions(+) create mode 100644 api/.gitkeep create mode 100644 build/docker-compose.yml create mode 100644 cmd/main.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 internal/.gitkeep create mode 100644 pkg/aggregatormanager/.gitkeep create mode 100644 pkg/cdk/sequencermanager/.gitkeep create mode 100644 pkg/dataavailability/.gitkeep create mode 100644 pkg/rpcproxy/.gitkeep create mode 100644 pkg/sequencesender/.gitkeep create mode 100644 pkg/syncer/.gitkeep create mode 100644 scripts/.gitkeep create mode 100644 sequencermanager/.gitkeep create mode 100644 sequencesender/.gitkeep create mode 100644 syncer/ethprovider/ethprovider.go create mode 100644 syncer/interfaces.go create mode 100644 syncer/provider.go create mode 100644 syncer/storage/inmem/inmem.go create mode 100644 syncer/storage/storage.go create mode 100644 syncer/syncer.go create mode 100644 test/e2e.go diff --git a/api/.gitkeep b/api/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/build/docker-compose.yml b/build/docker-compose.yml new file mode 100644 index 00000000..e69de29b diff --git a/cmd/main.go b/cmd/main.go new file mode 100644 index 00000000..06ab7d0f --- /dev/null +++ b/cmd/main.go @@ -0,0 +1 @@ +package main diff --git a/go.mod b/go.mod new file mode 100644 index 00000000..c90ef606 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/0xPolygon/cdk + +go 1.22 diff --git a/go.sum b/go.sum new file mode 100644 index 00000000..e69de29b diff --git a/internal/.gitkeep b/internal/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/pkg/aggregatormanager/.gitkeep b/pkg/aggregatormanager/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/pkg/cdk/sequencermanager/.gitkeep b/pkg/cdk/sequencermanager/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/pkg/dataavailability/.gitkeep b/pkg/dataavailability/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/pkg/rpcproxy/.gitkeep b/pkg/rpcproxy/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/pkg/sequencesender/.gitkeep b/pkg/sequencesender/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/pkg/syncer/.gitkeep b/pkg/syncer/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/scripts/.gitkeep b/scripts/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/sequencermanager/.gitkeep b/sequencermanager/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/sequencesender/.gitkeep b/sequencesender/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/syncer/ethprovider/ethprovider.go b/syncer/ethprovider/ethprovider.go new file mode 100644 index 00000000..9bc463d8 --- /dev/null +++ b/syncer/ethprovider/ethprovider.go @@ -0,0 +1,9 @@ +package ethsyncer + +import ( + "github.com/0xPolygon/cdk/syncer/storage" +) + +type EthSyncer struct { + Storage storage.StorageService +} diff --git a/syncer/interfaces.go b/syncer/interfaces.go new file mode 100644 index 00000000..2be883fd --- /dev/null +++ b/syncer/interfaces.go @@ -0,0 +1,9 @@ +package syncer + +type EventSyncer interface { + GetData() []byte +} + +type EventProcessor interface { + Process(data []byte) error +} \ No newline at end of file diff --git a/syncer/provider.go b/syncer/provider.go new file mode 100644 index 00000000..d62c4fbc --- /dev/null +++ b/syncer/provider.go @@ -0,0 +1 @@ +package syncer diff --git a/syncer/storage/inmem/inmem.go b/syncer/storage/inmem/inmem.go new file mode 100644 index 00000000..b9a930b0 --- /dev/null +++ b/syncer/storage/inmem/inmem.go @@ -0,0 +1,8 @@ +package inmem + +type Inmem struct { +} + +func (inmem *Inmem) GetData() []byte { + return []byte("Inmem") +} diff --git a/syncer/storage/storage.go b/syncer/storage/storage.go new file mode 100644 index 00000000..c485ecb6 --- /dev/null +++ b/syncer/storage/storage.go @@ -0,0 +1,7 @@ +package storage + +// Storage is an interface for the storage of the syncer +type StorageService interface { + GetData() []byte + GetLatestVerifiedBlock() uint64 +} diff --git a/syncer/syncer.go b/syncer/syncer.go new file mode 100644 index 00000000..fab1add8 --- /dev/null +++ b/syncer/syncer.go @@ -0,0 +1,23 @@ +package syncer + +type Syncer interface { + // Start starts the syncer + Start() error + // Stop stops the syncer + Stop() error + // Synced returns true if the syncer is synced + Synced() bool + // SyncedChan returns a channel that is closed when the syncer is synced + SyncedChan() <-chan struct{} + // LatestVerifiedBlock returns the latest verified block + LatestVerifiedBlock() uint64 + // LatestBlock returns the latest block + LatestBlock() uint64 + // SyncedBlock returns the latest block that is synced + SyncedBlock() uint64 + // SyncedBlockChan returns a channel that is closed when the latest block is synced + SyncedBlockChan() <-chan struct{} +} + +type Sync struct { +} diff --git a/test/e2e.go b/test/e2e.go new file mode 100644 index 00000000..df8caf70 --- /dev/null +++ b/test/e2e.go @@ -0,0 +1 @@ +package e2e