blobstorage

package
v0.3.1-0...-ee1233d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 3 Imported by: 0

README

blob-storage

Repo for BLOB storage (archive and serve data)

how to run ?

Prerequisite is to have docker engine up and running.

  1. Start the mongoDB
cd local_docker && docker-compose up -d
  1. Start the indexer
ENV_FILE=.default.indexer.env run cmd/main.go indexer

By default the above command starts the app from the latest block height. If we want to specifiy a previous blockheight, we can run change it from the .default.indexer.env file, by adding a STARTING_BLOCK_ID variable.

  1. Start the server.
ENV_FILE=.default.server.env run cmd/main.go server

how to test / use ?

When the DB, blob-catcher and server is running, the blob-catcher is outputting the blobHash to the terminal (with the networkName variable too, tho it is not written into the DB). Use that blobHash (including the 0x) in

  1. Either in a curl command like this (you can query multiple blobHashes - comma separated - with one go and the result will be a respective array):
curl -X GET "http://localhost:27001/getBlob?blobHash=0x01a2a1cdc7ad221934061642a79a760776a013d0e6fa1a1c6b642ace009c372a,0xWRONG_HASH"

The result will be something like this:

{"data":[{"blob":"0x123...00","kzg_commitment":"0xabd68b406920aa74b83cf19655f1179d373b5a8cba21b126b2c18baf2096c8eb9ab7116a89b375546a3c30038485939e"}, {"blob":"NOT_FOUND","kzg_commitment":"NOT_FOUND"}]}
  1. Or to backtest, use the simple python script below, after overwriting the blob_hash variable:
python3 python_query.py

todos

What is still missing is:

  • small refinements and DevOps (prod-grade DB with creditentials, proper containerization)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDB = errors.Validation.NewWithKeyAndDetail("ERR_NO_DB", "DB is required")
)

Functions

This section is empty.

Types

type BlobHash

type BlobHash struct {
	BlobHash       string
	KzgCommitment  string
	BlockTimestamp uint64
	BlobData       string
	BlockID        uint64
	EmittedBlockID uint64
}

type BlobHashRepository

type BlobHashRepository interface {
	Save(opts SaveBlobHashOpts) error
	FirstByBlobHash(blobHash string) (*BlobHash, error)
	FindLatestBlockID() (uint64, error)
	DeleteAllAfterBlockID(blockID uint64) error
}

type DB

type DB interface {
	DB() (*sql.DB, error)
	GormDB() *gorm.DB
}

type DBConnectionOpts

type DBConnectionOpts struct {
	Name            string
	Password        string
	Host            string
	Database        string
	MaxIdleConns    uint64
	MaxOpenConns    uint64
	MaxConnLifetime uint64
	OpenFunc        func(dsn string) (DB, error)
}

type SaveBlobHashOpts

type SaveBlobHashOpts struct {
	BlobHash       string
	KzgCommitment  string
	BlockTimestamp uint64
	BlobData       string
	BlockID        uint64
	EmittedBlockID uint64
}

Directories

Path Synopsis
bindings
cmd
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL