Skip to content

Conversation

@StephenButtolph
Copy link
Contributor

@StephenButtolph StephenButtolph commented Sep 16, 2025

Was thinking about how best to convey what I expected to happen here and realized it would be easiest to just make a PR.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a TODO comment in the LastToSettleAt function by implementing more fine-grained execution time checks. The implementation now tracks when execution is behind the settlement time and uses this information to provide more accurate results.

  • Removes coarse-grained implementation that returned false negatives
  • Adds execution timing tracking with executionIsBehind flag
  • Updates test expectations to reflect improved accuracy

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
blocks/settlement.go Implements fine-grained execution time checking with executionIsBehind tracking
blocks/settlement_test.go Updates test case to expect accurate results instead of false negatives

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

continue
}
return block, true
return block, !executionIsBehind
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for returning !executionIsBehind appears incorrect. When execution data is available (e != nil) and execution time is within the settlement window (e.byGas.CompareUnix(settleAt) <= 0), the block should be valid regardless of the executionIsBehind flag state. The executionIsBehind flag tracks whether we've encountered blocks that can't execute in time, but if we have actual execution data showing completion within the window, that should always return true.

Suggested change
return block, !executionIsBehind
return block, true

Copilot uses AI. Check for mistakes.
var executionIsBehind bool
for block := parent; ; block = block.ParentBlock() {
if startsNoEarlierThan := block.BuildTime(); startsNoEarlierThan > settleAt {
executionIsBehind = false
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting executionIsBehind = false when startsNoEarlierThan > settleAt is incorrect logic. If a block's build time is after the settlement time, it indicates the block cannot execute before settlement, which should set executionIsBehind = true, not false.

Suggested change
executionIsBehind = false
executionIsBehind = true

Copilot uses AI. Check for mistakes.
@ARR4N ARR4N changed the title Address TODO in LastToSettleAt feat: LastToSettleAt() supports unknown grandchild execution time Sep 17, 2025
Copy link
Collaborator

@ARR4N ARR4N left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you. I pushed a slight refactoring and updated the PR title to reflect what's happening.

@ARR4N ARR4N merged commit abfc7f3 into arr4n/blocks Sep 17, 2025
@ARR4N ARR4N deleted the StephenButtolph/blocks-todo branch September 17, 2025 07:00
@ARR4N ARR4N mentioned this pull request Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants