Skip to content

Commit

Permalink
Merge pull request #680 from rocket-pool/fix-submission-check
Browse files Browse the repository at this point in the history
Fix price/balance submission check
  • Loading branch information
0xfornax authored Oct 19, 2024
2 parents e060afb + 9f5fc29 commit 4e9ee2e
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 4e9ee2e

Please sign in to comment.