Skip to content

Commit

Permalink
refactor fvmOpts
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchiqing committed Dec 12, 2024
1 parent 4ffa7a6 commit 721ae8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 30 deletions.
24 changes: 2 additions & 22 deletions cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion engine/verification/verifier/verifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 8 additions & 7 deletions fvm/initialize/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down

0 comments on commit 721ae8a

Please sign in to comment.