Skip to content

Commit

Permalink
Merge pull request #12 from migalabs/feat/add-fetch-transactions-flag
Browse files Browse the repository at this point in the history
Feat/add fetch transactions flag
  • Loading branch information
santi1234567 authored Feb 22, 2024
2 parents 449ee69 + 92692d9 commit a40372a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ OPTIONS:
--log-level value Log level: debug, warn, info, error (default: info) [$LOG_LEVEL]
--workers-num value Number of workers to process API requests (default: 10) [$WORKER_NUM]
--alchemy-url value Alchemy url (default: https://eth-mainnet.g.alchemy.com/v2/KEY) [$ALCHEMY_URL]
--only-deposits Only fetch deposits. If not set, it will fetch all new depositor transactions which can take up to 20 hours (default: false)
--help, -h show help
```

Expand Down Expand Up @@ -187,7 +188,7 @@ Utilizing Alchemy as EL node and API, with a local database, these are the bench
- Total time: 4h 51m
- Total time for the first run: 21h 29m

If running the tool on a weekly basis, expect the tool to take around 16h to run considering that the process of fetching depositors transactions will be done on every run.
If running the tool on a weekly basis, expect the tool to take around 16h to run considering that the process of fetching depositors transactions will be done on every run unless the `--only-deposits` flag is set, in which case the tool will take around 10m to run.

The size of the fully synced database is around 3GB.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (b *BeaconDepositorsTransactions) Run() {
log.Infof("Finished downloading new beacon deposits in %f seconds", duration)

}
if !b.stop {
if !b.stop && !b.iConfig.OnlyDeposits {
initTime := time.Now()
log.Info("Updating depositors transactions...")
b.updateDepositorsTransactions()
Expand Down
4 changes: 4 additions & 0 deletions cmd/beacon-depositors-transactions/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ var BeaconDepositorsTransactionsCommand = &cli.Command{
EnvVars: []string{"ALCHEMY_URL"},
DefaultText: "https://eth-mainnet.g.alchemy.com/v2/KEY",
},
&cli.BoolFlag{
Name: "only-deposits",
Usage: "Only fetch deposits. If not set, it will fetch all new depositor transactions which can take up to 20 hours",
},
},
}

Expand Down
15 changes: 10 additions & 5 deletions config/beacon_depositors_transactions_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
)

type BeaconDepositorsTransactionsConfig struct {
LogLevel string `json:"log-level"`
ElEndpoint string `json:"el-endpoint"`
DBUrl string `json:"db-url"`
Workers int `json:"workers-num"`
AlchemyURL string `json:"alchemy-url"`
LogLevel string `json:"log-level"`
ElEndpoint string `json:"el-endpoint"`
DBUrl string `json:"db-url"`
Workers int `json:"workers-num"`
AlchemyURL string `json:"alchemy-url"`
OnlyDeposits bool `json:"only-deposits"`
}

func NewBeaconDepositorsTransactionsConfig() *BeaconDepositorsTransactionsConfig {
Expand Down Expand Up @@ -43,4 +44,8 @@ func (c *BeaconDepositorsTransactionsConfig) Apply(ctx *cli.Context) {
c.AlchemyURL = ctx.String("alchemy-url")
}

if ctx.IsSet("only-deposits") {
c.OnlyDeposits = true
}

}

0 comments on commit a40372a

Please sign in to comment.