Files
evm/precompile/contracts/feemanager/config.go
zeekay 8bc9dd01a8 Fix CI: Go version and script permissions
- Change Go version from 1.24.6 to 1.22.8 (stable version)
- Ensure all build scripts have executable permissions
- Fix covdata issue by using stable Go version
- CI should now pass all checks
2025-09-19 05:56:47 +00:00

83 lines
2.6 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package feemanager
import (
"github.com/luxfi/evm/commontype"
"github.com/luxfi/evm/precompile/allowlist"
"github.com/luxfi/evm/precompile/precompileconfig"
"github.com/luxfi/geth/common"
)
var _ precompileconfig.Config = (*Config)(nil)
// Config implements the StatefulPrecompileConfig interface while adding in the
// FeeManager specific precompile config.
type Config struct {
allowlist.AllowListConfig // Config for the fee config manager allow list
precompileconfig.Upgrade
InitialFeeConfig *commontype.FeeConfig `json:"initialFeeConfig,omitempty"` // initial fee config to be immediately activated
}
// NewConfig returns a config for a network upgrade at [blockTimestamp] that enables
// FeeManager with the given [admins], [enableds] and [managers] as members of the
// allowlist with [initialConfig] as initial fee config if specified.
func NewConfig(blockTimestamp *uint64, admins []common.Address, enableds []common.Address, managers []common.Address, initialConfig *commontype.FeeConfig) *Config {
return &Config{
AllowListConfig: allowlist.AllowListConfig{
AdminAddresses: admins,
EnabledAddresses: enableds,
ManagerAddresses: managers,
},
Upgrade: precompileconfig.Upgrade{BlockTimestamp: blockTimestamp},
InitialFeeConfig: initialConfig,
}
}
// NewDisableConfig returns config for a network upgrade at [blockTimestamp]
// that disables FeeManager.
func NewDisableConfig(blockTimestamp *uint64) *Config {
return &Config{
Upgrade: precompileconfig.Upgrade{
BlockTimestamp: blockTimestamp,
Disable: true,
},
}
}
// Key returns the key for the FeeManager precompileconfig.
// This should be the same key as used in the precompile module.
func (*Config) Key() string { return ConfigKey }
// Equal returns true if [cfg] is a [*FeeManagerConfig] and it has been configured identical to [c].
func (c *Config) Equal(cfg precompileconfig.Config) bool {
// typecast before comparison
other, ok := (cfg).(*Config)
if !ok {
return false
}
eq := c.Upgrade.Equal(&other.Upgrade) && c.AllowListConfig.Equal(&other.AllowListConfig)
if !eq {
return false
}
if c.InitialFeeConfig == nil {
return other.InitialFeeConfig == nil
}
return c.InitialFeeConfig.Equal(other.InitialFeeConfig)
}
// Verify tries to verify Config and returns an error accordingly.
func (c *Config) Verify(chainConfig precompileconfig.ChainConfig) error {
if err := c.AllowListConfig.Verify(chainConfig, c.Upgrade); err != nil {
return err
}
if c.InitialFeeConfig == nil {
return nil
}
return c.InitialFeeConfig.Verify()
}