-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get latest updates from upstream and solve conflicts
- Loading branch information
Showing
70 changed files
with
1,761 additions
and
1,025 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Phone (please complete the following information):** | ||
- OS: [e.g. iOS 14.5] | ||
- App Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package main | ||
|
||
import ( | ||
"eth2-exporter/db" | ||
"eth2-exporter/rpc" | ||
"eth2-exporter/types" | ||
"eth2-exporter/utils" | ||
"eth2-exporter/version" | ||
"flag" | ||
"fmt" | ||
"math/big" | ||
"time" | ||
|
||
geth_rpc "github.com/ethereum/go-ethereum/rpc" | ||
|
||
eth_rewards "github.com/gobitfly/eth-rewards" | ||
"github.com/prysmaticlabs/prysm/v3/api/client/beacon" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func main() { | ||
|
||
configPath := flag.String("config", "", "Path to the config file, if empty string defaults will be used") | ||
bnAddress := flag.String("beacon-node-address", "", "Url of the beacon node api") | ||
enAddress := flag.String("execution-node-address", "", "Url of the execution node api") | ||
epoch := flag.Int64("epoch", -1, "epoch to export (use -1 to export latest finalized epoch)") | ||
network := flag.String("network", "", "Config to use (can be mainnet, prater or sepolia") | ||
|
||
flag.Parse() | ||
|
||
cfg := &types.Config{} | ||
err := utils.ReadConfig(cfg, *configPath) | ||
if err != nil { | ||
logrus.Fatalf("error reading config file: %v", err) | ||
} | ||
utils.Config = cfg | ||
logrus.WithField("config", *configPath).WithField("version", version.Version).WithField("chainName", utils.Config.Chain.Config.ConfigName).Printf("starting") | ||
|
||
client, err := beacon.NewClient(*bnAddress) | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
|
||
lc, err := rpc.NewLighthouseClient(*bnAddress, big.NewInt(5)) | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
|
||
elClient, err := geth_rpc.Dial(*enAddress) | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
|
||
bt, err := db.InitBigtable(utils.Config.Bigtable.Project, utils.Config.Bigtable.Instance, fmt.Sprintf("%d", utils.Config.Chain.Config.DepositChainID)) | ||
if err != nil { | ||
logrus.Fatalf("error connecting to bigtable: %v", err) | ||
} | ||
defer bt.Close() | ||
|
||
if *epoch == -1 { | ||
for { | ||
head, err := lc.GetChainHead() | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
if int64(head.FinalizedEpoch) <= *epoch { | ||
time.Sleep(time.Second * 12) | ||
continue | ||
} | ||
|
||
*epoch = int64(head.FinalizedEpoch) | ||
|
||
start := time.Now() | ||
logrus.Infof("retrieving rewards details for epoch %v", *epoch) | ||
|
||
rewards, err := eth_rewards.GetRewardsForEpoch(int(*epoch), client, elClient, *network) | ||
|
||
if err != nil { | ||
logrus.Fatalf("error retrieving reward details for epoch %v: %v", *epoch, err) | ||
} else { | ||
logrus.Infof("retrieved %v reward details for epoch %v in %v", len(rewards), *epoch, time.Since(start)) | ||
} | ||
|
||
err = bt.SaveValidatorIncomeDetails(uint64(*epoch), rewards) | ||
if err != nil { | ||
logrus.Fatalf("error saving reward details to bigtable: %v", err) | ||
} | ||
} | ||
} | ||
|
||
start := time.Now() | ||
logrus.Infof("retrieving rewards details for epoch %v", *epoch) | ||
|
||
rewards, err := eth_rewards.GetRewardsForEpoch(int(*epoch), client, elClient, *network) | ||
|
||
if err != nil { | ||
logrus.Fatalf("error retrieving reward details for epoch %v: %v", *epoch, err) | ||
} else { | ||
logrus.Infof("retrieved %v reward details for epoch %v in %v", len(rewards), *epoch, time.Since(start)) | ||
} | ||
|
||
err = bt.SaveValidatorIncomeDetails(uint64(*epoch), rewards) | ||
if err != nil { | ||
logrus.Fatalf("error saving reward details to bigtable: %v", err) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.