Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core/types): remove Blocks's Timestamp() method #1429

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

qdm12
Copy link
Collaborator

@qdm12 qdm12 commented Jan 22, 2025

Why this should be merged

See ava-labs/coreth#749

How this works

See commit messages, but TLDR:

  • change easy-to-change Timestamp calls to Time calls
  • change arguments from blockContext -> blockNumber + blockTime
  • New PrecompileBlockContext implementing a now changed BlockContext interface (Timestamp -> Time)

How this was tested

Existing CI passing

Need to be documented?

Maybe? The template changed 🤔

Need to update RELEASES.md?

@qdm12 qdm12 force-pushed the qdm12/block-remove-timestamp branch 2 times, most recently from 1926d99 to 1bc820a Compare January 23, 2025 08:36
@qdm12 qdm12 force-pushed the qdm12/block-remove-timestamp branch from 1bc820a to 2cf8ef3 Compare January 23, 2025 08:38
@qdm12 qdm12 marked this pull request as ready for review January 23, 2025 08:38
@qdm12 qdm12 requested review from ceyonur, darioush and a team as code owners January 23, 2025 08:38
@@ -43,10 +44,10 @@ func (*configurator) MakeConfig() precompileconfig.Config {

// Configure configures [state] with the given [cfg] precompileconfig.
// This function is called by the EVM once per precompile contract activation.
func (c *configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockContext contract.ConfigurationBlockContext) error {
func (c *configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we keep both the block number and time here even if the time is unused? As we previously exposed this interface in precompile-evm and it seems it could be used in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, one of the last commits removes the time argument, I wanted to see your opinion on this 😉

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, similar question: what would be the cost to change the function signature in the future?

@@ -21,8 +21,8 @@ type AllowListConfig struct {
}

// Configure initializes the address space of [precompileAddr] by initializing the role of each of
// the addresses in [AllowListAdmins].
func (c *AllowListConfig) Configure(chainConfig precompileconfig.ChainConfig, precompileAddr common.Address, state contract.StateDB, blockContext contract.ConfigurationBlockContext) error {
// the addresses in [AllowListConfig].
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we keep the arguments for this method for symmetry with the other methods (even though unused)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure I understand what symmetry you are thinking about? With the Configurator.Configure??

Copy link
Collaborator

Choose a reason for hiding this comment

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

That was my thought, even though the AllowList is not a precompile it follows through the phases of Configure along with the precompile.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Related question: what would be the cost of changing the signature of AllowListConfig.Configure if needed in the future? 🤔

@qdm12 qdm12 force-pushed the qdm12/block-remove-timestamp branch from 2cf8ef3 to a9b334c Compare January 23, 2025 16:54
@qdm12 qdm12 force-pushed the qdm12/block-remove-timestamp branch from 29c0766 to d590a04 Compare January 24, 2025 09:41
@qdm12 qdm12 requested a review from darioush January 24, 2025 09:42
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.

2 participants