Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
7 changes: 4 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ on:
push:
branches:
- 'main'
workflow_dispatch:

jobs:
buildx:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
-
name: Prepare
id: prep
Expand All @@ -33,7 +34,7 @@ jobs:
uses: docker/setup-buildx-action@v1
-
name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
Expand All @@ -49,7 +50,7 @@ jobs:
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: "."
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18-alpine AS build
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.23-alpine AS build
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG VERSION
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GITDATE=$$(TZ=UTC git show -s --date=iso-strict-local --format=%cd HEAD | sed 's
BUILDDATE=`date -u +"%Y%m%d%H%M%S"`
LDFLAGS="-X ${GITURL}/version.GitCommit=${GITCOMMIT} -X ${GITURL}/version.GitDate=${GITDATE} -X ${GITURL}/version.Version=${GITDATE}-${GITCOMMIT}"
BINARY=bin/eth.store
all: test build
all: build
test:
go test -v ./...
clean:
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
![image](https://user-images.githubusercontent.com/26490734/174131682-598758e0-1b5d-4b8d-8995-26cab3f65f22.png)
![ethstore](https://user-images.githubusercontent.com/26490734/235898840-ffba747a-69ac-4750-8517-c0b3ffcb8459.png)

*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.

Expand Down
44 changes: 26 additions & 18 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"sort"
Expand All @@ -20,16 +19,18 @@ import (
)

var opts struct {
Days string
Validators string
ConsAddress string
ConsTimeout time.Duration
ExecAddress string
ExecTimeout time.Duration
Json bool
JsonFile string
DebugLevel uint64
Version bool
Days string
Validators string
ConsAddress string
ConsTimeout time.Duration
ExecAddress string
ExecTimeout time.Duration
Json bool
JsonFile string
DebugLevel uint64
Version bool
ReceiptsMode int
BeaconchainApikey string
}

func main() {
Expand All @@ -42,16 +43,23 @@ func main() {
flag.StringVar(&opts.JsonFile, "json.file", "", "path to file to write results into, only missing days will be added")
flag.Uint64Var(&opts.DebugLevel, "debug", 0, "set debug-level (higher level will increase verbosity)")
flag.BoolVar(&opts.Version, "version", false, "print version and exit")
flag.IntVar(&opts.ReceiptsMode, "receipts-mode", 0, "mode to use for fetching tx receipts, 0 = eth_getTransactionReceipt, 1 = eth_getBlockReceipts")
flag.StringVar(&opts.BeaconchainApikey, "beaconchain.apikey", "", "beaconchain apikey to use")
flag.Parse()

if opts.Version {
fmt.Println(version.Version)
return
}

if opts.ReceiptsMode != 0 && opts.ReceiptsMode != 1 {
log.Fatalf("invalid receipts mode provided, can only be 0 or 1")
}

ethstore.SetConsTimeout(opts.ConsTimeout)
ethstore.SetExecTimeout(opts.ExecTimeout)
ethstore.SetDebugLevel(opts.DebugLevel)
ethstore.SetBeaconchainApiKey(opts.BeaconchainApikey)

days := []uint64{}

Expand All @@ -69,13 +77,13 @@ func main() {
if daysSplit[1] == "finalized" {
d, err := ethstore.GetFinalizedDay(context.Background(), opts.ConsAddress)
if err != nil {
log.Fatalf("error getting lattest day: %v", err)
log.Fatalf("error getting finalized day: %v", err)
}
toDay = d
} else if daysSplit[1] == "head" {
d, err := ethstore.GetHeadDay(context.Background(), opts.ConsAddress)
if err != nil {
log.Fatalf("error getting lattest day: %v", err)
log.Fatalf("error getting head day: %v", err)
}
toDay = d
} else {
Expand Down Expand Up @@ -124,7 +132,7 @@ func main() {
fileDays := []*ethstore.Day{}
_, err := os.Stat(opts.JsonFile)
if err == nil {
fileDaysBytes, err := ioutil.ReadFile(opts.JsonFile)
fileDaysBytes, err := os.ReadFile(opts.JsonFile)
if err != nil {
log.Fatalf("error reading file: %v", err)
}
Expand All @@ -145,7 +153,7 @@ func main() {
logEthstoreDay(d)
continue
}
d, _, err := ethstore.Calculate(context.Background(), opts.ConsAddress, opts.ExecAddress, fmt.Sprintf("%d", dd), 10)
d, _, err := ethstore.Calculate(context.Background(), opts.ConsAddress, opts.ExecAddress, fmt.Sprintf("%d", dd), 10, opts.ReceiptsMode)
if err != nil {
log.Fatalf("error calculating ethstore: %v", err)
}
Expand All @@ -157,7 +165,7 @@ func main() {
if err != nil {
log.Fatalf("error marshaling ethstore: %v", err)
}
err = ioutil.WriteFile(opts.JsonFile, fileDaysJson, 0644)
err = os.WriteFile(opts.JsonFile, fileDaysJson, 0644)
if err != nil {
log.Fatalf("error writing ethstore to file: %v", err)
}
Expand All @@ -168,7 +176,7 @@ func main() {
} else {
result := []*ethstore.Day{}
for _, dd := range days {
d, _, err := ethstore.Calculate(context.Background(), opts.ConsAddress, opts.ExecAddress, fmt.Sprintf("%d", dd), 10)
d, _, err := ethstore.Calculate(context.Background(), opts.ConsAddress, opts.ExecAddress, fmt.Sprintf("%d", dd), 10, opts.ReceiptsMode)
if err != nil {
log.Fatalf("error calculating ethstore: %v", err)
}
Expand All @@ -188,5 +196,5 @@ func main() {
}

func logEthstoreDay(d *ethstore.Day) {
fmt.Printf("day: %v (%v), epochs: %v-%v, validators: %v, apr: %v, effectiveBalanceSumGwei: %v, totalRewardsSumWei: %v, consensusRewardsGwei: %v (%s%%), txFeesSumWei: %v\n", d.Day, d.DayTime, d.StartEpoch, d.StartEpoch.Add(decimal.New(224, 0)), d.Validators, d.Apr.StringFixed(9), d.EffectiveBalanceGwei, d.TotalRewardsWei, d.ConsensusRewardsGwei, d.ConsensusRewardsGwei.Mul(decimal.NewFromInt(1e9*1e2)).Div(d.TotalRewardsWei).StringFixed(2), d.TxFeesSumWei)
fmt.Printf("day: %v (%v), epochs: %v-%v, validators: %v, apr: %v, effectiveBalanceSumGwei: %v, totalRewardsSumWei: %v, consensusRewardsGwei: %v (%s%%), txFeesSumWei: %v\n", d.Day, d.DayTime, d.StartEpoch, d.StartEpoch.Add(decimal.New(224, 0)), d.Validators, d.Apr.StringFixed(9), d.EffectiveBalanceGwei, d.TotalRewardsWei, d.ConsensusRewardsGwei, d.ConsensusRewardsGwei.Abs().Mul(decimal.NewFromInt(1e9*1e2)).Div(d.TotalRewardsWei.Abs()).StringFixed(2), d.TxFeesSumWei)
}
Loading
Loading