diff --git a/cmd/scaffold.go b/cmd/scaffold.go index c36485aaadf..73548ba8620 100644 --- a/cmd/scaffold.go +++ b/cmd/scaffold.go @@ -26,8 +26,7 @@ import ( "google.golang.org/api/option" "github.com/onflow/flow-go/crypto" - "github.com/onflow/flow-go/fvm" - "github.com/onflow/flow-go/fvm/environment" + "github.com/onflow/flow-go/fvm/initialize" "github.com/onflow/flow-go/admin" "github.com/onflow/flow-go/admin/commands" @@ -1564,26 +1563,7 @@ func (fnb *FlowNodeBuilder) initLocal() error { } func (fnb *FlowNodeBuilder) initFvmOptions() { - blockFinder := environment.NewBlockFinder(fnb.Storage.Headers) - vmOpts := []fvm.Option{ - fvm.WithChain(fnb.RootChainID.Chain()), - fvm.WithBlocks(blockFinder), - fvm.WithAccountStorageLimit(true), - // temporarily enable dependency check for all networks - fvm.WithDependencyCheckEnabled(true), - } - if fnb.RootChainID == flow.Testnet || fnb.RootChainID == flow.Sandboxnet || fnb.RootChainID == flow.Mainnet { - vmOpts = append(vmOpts, - fvm.WithTransactionFeesEnabled(true), - ) - } - if fnb.RootChainID == flow.Testnet || fnb.RootChainID == flow.Sandboxnet || fnb.RootChainID == flow.Localnet || fnb.RootChainID == flow.Benchnet { - vmOpts = append(vmOpts, - fvm.WithContractDeploymentRestricted(false), - ) - } - - fnb.FvmOptions = vmOpts + fnb.FvmOptions = initialize.InitFvmOptions(fnb.RootChainID, fnb.Storage.Headers) } // handleModules initializes the given module. diff --git a/engine/verification/verifier/verifiers.go b/engine/verification/verifier/verifiers.go index f92a25ad97e..95ff0b52318 100644 --- a/engine/verification/verifier/verifiers.go +++ b/engine/verification/verifier/verifiers.go @@ -42,7 +42,10 @@ func VerifyLastKHeight(k uint64, chainID flow.ChainID, protocolDataDir string, c return fmt.Errorf("could not get last sealed height: %w", err) } - root := state.Params().SealedRoot().Height + root, err := state.Params().SealedRoot() + if err != nil { + return fmt.Errorf("could not get sealed root: %w", err) + } // preventing overflow if k > lastSealed.Height+1 { diff --git a/fvm/initialize/options.go b/fvm/initialize/options.go index fcfce074601..c0aa8c62334 100644 --- a/fvm/initialize/options.go +++ b/fvm/initialize/options.go @@ -16,22 +16,23 @@ func InitFvmOptions(chainID flow.ChainID, headers storage.Headers) []fvm.Option fvm.WithChain(chainID.Chain()), fvm.WithBlocks(blockFinder), fvm.WithAccountStorageLimit(true), + // temporarily enable dependency check for all networks + fvm.WithDependencyCheckEnabled(true), } switch chainID { case flow.Testnet, flow.Sandboxnet, - flow.Previewnet, flow.Mainnet: vmOpts = append(vmOpts, fvm.WithTransactionFeesEnabled(true), ) } - switch chainID { - case flow.Testnet, - flow.Sandboxnet, - flow.Previewnet, - flow.Localnet, - flow.Benchnet: + if chainID == flow.Testnet || chainID == flow.Sandboxnet || chainID == flow.Mainnet { + vmOpts = append(vmOpts, + fvm.WithTransactionFeesEnabled(true), + ) + } + if chainID == flow.Testnet || chainID == flow.Sandboxnet || chainID == flow.Localnet || chainID == flow.Benchnet { vmOpts = append(vmOpts, fvm.WithContractDeploymentRestricted(false), )