Skip to content

Commit

Permalink
generalized-upgrades-rb review (#474)
Browse files Browse the repository at this point in the history
* keep genesis disabled fix

* nits

* nits

* nit
  • Loading branch information
darioush authored Feb 2, 2023
1 parent eb20994 commit b89a93a
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion accounts/abi/bind/precompile_config_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func NewModule() precompile.StatefulPrecompileModule {
// Address returns the address of the {{.Contract.Type}}.
// Select a non-conflicting address and set it in generated contract.go
func (c {{.Contract.Type}}Config) Address() common.Address {
func ({{.Contract.Type}}Config) Address() common.Address {
return ContractAddress
}
Expand Down
4 changes: 4 additions & 0 deletions params/precompile_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (c *ChainConfig) verifyPrecompileUpgrades() error {
if err := config.Verify(); err != nil {
return err
}
// if the precompile is disabled at genesis, skip it.
if config.Timestamp() == nil {
continue
}
// check the genesis chain config for any enabled upgrade
lastUpgradeMap[key] = lastUpgradeData{
disabled: false,
Expand Down
8 changes: 4 additions & 4 deletions params/precompile_modules.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // (c) 2022, Ava Labs, Inc. All rights reserved.
// // See the file LICENSE for licensing terms.
// (c) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package params

Expand Down Expand Up @@ -27,10 +27,10 @@ import (
// ContractDeployerAllowListAddress = common.HexToAddress("0x0200000000000000000000000000000000000000")
// ContractNativeMinterAddress = common.HexToAddress("0x0200000000000000000000000000000000000001")
// TxAllowListAddress = common.HexToAddress("0x0200000000000000000000000000000000000002")
// FeeManagerAddress = common.HexToAddress("0x0200000000000000000000000000000000000003")
// FeeManagerAddress = common.HexToAddress("0x0200000000000000000000000000000000000003")
// RewardManagerAddress = common.HexToAddress("0x0200000000000000000000000000000000000004")
// ADD YOUR PRECOMPILE HERE
// {YourPrecompile}Address = common.HexToAddress("0x03000000000000000000000000000000000000??")
// {YourPrecompile}Address = common.HexToAddress("0x03000000000000000000000000000000000000??")
func init() {
// Order matters here.
precompile.RegisterModule(deployerallowlist.NewModule())
Expand Down
2 changes: 1 addition & 1 deletion precompile/deployerallowlist/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (ContractDeployerAllowListConfig) Contract() precompile.StatefulPrecompiled
}

// Key returns the key used in json config files to specify this precompile config.
func (c ContractDeployerAllowListConfig) Key() string {
func (ContractDeployerAllowListConfig) Key() string {
return ConfigKey
}

Expand Down
6 changes: 3 additions & 3 deletions precompile/feemanager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ func NewDisableFeeManagerConfig(blockTimestamp *big.Int) *FeeManagerConfig {
}

// Address returns the address of the fee manager contract.
func (c FeeManagerConfig) Address() common.Address {
func (FeeManagerConfig) Address() common.Address {
return ContractAddress
}

// Contract returns the singleton stateful precompiled contract to be used for the fee manager.
func (c FeeManagerConfig) Contract() precompile.StatefulPrecompiledContract {
func (FeeManagerConfig) Contract() precompile.StatefulPrecompiledContract {
return FeeManagerPrecompile
}

// Key returns the key used in json config files to specify this precompile config.
func (c FeeManagerConfig) Key() string {
func (FeeManagerConfig) Key() string {
return ConfigKey
}

Expand Down
2 changes: 1 addition & 1 deletion precompile/nativeminter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewDisableContractNativeMinterConfig(blockTimestamp *big.Int) *ContractNati
}

// Address returns the address of the native minter contract.
func (c ContractNativeMinterConfig) Address() common.Address {
func (ContractNativeMinterConfig) Address() common.Address {
return ContractAddress
}

Expand Down
8 changes: 4 additions & 4 deletions precompile/rewardmanager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,22 @@ func NewDisableRewardManagerConfig(blockTimestamp *big.Int) *RewardManagerConfig

// Address returns the address of the RewardManager. Addresses reside under the precompile/params.go
// Select a non-conflicting address and set it in the params.go.
func (*RewardManagerConfig) Address() common.Address {
func (RewardManagerConfig) Address() common.Address {
return ContractAddress
}

// Contract returns the singleton stateful precompiled contract to be used for RewardManager.
func (*RewardManagerConfig) Contract() precompile.StatefulPrecompiledContract {
func (RewardManagerConfig) Contract() precompile.StatefulPrecompiledContract {
return RewardManagerPrecompile
}

// Key returns the key used in json config files to specify this precompile config.
func (*RewardManagerConfig) Key() string {
func (RewardManagerConfig) Key() string {
return ConfigKey
}

// NewConfig returns a new instance of RewardManagerConfig.
func (*RewardManagerConfig) NewConfig() precompile.StatefulPrecompileConfig {
func (RewardManagerConfig) NewConfig() precompile.StatefulPrecompileConfig {
return new(RewardManagerConfig)
}

Expand Down
2 changes: 1 addition & 1 deletion precompile/stateful_precompile_module.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package precompile
Expand Down
2 changes: 1 addition & 1 deletion tests/statefulprecompiles/allow_list_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package statefulprecompiles
Expand Down
2 changes: 1 addition & 1 deletion tests/statefulprecompiles/contract_deployer_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package statefulprecompiles
Expand Down
2 changes: 1 addition & 1 deletion tests/statefulprecompiles/fee_manager_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package statefulprecompiles
Expand Down
2 changes: 1 addition & 1 deletion tests/statefulprecompiles/native_minter_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package statefulprecompiles
Expand Down
2 changes: 1 addition & 1 deletion tests/statefulprecompiles/reward_manager_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package statefulprecompiles
Expand Down
2 changes: 1 addition & 1 deletion tests/statefulprecompiles/tx_allowlist_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// (c) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package statefulprecompiles
Expand Down

0 comments on commit b89a93a

Please sign in to comment.