mirror of
https://github.com/luxfi/precompile.git
synced 2026-09-24 00:26:21 +00:00
A precompile's config key names the precompile
Forty-five of the fifty-six suite modules keyed off <name>Config and eleven did not, in three other spellings: Verify, Threshold, Encapsulate. The LP-4200 unified PQCrypto block carried four of those conventions across its eight addresses — two KEMs named differently (mlkemConfig beside hqcEncapsulate) and two threshold schemes named differently (pulsarVerify beside coronaThreshold) — so the block that exists to be one thing did not read as one thing. The deviations also named an OPERATION where a precompile belongs. HQC decapsulates as well as encapsulates and the Verify precompiles do more than verify, so hqcEncapsulate was the name of one entry point standing in for the whole module. A config key selects a precompile; it is not a method selector. All fifty-six are <name>Config now. There is no compatibility shim: an upgrade.json naming an old key is naming something that does not exist, which luxd already refuses loudly, and every chain config in the estate moves with this. Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
+2
-2
@@ -16,7 +16,7 @@ type configurator struct{}
|
||||
func init() {
|
||||
// Register CGGMP21 precompile module
|
||||
if err := modules.RegisterModule(modules.Module{
|
||||
ConfigKey: "cggmp21Verify",
|
||||
ConfigKey: "cggmp21Config",
|
||||
Address: ContractCGGMP21VerifyAddress,
|
||||
Contract: CGGMP21VerifyPrecompile,
|
||||
Configurator: &configurator{},
|
||||
@@ -45,7 +45,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
func (c *Config) Key() string {
|
||||
return "cggmp21Verify"
|
||||
return "cggmp21Config"
|
||||
}
|
||||
|
||||
func (c *Config) Timestamp() *uint64 {
|
||||
|
||||
@@ -26,7 +26,7 @@ func (t *testChainCfg) IsDurango(uint64) bool { return true }
|
||||
|
||||
func TestConfigLifecycle(t *testing.T) {
|
||||
cfg := &Config{}
|
||||
require.Equal(t, "cggmp21Verify", cfg.Key())
|
||||
require.Equal(t, "cggmp21Config", cfg.Key())
|
||||
require.Nil(t, cfg.Timestamp())
|
||||
require.False(t, cfg.IsDisabled())
|
||||
require.NoError(t, cfg.Verify(&testChainCfg{}))
|
||||
@@ -45,7 +45,7 @@ func TestConfigurator(t *testing.T) {
|
||||
c := &configurator{}
|
||||
cfg := c.MakeConfig()
|
||||
require.NotNil(t, cfg)
|
||||
require.Equal(t, "cggmp21Verify", cfg.Key())
|
||||
require.Equal(t, "cggmp21Config", cfg.Key())
|
||||
require.NoError(t, c.Configure(&testChainCfg{}, cfg, nil, nil))
|
||||
}
|
||||
|
||||
@@ -64,14 +64,14 @@ func TestConfigurator(t *testing.T) {
|
||||
func TestModuleRegistration(t *testing.T) {
|
||||
byAddr, ok := modules.GetPrecompileModuleByAddress(ContractCGGMP21VerifyAddress)
|
||||
require.True(t, ok, "the CGGMP21 module must be registered at its address")
|
||||
byKey, ok := modules.GetPrecompileModule("cggmp21Verify")
|
||||
byKey, ok := modules.GetPrecompileModule("cggmp21Config")
|
||||
require.True(t, ok, "the CGGMP21 module must be registered under its config key")
|
||||
require.Equal(t, byAddr, byKey, "address and key must name the same module")
|
||||
require.Equal(t, CGGMP21VerifyPrecompile, byAddr.Contract)
|
||||
require.Equal(t, "cggmp21Verify", byAddr.ConfigKey)
|
||||
require.Equal(t, "cggmp21Config", byAddr.ConfigKey)
|
||||
|
||||
require.Error(t, modules.RegisterModule(modules.Module{
|
||||
ConfigKey: "cggmp21Verify",
|
||||
ConfigKey: "cggmp21Config",
|
||||
Address: common.HexToAddress("0x0800000000000000000000000000000000000043"),
|
||||
Contract: CGGMP21VerifyPrecompile,
|
||||
Configurator: &configurator{},
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ type configurator struct{}
|
||||
func init() {
|
||||
// Register Corona threshold precompile module
|
||||
if err := modules.RegisterModule(modules.Module{
|
||||
ConfigKey: "coronaThreshold",
|
||||
ConfigKey: "coronaConfig",
|
||||
Address: ContractCoronaThresholdAddress,
|
||||
Contract: CoronaThresholdPrecompile,
|
||||
Configurator: &configurator{},
|
||||
@@ -45,7 +45,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
func (c *Config) Key() string {
|
||||
return "coronaThreshold"
|
||||
return "coronaConfig"
|
||||
}
|
||||
|
||||
func (c *Config) Timestamp() *uint64 {
|
||||
|
||||
@@ -24,7 +24,7 @@ func (t *testChainCfg) IsDurango(uint64) bool { return true }
|
||||
|
||||
func TestConfigLifecycle(t *testing.T) {
|
||||
cfg := &Config{}
|
||||
require.Equal(t, "coronaThreshold", cfg.Key())
|
||||
require.Equal(t, "coronaConfig", cfg.Key())
|
||||
require.Nil(t, cfg.Timestamp())
|
||||
require.False(t, cfg.IsDisabled())
|
||||
require.NoError(t, cfg.Verify(&testChainCfg{}))
|
||||
@@ -43,7 +43,7 @@ func TestConfigurator(t *testing.T) {
|
||||
c := &configurator{}
|
||||
cfg := c.MakeConfig()
|
||||
require.NotNil(t, cfg)
|
||||
require.Equal(t, "coronaThreshold", cfg.Key())
|
||||
require.Equal(t, "coronaConfig", cfg.Key())
|
||||
require.NoError(t, c.Configure(&testChainCfg{}, cfg, nil, nil))
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ type configurator struct{}
|
||||
func init() {
|
||||
// Register FROST precompile module
|
||||
if err := modules.RegisterModule(modules.Module{
|
||||
ConfigKey: "frostVerify",
|
||||
ConfigKey: "frostConfig",
|
||||
Address: ContractFROSTVerifyAddress,
|
||||
Contract: FROSTVerifyPrecompile,
|
||||
Configurator: &configurator{},
|
||||
@@ -45,7 +45,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
func (c *Config) Key() string {
|
||||
return "frostVerify"
|
||||
return "frostConfig"
|
||||
}
|
||||
|
||||
func (c *Config) Timestamp() *uint64 {
|
||||
|
||||
@@ -26,7 +26,7 @@ func (t *testChainCfg) IsDurango(uint64) bool { return true }
|
||||
|
||||
func TestConfigLifecycle(t *testing.T) {
|
||||
cfg := &Config{}
|
||||
require.Equal(t, "frostVerify", cfg.Key())
|
||||
require.Equal(t, "frostConfig", cfg.Key())
|
||||
require.Nil(t, cfg.Timestamp())
|
||||
require.False(t, cfg.IsDisabled())
|
||||
require.NoError(t, cfg.Verify(&testChainCfg{}))
|
||||
@@ -45,7 +45,7 @@ func TestConfigurator(t *testing.T) {
|
||||
c := &configurator{}
|
||||
cfg := c.MakeConfig()
|
||||
require.NotNil(t, cfg)
|
||||
require.Equal(t, "frostVerify", cfg.Key())
|
||||
require.Equal(t, "frostConfig", cfg.Key())
|
||||
require.NoError(t, c.Configure(&testChainCfg{}, cfg, nil, nil))
|
||||
}
|
||||
|
||||
@@ -64,14 +64,14 @@ func TestConfigurator(t *testing.T) {
|
||||
func TestModuleRegistration(t *testing.T) {
|
||||
byAddr, ok := modules.GetPrecompileModuleByAddress(ContractFROSTVerifyAddress)
|
||||
require.True(t, ok, "the FROST module must be registered at its address")
|
||||
byKey, ok := modules.GetPrecompileModule("frostVerify")
|
||||
byKey, ok := modules.GetPrecompileModule("frostConfig")
|
||||
require.True(t, ok, "the FROST module must be registered under its config key")
|
||||
require.Equal(t, byAddr, byKey, "address and key must name the same module")
|
||||
require.Equal(t, FROSTVerifyPrecompile, byAddr.Contract)
|
||||
require.Equal(t, "frostVerify", byAddr.ConfigKey)
|
||||
require.Equal(t, "frostConfig", byAddr.ConfigKey)
|
||||
|
||||
require.Error(t, modules.RegisterModule(modules.Module{
|
||||
ConfigKey: "frostVerify",
|
||||
ConfigKey: "frostConfig",
|
||||
Address: common.HexToAddress("0x0800000000000000000000000000000000000042"),
|
||||
Contract: FROSTVerifyPrecompile,
|
||||
Configurator: &configurator{},
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
var _ contract.Configurator = &configurator{}
|
||||
|
||||
const ConfigKey = "hqcEncapsulate"
|
||||
const ConfigKey = "hqcConfig"
|
||||
|
||||
type configurator struct{}
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
var _ contract.Configurator = &configurator{}
|
||||
|
||||
const ConfigKey = "magnetarVerify"
|
||||
const ConfigKey = "magnetarConfig"
|
||||
|
||||
type configurator struct{}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ func (t *testChainCfg) IsDurango(uint64) bool { return true }
|
||||
func TestConfigLifecycle(t *testing.T) {
|
||||
cfg := &Config{}
|
||||
require.Equal(t, ConfigKey, cfg.Key())
|
||||
require.Equal(t, "magnetarVerify", cfg.Key())
|
||||
require.Equal(t, "magnetarConfig", cfg.Key())
|
||||
require.Nil(t, cfg.Timestamp())
|
||||
require.False(t, cfg.IsDisabled())
|
||||
require.NoError(t, cfg.Verify(&testChainCfg{}))
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
var _ contract.Configurator = &configurator{}
|
||||
|
||||
const ConfigKey = "mldsaVerify"
|
||||
const ConfigKey = "mldsaConfig"
|
||||
|
||||
type configurator struct{}
|
||||
|
||||
|
||||
+2
-2
@@ -12,10 +12,10 @@ import (
|
||||
var _ contract.Configurator = &configurator{}
|
||||
|
||||
// ConfigKey is the globally unique JSON config key for this
|
||||
// precompile. Distinct from "pulsarVerify" (slot 0x012204) so a
|
||||
// precompile. Distinct from "pulsarConfig" (slot 0x012204) so a
|
||||
// chain config can independently enable/disable the LP-218 rollup-
|
||||
// commit verifier.
|
||||
const ConfigKey = "p3qVerify"
|
||||
const ConfigKey = "p3qConfig"
|
||||
|
||||
type configurator struct{}
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ func (*chainCfg) IsDurango(uint64) bool { return true }
|
||||
func TestConfigLifecycle(t *testing.T) {
|
||||
cfg := &Config{}
|
||||
require.Equal(t, ConfigKey, cfg.Key())
|
||||
require.Equal(t, "p3qVerify", cfg.Key(),
|
||||
require.Equal(t, "p3qConfig", cfg.Key(),
|
||||
"the config key is chain-config-visible; renaming it silently disables the precompile")
|
||||
require.Nil(t, cfg.Timestamp(), "unset is nil, not zero")
|
||||
require.False(t, cfg.IsDisabled())
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
var _ contract.Configurator = &configurator{}
|
||||
|
||||
const ConfigKey = "pulsarVerify"
|
||||
const ConfigKey = "pulsarConfig"
|
||||
|
||||
type configurator struct{}
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
var _ contract.Configurator = &configurator{}
|
||||
|
||||
const ConfigKey = "slhdsaVerify"
|
||||
const ConfigKey = "slhdsaConfig"
|
||||
|
||||
type configurator struct{}
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
var _ contract.Configurator = &configurator{}
|
||||
|
||||
const ConfigKey = "sr25519Verify"
|
||||
const ConfigKey = "sr25519Config"
|
||||
|
||||
type configurator struct{}
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ func TestParity_ModuleWiring(t *testing.T) {
|
||||
Contract: SR25519VerifyPrecompile,
|
||||
Configurator: &configurator{},
|
||||
}
|
||||
require.Equal(t, "sr25519Verify", entry.ConfigKey)
|
||||
require.Equal(t, "sr25519Config", entry.ConfigKey)
|
||||
require.Equal(t,
|
||||
common.HexToAddress("0x0A00000000000000000000000000000000000001"),
|
||||
ContractAddress)
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
var _ contract.Configurator = &configurator{}
|
||||
|
||||
const ConfigKey = "starkfriVerify"
|
||||
const ConfigKey = "starkfriConfig"
|
||||
|
||||
type configurator struct{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user