ethstore

package module
v0.0.0-...-da895ce Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: GPL-3.0 Imports: 32 Imported by: 1

README

ethstore

ETH.STORE® is not made available for use as a benchmark, whether in relation to a financial instrument, financial contract or to measure the performance of an investment fund, or otherwise in a way that would require it to be administered by a benchmark administrator pursuant to the EU Benchmarks Regulation. Currently Bitfly does not grant any right to access or use ETH.STORE® for such purpose.

ETH.STORE (Ether Staking Offered Rate) represents the average financial return validators on the Ethereum network have achieved in a 24-hour period.

usage

# build and install binary from source via go
go install github.com/gobitfly/eth.store

eth.store -h
Usage of /bin/eth.store:
  -cons.address string
    	address of the conensus-node-api (default "http://localhost:4000")
  -cons.timeout duration
    	timeout duration for the consensus-node-api (default 2m0s)
  -days string
    	days to calculate eth.store for, format: "1-3" or "1,4,6"
  -debug uint
    	set debug-level (higher level will increase verbosity)
  -exec.address string
    	address of the execution-node-api (default "http://localhost:4000")
  -exec.timeout duration
    	timeout duration for the execution-node-api (default 2m0s)
  -json
    	format output as json
  -json.file string
    	path to file to write results into, only missing days will be added
  -version
    	print version and exit


eth.store -cons.address="http://some-consensus-node:4000" -exec.address="http://some-execution-node:8545" -days="497-499"
day: 497 (2022-04-12 12:00:23 +0000 UTC), epochs: 111825-112049, validators: 341373, apr: 0.049083890, effectiveBalanceSumGwei: 10923834000000000, totalRewardsSumWei: 1468997980817000000000, consensusRewardsGwei: 1468997980817 (100%), txFeesSumWei: 0
day: 498 (2022-04-13 12:00:23 +0000 UTC), epochs: 112050-112274, validators: 342498, apr: 0.049011013, effectiveBalanceSumGwei: 10959834000000000, totalRewardsSumWei: 1471650879693000000000, consensusRewardsGwei: 1471650879693 (100%), txFeesSumWei: 0
day: 499 (2022-04-14 12:00:23 +0000 UTC), epochs: 112275-112499, validators: 343623, apr: 0.048898885, effectiveBalanceSumGwei: 10995834000000000, totalRewardsSumWei: 1473106903824000000000, consensusRewardsGwei: 1473106903824 (100%), txFeesSumWei: 0

# build and run docker-image and output json
git clone github.com/gobitfly/eth.store
cd eth.store
docker build . -t eth.store
docker run --network=host eth.store -cons.address="http://some-consensus-node:4000" -exec.address="http://some-execution-node:8545" -days="0,10" -json
[
	{
		"day": "0",
		"dayTime": "2020-12-01T12:00:23Z",
		"apr": "0.1740251707100836",
		"validators": "21062",
		"startEpoch": "0",
		"effectiveBalanceGwei": "673984000000000",
		"startBalanceGwei": "674112000000000",
		"endBalanceGwei": "674433342960701",
		"depositsSumGwei": "0",
		"consensusRewardsGwei": "321342960701",
		"txFeesSumWei": "0",
		"totalRewardsWei": "321342960701000000000"
	},
	{
		"day": "10",
		"dayTime": "2020-12-11T12:00:23Z",
		"apr": "0.1622832991187628",
		"validators": "29871",
		"startEpoch": "2250",
		"effectiveBalanceGwei": "955872000000000",
		"startBalanceGwei": "960110038369385",
		"endBalanceGwei": "960535030319235",
		"depositsSumGwei": "0",
		"consensusRewardsGwei": "424991949850",
		"txFeesSumWei": "0",
		"totalRewardsWei": "424991949850000000000"
	}
]

