Skip to content

Commit

Permalink
move execution parameter to separate account
Browse files Browse the repository at this point in the history
  • Loading branch information
janezpodhostnik committed Jan 15, 2025
1 parent ad39920 commit df2464e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
6 changes: 4 additions & 2 deletions fvm/executionParameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(),
Expand Down
39 changes: 26 additions & 13 deletions fvm/systemcontracts/system_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit df2464e

Please sign in to comment.