Skip to content

Commit

Permalink
Fix price/balance submission check
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfornax committed Oct 17, 2024
1 parent b9a33b8 commit 9f5fc29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 0 additions & 5 deletions rocketpool/watchtower/submit-rpl-price.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,6 @@ func (t *submitRplPrice) run(state *state.NetworkState) error {
}
targetBlockNumber := targetBlockHeader.Number.Uint64()

if targetBlockNumber > state.ElBlockNumber {
// No submission needed: target block in the future
return nil
}

// Check if the process is already running
t.lock.Lock()
if t.isRunning {
Expand Down
11 changes: 11 additions & 0 deletions rocketpool/watchtower/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,23 @@ func FindLastBlockWithExecutionPayload(bc beacon.Client, slotNumber uint64) (bea
}

func FindNextSubmissionTarget(rp *rocketpool.RocketPool, eth2Config beacon.Eth2Config, bc beacon.Client, ec rocketpool.ExecutionClient, lastSubmissionBlock uint64, referenceTimestamp int64, submissionIntervalInSeconds int64) (uint64, time.Time, *types.Header, error) {
// Get the time of the last submission
lastSubmissionBlockHeader, err := rp.Client.HeaderByNumber(context.Background(), big.NewInt(int64(lastSubmissionBlock)))
if err != nil {
return 0, time.Time{}, nil, fmt.Errorf("can't get the latest submission block header: %w", err)
}

// Get the time of the latest block
latestEth1Block, err := rp.Client.HeaderByNumber(context.Background(), nil)
if err != nil {
return 0, time.Time{}, nil, fmt.Errorf("can't get the latest block time: %w", err)
}
latestBlockTimestamp := int64(latestEth1Block.Time)

if int64(lastSubmissionBlockHeader.Time)+submissionIntervalInSeconds > latestBlockTimestamp {
return 0, time.Time{}, nil, fmt.Errorf("not enough time has passed for the next price/balances submission")
}

// Calculate the next submission timestamp
submissionTimestamp, err := FindNextSubmissionTimestamp(latestBlockTimestamp, referenceTimestamp, submissionIntervalInSeconds)
if err != nil {
Expand Down

0 comments on commit 9f5fc29

Please sign in to comment.