Skip to content

Commit

Permalink
server part
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Apr 3, 2024
1 parent c97191f commit 9e36697
Show file tree
Hide file tree
Showing 34 changed files with 2,495 additions and 34 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

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

9 changes: 9 additions & 0 deletions .idea/blob-syncer.iml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ ldflags = -X $(REPO)/version.AppVersion=$(VERSION) \
-X $(REPO)/version.GitCommit=$(GIT_COMMIT) \
-X $(REPO)/version.GitCommitDate=$(GIT_COMMIT_DATE)

build:
build_syncer:
ifeq ($(OS),Windows_NT)
go build -o build/blob-syncer.exe -ldflags="$(ldflags)" main.go
else
go build -o build/blob-syncer -ldflags="$(ldflags)" main.go
endif

build_server:
ifeq ($(OS),Windows_NT)
go build $(BUILD_FLAGS) -o build/server.exe cmd/blob-syncer-server/main.go
else
go build $(BUILD_FLAGS) -o build/server cmd/blob-syncer-server/main.go
endif

install:
ifeq ($(OS),Windows_NT)
go install main.go
Expand Down Expand Up @@ -48,4 +55,9 @@ lint-fix:
format:
bash scripts/format.sh

.PHONY: lint lint-fix format
.PHONY: lint lint-fix format

swagger-gen:
swagger generate server -f ./swagger.yaml -A blob-syncer --default-scheme=http


6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
./build/blob-syncer --config-type local --config-path config/config.json

./build/server --config-type local --config-path config/config.json




1 change: 1 addition & 0 deletions blob-store/blob_h8765008_i1

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions blob-store/blob_h8775477_i0

Large diffs are not rendered by default.

Binary file modified build/blob-syncer
Binary file not shown.
57 changes: 57 additions & 0 deletions cmd/blob-syncer-server/main.go

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

2 changes: 1 addition & 1 deletion config/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"syncer_config": {
"bucket_name": "bsc-blobs",
"start_height": 8775477,
"start_height": 8775600,
"beacon_addrs": [
"https://eth2-beacon-mainnet.nodereal.io/v1/a24f28a0f2484effa9fea36b8e281272"
],
Expand Down
20 changes: 6 additions & 14 deletions db/dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,18 @@ func (d *BlobSvcDB) GetLatestProcessedBlock() (*Block, error) {
}

type BlobDB interface {
GetBlob(uint64) (*Blob, error)
GetBlobs(height int64) ([]*Blob, error)
//UpdateBlobStatus(blobName string, status BlobStatus) error
}

func (d *BlobSvcDB) GetBlob(u uint64) (*Blob, error) {
blob := Blob{}
err := d.db.Model(Block{}).Order("height desc").Take(&blob).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
func (d *BlobSvcDB) GetBlobs(height int64) ([]*Blob, error) {
blobs := make([]*Blob, 0)
if err := d.db.Where("height = ?", uint64(height)).Find(&blobs).Error; err != nil {
return blobs, err
}
return &blob, nil
return blobs, nil
}

//func (d *BlobSvcDB) UpdateBlobStatus(blobName string, status Status) error {
// return d.db.Transaction(func(dbTx *gorm.DB) error {
// return dbTx.Model(Blob{}).Where("name = ?", blobName).Updates(
// Blob{Status: status}).Error
// })
//}

type BundleDB interface {
GetLatestFinalizingBundle() (*Bundle, error)
CreateBundle(*Bundle) error
Expand Down
19 changes: 15 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@ go 1.20
require (
github.com/aws/aws-sdk-go v1.48.6
github.com/ethereum/go-ethereum v1.13.10
github.com/go-openapi/errors v0.20.4
github.com/go-openapi/loads v0.21.2
github.com/go-openapi/runtime v0.26.0
github.com/go-openapi/spec v0.20.9
github.com/go-openapi/strfmt v0.21.7
github.com/go-openapi/swag v0.22.4
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/jessevdk/go-flags v1.5.0
github.com/node-real/greenfield-bundle-service v0.0.1-beta
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/prysmaticlabs/prysm/v5 v5.0.2
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.15.0
golang.org/x/net v0.21.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gorm.io/driver/mysql v1.5.1
gorm.io/driver/sqlite v1.5.3
gorm.io/gorm v1.25.5

)

require (
Expand All @@ -28,13 +38,15 @@ require (
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/deckarep/golang-set/v2 v2.5.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/strfmt v0.21.7 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand Down Expand Up @@ -83,7 +95,6 @@ require (
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
Loading

0 comments on commit 9e36697

Please sign in to comment.