diff --git a/cmd/util/cmd/compare-cadence-vm/cmd.go b/cmd/util/cmd/compare-cadence-vm/cmd.go index d018ca40ead..d74254f9792 100644 --- a/cmd/util/cmd/compare-cadence-vm/cmd.go +++ b/cmd/util/cmd/compare-cadence-vm/cmd.go @@ -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" @@ -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)") @@ -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 diff --git a/cmd/util/cmd/debug-tx/cmd.go b/cmd/util/cmd/debug-tx/cmd.go index ddcac21467b..b5c23b12662 100644 --- a/cmd/util/cmd/debug-tx/cmd.go +++ b/cmd/util/cmd/debug-tx/cmd.go @@ -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)") @@ -456,6 +456,7 @@ func RunTransaction( fvmOptions := []fvm.Option{ fvm.WithCadenceVMEnabled(useVM), + fvm.WithComputationLimit(computeLimit), } if spanExporter != nil { @@ -497,7 +498,6 @@ func RunTransaction( tx, snapshot, header, - computeLimit, ) if err != nil { log.Fatal().Err(err).Msg("Transaction execution failed") diff --git a/fvm/environment/facade_env.go b/fvm/environment/facade_env.go index 8103ddb1f04..c6c22719768 100644 --- a/fvm/environment/facade_env.go +++ b/fvm/environment/facade_env.go @@ -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" @@ -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{} diff --git a/fvm/environment/mock/environment.go b/fvm/environment/mock/environment.go index 2c7809dc48f..38cd7a765d8 100644 --- a/fvm/environment/mock/environment.go +++ b/fvm/environment/mock/environment.go @@ -28,8 +28,6 @@ import ( runtime "github.com/onflow/cadence/runtime" - sema "github.com/onflow/cadence/sema" - time "time" trace "github.com/onflow/flow-go/module/trace" @@ -1723,7 +1721,7 @@ func (_m *Environment) UpdateAccountContractCode(location common.AddressLocation } // ValidateAccountCapabilitiesGet provides a mock function with given fields: context, address, path, wantedBorrowType, capabilityBorrowType -func (_m *Environment) ValidateAccountCapabilitiesGet(context interpreter.AccountCapabilityGetValidationContext, address interpreter.AddressValue, path interpreter.PathValue, wantedBorrowType *sema.ReferenceType, capabilityBorrowType *sema.ReferenceType) (bool, error) { +func (_m *Environment) ValidateAccountCapabilitiesGet(context interpreter.AccountCapabilityGetValidationContext, address interpreter.AddressValue, path interpreter.PathValue, wantedBorrowType *interpreter.ReferenceStaticType, capabilityBorrowType *interpreter.ReferenceStaticType) (bool, error) { ret := _m.Called(context, address, path, wantedBorrowType, capabilityBorrowType) if len(ret) == 0 { @@ -1732,16 +1730,16 @@ func (_m *Environment) ValidateAccountCapabilitiesGet(context interpreter.Accoun var r0 bool var r1 error - if rf, ok := ret.Get(0).(func(interpreter.AccountCapabilityGetValidationContext, interpreter.AddressValue, interpreter.PathValue, *sema.ReferenceType, *sema.ReferenceType) (bool, error)); ok { + if rf, ok := ret.Get(0).(func(interpreter.AccountCapabilityGetValidationContext, interpreter.AddressValue, interpreter.PathValue, *interpreter.ReferenceStaticType, *interpreter.ReferenceStaticType) (bool, error)); ok { return rf(context, address, path, wantedBorrowType, capabilityBorrowType) } - if rf, ok := ret.Get(0).(func(interpreter.AccountCapabilityGetValidationContext, interpreter.AddressValue, interpreter.PathValue, *sema.ReferenceType, *sema.ReferenceType) bool); ok { + if rf, ok := ret.Get(0).(func(interpreter.AccountCapabilityGetValidationContext, interpreter.AddressValue, interpreter.PathValue, *interpreter.ReferenceStaticType, *interpreter.ReferenceStaticType) bool); ok { r0 = rf(context, address, path, wantedBorrowType, capabilityBorrowType) } else { r0 = ret.Get(0).(bool) } - if rf, ok := ret.Get(1).(func(interpreter.AccountCapabilityGetValidationContext, interpreter.AddressValue, interpreter.PathValue, *sema.ReferenceType, *sema.ReferenceType) error); ok { + if rf, ok := ret.Get(1).(func(interpreter.AccountCapabilityGetValidationContext, interpreter.AddressValue, interpreter.PathValue, *interpreter.ReferenceStaticType, *interpreter.ReferenceStaticType) error); ok { r1 = rf(context, address, path, wantedBorrowType, capabilityBorrowType) } else { r1 = ret.Error(1) diff --git a/fvm/fvm_test.go b/fvm/fvm_test.go index dfcff872fed..0a413182e9e 100644 --- a/fvm/fvm_test.go +++ b/fvm/fvm_test.go @@ -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, ) @@ -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, ) diff --git a/go.mod b/go.mod index 91b6edfc20a..3d2f371daf5 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index e5a512cae99..0948238112b 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/insecure/go.mod b/insecure/go.mod index c38cc464c91..3b54b1d362d 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -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 diff --git a/insecure/go.sum b/insecure/go.sum index b2a5ed17c89..fc688c03405 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -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= diff --git a/integration/go.mod b/integration/go.mod index e9367549420..f7ddda131f5 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -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 diff --git a/integration/go.sum b/integration/go.sum index 25f3155d14b..3b752362b46 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -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= diff --git a/utils/debug/remoteDebugger.go b/utils/debug/remoteDebugger.go index 3ab7002dcba..0b9cd25d5d2 100644 --- a/utils/debug/remoteDebugger.go +++ b/utils/debug/remoteDebugger.go @@ -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 {