Skip to content
Open
26 changes: 23 additions & 3 deletions cmd/util/cmd/compare-cadence-vm/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

debug_tx "github.com/onflow/flow-go/cmd/util/cmd/debug-tx"
"github.com/onflow/flow-go/fvm"
"github.com/onflow/flow-go/fvm/errors"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/grpcclient"
"github.com/onflow/flow-go/utils/debug"
Expand Down Expand Up @@ -58,7 +59,7 @@ func init() {

Cmd.Flags().StringVar(&flagExecutionAddress, "execution-address", "", "address of the execution node (required if --use-execution-data-api is false)")

Cmd.Flags().Uint64Var(&flagComputeLimit, "compute-limit", 9999, "transaction compute limit")
Cmd.Flags().Uint64Var(&flagComputeLimit, "compute-limit", flow.DefaultMaxTransactionGasLimit, "transaction compute limit")

Cmd.Flags().BoolVar(&flagUseExecutionDataAPI, "use-execution-data-api", true, "use the execution data API (default: true)")

Expand Down Expand Up @@ -340,11 +341,30 @@ func compareResults(txID flow.Identifier, interResult debug.Result, vmResult deb
vmErr := vmResult.Output.Err

if interErr == nil && vmErr != nil {
log.Error().Msgf("VM failed but interpreter succeeded")

if vmErr.Code() == errors.ErrCodeComputationLimitExceededError {
log.Warn().Msg("VM exceeded computation limit but interpreter succeeded. Ignoring")
return true
}

log.Error().Msg("VM failed but interpreter succeeded")
mismatch = true

} else if interErr != nil && vmErr == nil {
log.Error().Msgf("Interpreter failed but VM succeeded")
if interErr.Code() == errors.ErrCodeComputationLimitExceededError {
log.Warn().Msg("Interpreter exceeded computation limit but VM succeeded. Ignoring")
return true
}

log.Error().Msg("Interpreter failed but VM succeeded")
mismatch = true
} else if interErr != nil &&
vmErr != nil &&
interErr.Code() == errors.ErrCodeComputationLimitExceededError &&
vmErr.Code() == errors.ErrCodeComputationLimitExceededError {

log.Warn().Msg("Both interpreter and VM exceeded computation limit. Ignoring")
return true
}

// Compare events
Expand Down
4 changes: 2 additions & 2 deletions cmd/util/cmd/debug-tx/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func init() {

Cmd.Flags().StringVar(&flagExecutionAddress, "execution-address", "", "address of the execution node (required if --use-execution-data-api is false)")

Cmd.Flags().Uint64Var(&flagComputeLimit, "compute-limit", 9999, "transaction compute limit")
Cmd.Flags().Uint64Var(&flagComputeLimit, "compute-limit", flow.DefaultMaxTransactionGasLimit, "transaction compute limit")

Cmd.Flags().BoolVar(&flagUseExecutionDataAPI, "use-execution-data-api", true, "use the execution data API (default: true)")

Expand Down Expand Up @@ -456,6 +456,7 @@ func RunTransaction(

fvmOptions := []fvm.Option{
fvm.WithCadenceVMEnabled(useVM),
fvm.WithComputationLimit(computeLimit),
}

if spanExporter != nil {
Expand Down Expand Up @@ -497,7 +498,6 @@ func RunTransaction(
tx,
snapshot,
header,
computeLimit,
)
if err != nil {
log.Fatal().Err(err).Msg("Transaction execution failed")
Expand Down
7 changes: 3 additions & 4 deletions fvm/environment/facade_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/onflow/cadence/ast"
"github.com/onflow/cadence/common"
"github.com/onflow/cadence/interpreter"
"github.com/onflow/cadence/sema"

"github.com/onflow/flow-go/fvm/storage"
"github.com/onflow/flow-go/fvm/storage/snapshot"
Expand Down Expand Up @@ -351,10 +350,10 @@ func (env *facadeEnvironment) ValidateAccountCapabilitiesGet(
_ interpreter.AccountCapabilityGetValidationContext,
_ interpreter.AddressValue,
_ interpreter.PathValue,
wantedBorrowType *sema.ReferenceType,
_ *sema.ReferenceType,
wantedBorrowType *interpreter.ReferenceStaticType,
_ *interpreter.ReferenceStaticType,
) (bool, error) {
_, hasEntitlements := wantedBorrowType.Authorization.(sema.EntitlementSetAccess)
_, hasEntitlements := wantedBorrowType.Authorization.(interpreter.EntitlementSetAuthorization)
if hasEntitlements {
// TODO: maybe abort
//return false, &interpreter.GetCapabilityError{}
Expand Down
10 changes: 4 additions & 6 deletions fvm/environment/mock/environment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions fvm/fvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3976,15 +3976,19 @@ func TestAccountCapabilitiesGetEntitledRejection(t *testing.T) {
nil,
interpreter.AddressValue(common.ZeroAddress),
interpreter.NewUnmeteredPathValue(common.PathDomainPublic, "dummy_value"),
sema.NewReferenceType(
interpreter.NewReferenceStaticType(
nil,
sema.NewEntitlementSetAccess(
[]*sema.EntitlementType{
sema.MutateType,
interpreter.NewEntitlementSetAuthorization(
nil,
func() []common.TypeID {
return []common.TypeID{
sema.MutateType.ID(),
}
},
1,
sema.Conjunction,
),
sema.IntType,
interpreter.PrimitiveStaticTypeInt,
),
nil,
)
Expand All @@ -4005,10 +4009,10 @@ func TestAccountCapabilitiesGetEntitledRejection(t *testing.T) {
nil,
interpreter.AddressValue(common.ZeroAddress),
interpreter.NewUnmeteredPathValue(common.PathDomainPublic, "dummy_value"),
sema.NewReferenceType(
interpreter.NewReferenceStaticType(
nil,
sema.UnauthorizedAccess,
sema.IntType,
interpreter.UnauthorizedAccess,
interpreter.PrimitiveStaticTypeInt,
),
nil,
)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require (
github.com/multiformats/go-multiaddr-dns v0.4.1
github.com/multiformats/go-multihash v0.2.3
github.com/onflow/atree v0.12.0
github.com/onflow/cadence v1.9.1
github.com/onflow/cadence v1.9.3-0.20251209190939-67ad9e7ba04d
github.com/onflow/crypto v0.25.3
github.com/onflow/flow v0.4.15
github.com/onflow/flow-core-contracts/lib/go/contracts v1.9.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -940,8 +940,8 @@ github.com/onflow/atree v0.12.0 h1:X7/UEPyCaaEQ1gCg11KDvfyEtEeQLhtRtxMHjAiH/Co=
github.com/onflow/atree v0.12.0/go.mod h1:qdZcfLQwPirHcNpLiK+2t3KAo+SAb9Si6TqurE6pykE=
github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483 h1:LpiQhTAfM9CAmNVEs0n//cBBgCg+vJSiIxTHYUklZ84=
github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
github.com/onflow/cadence v1.9.1 h1:z78U90Vt+5aBb4MlFk3mQWNi/5fYcUYtXSB/NBNfMKo=
github.com/onflow/cadence v1.9.1/go.mod h1:MlJsCwhCZwdnAUd24XHzcsizZfG7a2leab1PztabUsE=
github.com/onflow/cadence v1.9.3-0.20251209190939-67ad9e7ba04d h1:OLp/DVRZL+YBxwZUZr62p8plAfQdnY5I9QGMWSBSLaU=
github.com/onflow/cadence v1.9.3-0.20251209190939-67ad9e7ba04d/go.mod h1:MlJsCwhCZwdnAUd24XHzcsizZfG7a2leab1PztabUsE=
github.com/onflow/crypto v0.25.3 h1:XQ3HtLsw8h1+pBN+NQ1JYM9mS2mVXTyg55OldaAIF7U=
github.com/onflow/crypto v0.25.3/go.mod h1:+1igaXiK6Tjm9wQOBD1EGwW7bYWMUGKtwKJ/2QL/OWs=
github.com/onflow/fixed-point v0.1.1 h1:j0jYZVO8VGyk1476alGudEg7XqCkeTVxb5ElRJRKS90=
Expand Down
2 changes: 1 addition & 1 deletion insecure/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/atree v0.12.0 // indirect
github.com/onflow/cadence v1.9.1 // indirect
github.com/onflow/cadence v1.9.3-0.20251209190939-67ad9e7ba04d // indirect
github.com/onflow/fixed-point v0.1.1 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.9.2 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.9.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions insecure/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -890,8 +890,8 @@ github.com/onflow/atree v0.12.0 h1:X7/UEPyCaaEQ1gCg11KDvfyEtEeQLhtRtxMHjAiH/Co=
github.com/onflow/atree v0.12.0/go.mod h1:qdZcfLQwPirHcNpLiK+2t3KAo+SAb9Si6TqurE6pykE=
github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483 h1:LpiQhTAfM9CAmNVEs0n//cBBgCg+vJSiIxTHYUklZ84=
github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
github.com/onflow/cadence v1.9.1 h1:z78U90Vt+5aBb4MlFk3mQWNi/5fYcUYtXSB/NBNfMKo=
github.com/onflow/cadence v1.9.1/go.mod h1:MlJsCwhCZwdnAUd24XHzcsizZfG7a2leab1PztabUsE=
github.com/onflow/cadence v1.9.3-0.20251209190939-67ad9e7ba04d h1:OLp/DVRZL+YBxwZUZr62p8plAfQdnY5I9QGMWSBSLaU=
github.com/onflow/cadence v1.9.3-0.20251209190939-67ad9e7ba04d/go.mod h1:MlJsCwhCZwdnAUd24XHzcsizZfG7a2leab1PztabUsE=
github.com/onflow/crypto v0.25.3 h1:XQ3HtLsw8h1+pBN+NQ1JYM9mS2mVXTyg55OldaAIF7U=
github.com/onflow/crypto v0.25.3/go.mod h1:+1igaXiK6Tjm9wQOBD1EGwW7bYWMUGKtwKJ/2QL/OWs=
github.com/onflow/fixed-point v0.1.1 h1:j0jYZVO8VGyk1476alGudEg7XqCkeTVxb5ElRJRKS90=
Expand Down
2 changes: 1 addition & 1 deletion integration/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/ipfs/go-datastore v0.8.2
github.com/ipfs/go-ds-pebble v0.5.0
github.com/libp2p/go-libp2p v0.38.2
github.com/onflow/cadence v1.9.1
github.com/onflow/cadence v1.9.3-0.20251209190939-67ad9e7ba04d
github.com/onflow/crypto v0.25.3
github.com/onflow/flow v0.4.15
github.com/onflow/flow-core-contracts/lib/go/contracts v1.9.2
Expand Down
6 changes: 4 additions & 2 deletions integration/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,10 @@ github.com/onflow/atree v0.12.0 h1:X7/UEPyCaaEQ1gCg11KDvfyEtEeQLhtRtxMHjAiH/Co=
github.com/onflow/atree v0.12.0/go.mod h1:qdZcfLQwPirHcNpLiK+2t3KAo+SAb9Si6TqurE6pykE=
github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483 h1:LpiQhTAfM9CAmNVEs0n//cBBgCg+vJSiIxTHYUklZ84=
github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
github.com/onflow/cadence v1.9.1 h1:z78U90Vt+5aBb4MlFk3mQWNi/5fYcUYtXSB/NBNfMKo=
github.com/onflow/cadence v1.9.1/go.mod h1:MlJsCwhCZwdnAUd24XHzcsizZfG7a2leab1PztabUsE=
github.com/onflow/cadence v1.9.2-0.20251205230900-d0c5cc82b279 h1:ASEFfO49ht2Z6+OU6pornOM+ypzo9PfP+CFboWmfbgw=
github.com/onflow/cadence v1.9.2-0.20251205230900-d0c5cc82b279/go.mod h1:MlJsCwhCZwdnAUd24XHzcsizZfG7a2leab1PztabUsE=
github.com/onflow/cadence v1.9.3-0.20251209190939-67ad9e7ba04d h1:OLp/DVRZL+YBxwZUZr62p8plAfQdnY5I9QGMWSBSLaU=
github.com/onflow/cadence v1.9.3-0.20251209190939-67ad9e7ba04d/go.mod h1:MlJsCwhCZwdnAUd24XHzcsizZfG7a2leab1PztabUsE=
github.com/onflow/crypto v0.25.3 h1:XQ3HtLsw8h1+pBN+NQ1JYM9mS2mVXTyg55OldaAIF7U=
github.com/onflow/crypto v0.25.3/go.mod h1:+1igaXiK6Tjm9wQOBD1EGwW7bYWMUGKtwKJ/2QL/OWs=
github.com/onflow/fixed-point v0.1.1 h1:j0jYZVO8VGyk1476alGudEg7XqCkeTVxb5ElRJRKS90=
Expand Down
3 changes: 1 addition & 2 deletions utils/debug/remoteDebugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,13 @@ func (d *RemoteDebugger) RunSDKTransaction(
tx *sdk.Transaction,
snapshot StorageSnapshot,
header *flow.Header,
computeLimit uint64,
) (
Result,
error,
) {
txBodyBuilder := flow.NewTransactionBodyBuilder().
SetScript(tx.Script).
SetComputeLimit(computeLimit).
SetComputeLimit(tx.GasLimit).
SetPayer(flow.Address(tx.Payer))

for _, argument := range tx.Arguments {
Expand Down
Loading