# use pre-built docker-image and write into json-file
docker run --network=host gobitfly/eth.store:latest -cons.address="http://some-consensus-node:4000" -exec.address="http://some-execution-node:8545" -days="613" -json.file="./ethstore.json"
day: 613 (2022-08-06 12:00:23 +0000 UTC), epochs: 137925-138149, validators: 412063, apr: 0.044632337, effectiveBalanceSumGwei: 13185905000000000, totalRewardsSumWei: 1612377406889000000000, consensusRewardsGwei: 1612377406889 (100%), txFeesSumWei: 0
cat ./etsthore.json
[
	{
		"day": "613",
		"dayTime": "2022-08-06T12:00:23Z",
		"apr": "0.0446323368410803",
		"validators": "412063",
		"startEpoch": "137925",
		"effectiveBalanceGwei": "13185905000000000",
		"startBalanceGwei": "13899169115750451",
		"endBalanceGwei": "13900781493157340",
		"depositsSumGwei": "0",
		"consensusRewardsGwei": "1612377406889",
		"txFeesSumWei": "0",
		"totalRewardsWei": "1612377406889000000000"
	}
]

Documentation

Index

Constants

View Source
const RECEIPTS_MODE_BATCH = 0
View Source
const RECEIPTS_MODE_SINGLE = 1

Variables

This section is empty.

Functions

func GetConsTimeout

func GetConsTimeout() time.Duration

func GetDebugLevel

func GetDebugLevel() uint64

func GetDomain

func GetDomain() string

func GetExecTimeout

func GetExecTimeout() time.Duration

func GetFinalizedDay

func GetFinalizedDay(ctx context.Context, address string) (uint64, error)

func GetHeadDay

func GetHeadDay(ctx context.Context, address string) (uint64, error)

func GetValidators

func GetValidators(ctx context.Context, client *ethHttp.Service, stateID string) (map[phase0.ValidatorIndex]*v1.Validator, error)

func SetBeaconchainApiKey

func SetBeaconchainApiKey(apiKey string)

func SetConsTimeout

func SetConsTimeout(dur time.Duration)

func SetDebugLevel

func SetDebugLevel(lvl uint64)

func SetDomain

func SetDomain(domain string)

func SetExecTimeout

func SetExecTimeout(dur time.Duration)

Types

type BeaconchainApiClient

type BeaconchainApiClient struct {
	// contains filtered or unexported fields
}

func NewBeaconchainApiClient

func NewBeaconchainApiClient() *BeaconchainApiClient

func (*BeaconchainApiClient) ConsolidationRequests

func (c *BeaconchainApiClient) ConsolidationRequests(ctx context.Context, network string, slot uint64) (*BeaconchainConsolidationRequestsResponse, error)

func (*BeaconchainApiClient) DepositRequests

func (c *BeaconchainApiClient) DepositRequests(ctx context.Context, network string, slot uint64) (*BeaconchainDepositRequestsResponse, error)

func (*BeaconchainApiClient) GetApiKey

func (c *BeaconchainApiClient) GetApiKey() string

func (*BeaconchainApiClient) GetDomain

func (c *BeaconchainApiClient) GetDomain() string

func (*BeaconchainApiClient) HttpReq

func (c *BeaconchainApiClient) HttpReq(ctx context.Context, method, url string, headers map[string]string, params, result interface{}) error

func (*BeaconchainApiClient) SetApiKey

func (c *BeaconchainApiClient) SetApiKey(apiKey string)

func (*BeaconchainApiClient) SetDomain

func (c *BeaconchainApiClient) SetDomain(domain string)

type BeaconchainConsolidationRequest

type BeaconchainConsolidationRequest struct {
	AmountConsolidated int64  `json:"amount_consolidated"`
	BlockRoot          string `json:"block_root"`
	BlockSlot          uint64 `json:"block_slot"`
	RequestIndex       uint64 `json:"request_index"`
	SourceIndex        uint64 `json:"source_index"`
	TargetIndex        uint64 `json:"target_index"`
}

type BeaconchainConsolidationRequestsResponse

type BeaconchainConsolidationRequestsResponse struct {
	Status string                            `json:"status"`
	Data   []BeaconchainConsolidationRequest `json:"data"`
}

type BeaconchainDepositRequest

type BeaconchainDepositRequest struct {
	Amount                int64  `json:"amount"`
	BlockRoot             string `json:"block_root"`
	BlockSlot             uint64 `json:"block_slot"`
	Pubkey                string `json:"pubkey"`
	RequestIndex          uint64 `json:"request_index"`
	Signature             string `json:"signature"`
	WithdrawalCredentials string `json:"withdrawal_credentials"`
}

