-
Notifications
You must be signed in to change notification settings - Fork 276
Generalized upgrades #426
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
Generalized upgrades #426
Conversation
Co-authored-by: aaronbuchwald <[email protected]>
Co-authored-by: aaronbuchwald <[email protected]>
Co-authored-by: aaronbuchwald <[email protected]>
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 really like some of the simplifications this change affords.
- Could we make any improvements to the unmarshalling situation?
- Could we avoid making the module type by having RegisterModule take Key, Address, and Contract for example?
// IsPrecompileEnabled returns whether precompile with [address] is enabled at [blockTimestamp]. | ||
func (c *ChainConfig) IsPrecompileEnabled(address common.Address, blockTimestamp *big.Int) bool { | ||
config := c.GetPrecompileConfig(address, blockTimestamp) | ||
func (c *ChainConfig) IsPrecompileEnabled(name string, blockTimestamp *big.Int) bool { |
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 update the comment to match?
Also should we call this key or rename module.Key()
-> module.Name()
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.
Initially I named it as Name
but then it sounds a bit like human-readable name such as TxAllowList
. but instead this serves as a json map key as txAllowList
and IMO Key
fits better.
return err | ||
} | ||
if len(raw) != 1 { | ||
return fmt.Errorf("PrecompileUpgrade must have exactly one key") |
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.
nit: errors.New
if no formatting is included in the error
return configs[len(configs)-1] // return the most recent config | ||
} | ||
|
||
// getActivatingPrecompileConfigs returns all forks configured to activate during the state transition from a block with timestamp [from] |
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.
// getActivatingPrecompileConfigs returns all forks configured to activate during the state transition from a block with timestamp [from] | |
// getActivatingPrecompileConfigs returns all upgrades configured to activate during the state transition from a block with timestamp [from] |
if val := c.getActivePrecompileConfig(key, blockTimestamp); val != nil { | ||
return val | ||
} | ||
return nil |
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 return c.getActivePrecompileConfig(key, blockTimestamp)
?
PrecompileUpgrades: []params.PrecompileUpgrade{ | ||
{ | ||
TxAllowListConfig: txallowlist.NewTxAllowListConfig(big.NewInt(enableAllowListTimestamp.Unix()), testEthAddrs[0:1], nil), | ||
Config: txallowlist.NewTxAllowListConfig(big.NewInt(enableAllowListTimestamp.Unix()), testEthAddrs[0:1], nil), |
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.
nit: should we remove Config:
for consistency?
return err | ||
} | ||
return nil | ||
} |
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.
can we add a comment that explains this pattern?
New() StatefulPrecompileConfig | ||
} | ||
|
||
// StatefulPrecompileConfig defines the interface for a stateful precompile to |
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 complete the sentence? seems it was left half way before
Closing in favor of #434 |
Why this should be merged
How this works
How this was tested