Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
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.21-alpine AS build
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG VERSION
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
35 changes: 20 additions & 15 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,17 @@ 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
}

func main() {
Expand All @@ -42,13 +42,18 @@ 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.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)
Expand Down Expand Up @@ -124,7 +129,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 +150,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 +162,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 +173,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 Down
Loading