type BeaconchainDepositRequestsResponse

type BeaconchainDepositRequestsResponse struct {
	Status string                      `json:"status"`
	Data   []BeaconchainDepositRequest `json:"data"`
}

type BlockData

type BlockData struct {
	Version       spec.DataVersion
	ProposerIndex phase0.ValidatorIndex
	Transactions  []bellatrix.Transaction
	BaseFeePerGas *big.Int
	Deposits      []*phase0.Deposit
	GasUsed       uint64
	GasLimit      uint64
	Withdrawals   []*capella.Withdrawal
	BlockNumber   uint64
}

func GetBlockData

func GetBlockData(block *spec.VersionedSignedBeaconBlock) (*BlockData, error)

type Day

type Day struct {
	Day                  decimal.Decimal `json:"day"`
	DayTime              time.Time       `json:"dayTime"`
	Apr                  decimal.Decimal `json:"apr"`
	Validators           decimal.Decimal `json:"validators"`
	StartEpoch           decimal.Decimal `json:"startEpoch"`
	EffectiveBalanceGwei decimal.Decimal `json:"effectiveBalanceGwei"`
	StartBalanceGwei     decimal.Decimal `json:"startBalanceGwei"`
	EndBalanceGwei       decimal.Decimal `json:"endBalanceGwei"`
	DepositsSumGwei      decimal.Decimal `json:"depositsSumGwei"`
	WithdrawalsSumGwei   decimal.Decimal `json:"withdrawalsSumGwei"`
	ConsensusRewardsGwei decimal.Decimal `json:"consensusRewardsGwei"`
	TxFeesSumWei         decimal.Decimal `json:"txFeesSumWei"`
	TotalRewardsWei      decimal.Decimal `json:"totalRewardsWei"`
}

func Calculate

func Calculate(ctx context.Context, bnAddress, elAddress, dayStr string, concurrency int, receiptsMode int) (*Day, map[uint64]*Day, error)

type HttpReqError

type HttpReqError struct {
	StatusCode int
	Url        string
	Body       []byte
	JSONError  error
	HTTPError  error
}

func (HttpReqError) Error

func (e HttpReqError) Error() string

type Ratelimiter

type Ratelimiter struct {
	// contains filtered or unexported fields
}

func NewRatelimiter

func NewRatelimiter(reqPerSec float64) *Ratelimiter

func (*Ratelimiter) GetRate

func (rl *Ratelimiter) GetRate() float64

func (*Ratelimiter) SetRate

func (rl *Ratelimiter) SetRate(reqPerSec float64)

func (*Ratelimiter) Wait

func (rl *Ratelimiter) Wait()

type TxReceipt

type TxReceipt struct {
	BlockHash         *common.Hash    `json:"blockHash"`
	BlockNumber       *hexutil.Big    `json:"blockNumber"`
	ContractAddress   *common.Address `json:"contractAddress,omitempty"`
	CumulativeGasUsed hexutil.Uint64  `json:"cumulativeGasUsed"`
	EffectiveGasPrice *hexutil.Big    `json:"effectiveGasPrice"`
	From              *common.Address `json:"from,omitempty"`
	GasUsed           hexutil.Uint64  `json:"gasUsed"`
	LogsBloom         hexutil.Bytes   `json:"logsBloom"`
	Status            hexutil.Uint64  `json:"status"`
	To                *common.Address `json:"to,omitempty"`
	TransactionHash   *common.Hash    `json:"transactionHash"`
	TransactionIndex  hexutil.Uint64  `json:"transactionIndex"`
	Type              hexutil.Uint64  `json:"type"`
}

type Validator

type Validator struct {
	Index                phase0.ValidatorIndex
	Pubkey               phase0.BLSPubKey
	EffectiveBalanceGwei phase0.Gwei
	StartBalanceGwei     phase0.Gwei
	EndBalanceGwei       phase0.Gwei
	DepositsSumGwei      phase0.Gwei
	WithdrawalsSumGwei   phase0.Gwei
	TxFeesSumWei         *big.Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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