Skip to content

Conversation

@StephenButtolph
Copy link
Contributor

ACP176 expects the gas target to be updated immediately after the execution of the block. However, the prior code updates the target prior to executing the next block.

clock.FastForwardTo(
b.BuildTime(),
pts.SubSecondBlockTime(b.Header()),
b.Time(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I want to differentiate between the different times, much like how we do with state roots. Granted in this case it couldn't be execution (gas nor wall) time, but more generally I want to be more precise in this code base. Happy to change BuildTime() to something else if you'd like, but I'd prefer to not use raw Time() (which should probably be removed).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BuildTime doesn't exist on the provided type. The function is passing in types.Block, not blocks.Block. Are you suggesting to revert the change and take in blocks.Block again?

hook/hook.go Outdated
Comment on lines 25 to 27
// GasTarget returns the amount of gas per second that the chain should
// target to consume after executing the provided block.
GasTarget(*types.Header) gas.Gas
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// GasTarget returns the amount of gas per second that the chain should
// target to consume after executing the provided block.
GasTarget(*types.Header) gas.Gas
// GasTargetAfter returns the amount of gas per second that the chain should
// target to consume after executing the provided block.
GasTargetAfter(*types.Header) gas.Gas

Also (nit), something about the wording of "to consume after executing the provided block" feels off and it confused me for a split second. Perhaps "target to consume in subsequent blocks."? The current phrasing suggests immediacy, not long-term horizon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reworded it, lmk what you think

assert.Equal(t, initialTarget, tm.Target(), "Target not changed by BeforeBlock()")

enforcedPrice := tm.Price()
assert.LessOrEqual(t, enforcedPrice, initialPrice, "Price should not increase in BeforeBlock()")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should tighten this (and the AfterBlock() equivalent) to remove the equalities. It probably requires an accompanying comment for each, to explain that the strict inequality is synthetic, but it gives us slightly stronger guarantees of directionality in the test.

Base automatically changed from StephenButtolph/simplify-hooks to main December 8, 2025 16:25
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