-
Notifications
You must be signed in to change notification settings - Fork 241
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
base: master
Are you sure you want to change the base?
Conversation
1926d99
to
1bc820a
Compare
…Number` + `blockTime`
…ber` + `blockTime`
…blockNumber` + `blockTime`
1bc820a
to
2cf8ef3
Compare
@@ -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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😉
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would require changes to all precompiles, both those that we have developed and any external code bases that may have developed precompiles for use in subnet-evm or precompile-evm.
So I think we should avoid changing it without good reason, but we can still change it to deliver improvements, features, and a better interface.
It seems the code that sets up a precompile may want to have access to both the timestamp and the number of the block where it's activated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, should we then not change the signature, such that the block context interface (now removed) can be later extended?
@@ -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]. |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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
??
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less than the other method, as the AllowList is not part of the precompile interface but more a partial implementation that's used by some of the precompiles.
As I mentioned I have a subjective preference for methods that do similar things to all take the same arguments but this is not a strong preference.
2cf8ef3
to
a9b334c
Compare
29c0766
to
d590a04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes in the subnet-evm context are lgtm, but we should consider that this will break all precompiles (including precompiles in precompile-evm + subnet-evm forks)
@@ -59,7 +60,7 @@ func (*configurator) MakeConfig() precompileconfig.Config { | |||
// This function is called by the EVM once per precompile contract activation. | |||
// You can use this function to set up your precompile contract's initial state, | |||
// by using the [cfg] config and [state] stateDB. | |||
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockContext contract.ConfigurationBlockContext) error { | |||
func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg precompileconfig.Config, state contract.StateDB, blockNumber *big.Int, blockTime uint64) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a breaking change to all precompiles (external and internal precompiles). While having a simple params is better, we should also evaluate this with the future extension possibilities. IMO having a blockContext interface is less cumbersome to extend.
Why this should be merged
See ava-labs/coreth#749
How this works
See commit messages, but TLDR:
blockContext
->blockNumber
+blockTime
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?