diff --git a/fvm/executionParameters.go b/fvm/executionParameters.go index ac0ec6223f0..bb3f2075318 100644 --- a/fvm/executionParameters.go +++ b/fvm/executionParameters.go @@ -19,6 +19,7 @@ import ( "github.com/onflow/flow-go/fvm/storage" "github.com/onflow/flow-go/fvm/storage/derived" "github.com/onflow/flow-go/fvm/storage/state" + "github.com/onflow/flow-go/fvm/systemcontracts" ) func ProcedureStateParameters( @@ -143,10 +144,11 @@ func (computer ExecutionParametersComputer) getExecutionParameters() ( derived.StateExecutionParameters, error, ) { + sc := systemcontracts.SystemContractsForChain(computer.ctx.Chain.ChainID()) + // Check that the service account exists because all the settings are // stored in it - serviceAddress := computer.ctx.Chain.ServiceAddress() - service := common.Address(serviceAddress) + service := common.Address(sc.ExecutionParametersAccount.Address) env := environment.NewScriptEnv( context.Background(), diff --git a/fvm/systemcontracts/system_contracts.go b/fvm/systemcontracts/system_contracts.go index 7fd321d88bc..8773ce4b0ed 100644 --- a/fvm/systemcontracts/system_contracts.go +++ b/fvm/systemcontracts/system_contracts.go @@ -45,7 +45,8 @@ const ( ContractNameBurner = "Burner" // AccountNameEVMStorage is not a contract, but a special account that is used to store EVM state - AccountNameEVMStorage = "EVMStorageAccount" + AccountNameEVMStorage = "EVMStorageAccount" + AccountNameExecutionParametersAccount = "ExecutionParametersAccount" // Unqualified names of service events (not including address prefix or contract name) @@ -148,10 +149,11 @@ type SystemContracts struct { DKG SystemContract // service account related contracts - FlowServiceAccount SystemContract - NodeVersionBeacon SystemContract - RandomBeaconHistory SystemContract - FlowStorageFees SystemContract + FlowServiceAccount SystemContract + NodeVersionBeacon SystemContract + RandomBeaconHistory SystemContract + FlowStorageFees SystemContract + ExecutionParametersAccount SystemContract // token related contracts FlowFees SystemContract @@ -331,16 +333,26 @@ func init() { } } + executionParametersAccountFunc := func(chain flow.ChainID) flow.Address { + switch chain { + case flow.Testnet: + return flow.HexToAddress("b118676e2f11145f") + default: + return serviceAddressFunc(chain) + } + } + contractAddressFunc = map[string]func(id flow.ChainID) flow.Address{ ContractNameIDTableStaking: epochAddressFunc, ContractNameEpoch: epochAddressFunc, ContractNameClusterQC: epochAddressFunc, ContractNameDKG: epochAddressFunc, - ContractNameNodeVersionBeacon: serviceAddressFunc, - ContractNameRandomBeaconHistory: serviceAddressFunc, - ContractNameServiceAccount: serviceAddressFunc, - ContractNameStorageFees: serviceAddressFunc, + ContractNameNodeVersionBeacon: serviceAddressFunc, + ContractNameRandomBeaconHistory: serviceAddressFunc, + ContractNameServiceAccount: serviceAddressFunc, + ContractNameStorageFees: serviceAddressFunc, + AccountNameExecutionParametersAccount: executionParametersAccountFunc, ContractNameFlowFees: nthAddressFunc(FlowFeesAccountIndex), ContractNameFungibleToken: nthAddressFunc(FungibleTokenAccountIndex), @@ -392,10 +404,11 @@ func init() { ClusterQC: addressOfContract(ContractNameClusterQC), DKG: addressOfContract(ContractNameDKG), - FlowServiceAccount: addressOfContract(ContractNameServiceAccount), - NodeVersionBeacon: addressOfContract(ContractNameNodeVersionBeacon), - RandomBeaconHistory: addressOfContract(ContractNameRandomBeaconHistory), - FlowStorageFees: addressOfContract(ContractNameStorageFees), + FlowServiceAccount: addressOfContract(ContractNameServiceAccount), + NodeVersionBeacon: addressOfContract(ContractNameNodeVersionBeacon), + RandomBeaconHistory: addressOfContract(ContractNameRandomBeaconHistory), + FlowStorageFees: addressOfContract(ContractNameStorageFees), + ExecutionParametersAccount: addressOfContract(AccountNameExecutionParametersAccount), FlowFees: addressOfContract(ContractNameFlowFees), FlowToken: addressOfContract(ContractNameFlowToken),