Skip to content

Conversation

ceyonur
Copy link
Collaborator

@ceyonur ceyonur commented Jan 5, 2023

Why this should be merged

How this works

How this was tested

@ceyonur ceyonur changed the base branch from master to precompile-specific-packages January 5, 2023 14:23
Copy link

@darioush darioush left a 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 {
Copy link

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()

Copy link
Collaborator Author

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")
Copy link

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]
Copy link

Choose a reason for hiding this comment

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

Suggested change
// 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
Copy link

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),
Copy link

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
}
Copy link

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
Copy link

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

Base automatically changed from precompile-specific-packages to precompile-improvements-main January 6, 2023 09:29
@ceyonur
Copy link
Collaborator Author

ceyonur commented Jan 12, 2023

Closing in favor of #434

@ceyonur ceyonur closed this Jan 12, 2023
@ceyonur ceyonur deleted the generalized-upgrades branch February 22, 2023 14:15
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