Skip to content

Commit

Permalink
Port submission fix from v1
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfornax committed Oct 23, 2024
1 parent fda010b commit df89b5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 0 additions & 4 deletions rocketpool-daemon/watchtower/submit-network-balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ func (t *SubmitNetworkBalances) 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()
Expand Down
4 changes: 0 additions & 4 deletions rocketpool-daemon/watchtower/submit-rpl-price.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ func (t *SubmitRplPrice) Run(state *state.NetworkState) error {
submissionTimestamp := uint64(nextSubmissionTime.Unix())

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()
Expand Down
11 changes: 11 additions & 0 deletions rocketpool-daemon/watchtower/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,23 @@ func FindLastBlockWithExecutionPayload(ctx context.Context, bc beacon.IBeaconCli
}

func FindNextSubmissionTarget(ctx context.Context, rp *rocketpool.RocketPool, eth2Config beacon.Eth2Config, bc beacon.IBeaconClient, ec eth.IExecutionClient, 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 df89b5b

Please sign in to comment.