Skip to content

Add ComputationUsed to TransactionResult in test framework - #4455

Merged
turbolent merged 4 commits into
masterfrom
holyfuchs/test-computation-metering
Apr 8, 2026
Merged

turbolent merged 4 commits into
masterfrom
holyfuchs/test-computation-metering

Conversation

@holyfuchs

Copy link
Copy Markdown
Contributor

Adds computationUsed field to TransactionResult as part of computation metering support in the Cadence test framework (onflow/cadence-tools#563).
Updates the Go struct, the Cadence contract struct in test.cdc, and the newTransactionResult constructor invocation in test.go to pass the new value. No existing behavior is changed.

@github-actions

github-actions Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 8200d47.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@github-actions

github-actions Bot commented Mar 24, 2026 •

Copy link
Copy Markdown

Benchstat comparison

  • Base branch: onflow:master
  • Base commit: eb6737f
Results

old.txtnew.txt
time/opdelta
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ByteArrayTransfer-41.29µs ± 0%1.23µs ± 0%~(p=1.000 n=1+1)
ByteArrayValueToByteSlice-478.0ns ± 0%80.2ns ± 0%~(p=1.000 n=1+1)
ByteSliceToByteArrayValue-4949ns ± 0%1045ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4404µs ± 0%407µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-43.79µs ± 0%3.72µs ± 0%~(p=1.000 n=1+1)
Emit-44.54ms ± 0%4.65ms ± 0%~(p=1.000 n=1+1)
EnumTransfer-41.40µs ± 0%1.43µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4275ns ± 0%290ns ± 0%~(p=1.000 n=1+1)
ExportType/simple_type-478.2ns ± 0%78.1ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-422.3µs ± 0%22.6µs ± 0%~(p=1.000 n=1+1)
InterpretRecursionFib-42.25ms ± 0%2.28ms ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_interpreter-4866ns ± 0%875ns ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_sub-interpreter-4330ns ± 0%329ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4670µs ± 0%660µs ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-4691µs ± 0%702µs ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-42.81ms ± 0%2.79ms ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-49.90ms ± 0%9.96ms ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-415.4µs ± 0%15.7µs ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-442.1µs ± 0%41.8µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-462.1ns ± 0%63.7ns ± 0%~(p=1.000 n=1+1)
 
alloc/opdelta
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ByteArrayTransfer-41.08kB ± 0%1.08kB ± 0%~(all equal)
ByteArrayValueToByteSlice-432.0B ± 0%32.0B ± 0%~(all equal)
ByteSliceToByteArrayValue-4859B ± 0%854B ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4144kB ± 0%144kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-42.45kB ± 0%2.45kB ± 0%~(p=1.000 n=1+1)
Emit-41.50MB ± 0%1.50MB ± 0%~(p=1.000 n=1+1)
EnumTransfer-4835B ± 0%836B ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4120B ± 0%120B ± 0%~(all equal)
ExportType/simple_type-40.00B 0.00B ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-48.30kB ± 0%8.30kB ± 0%~(all equal)
InterpretRecursionFib-41.19MB ± 0%1.19MB ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_interpreter-4976B ± 0%976B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-4232B ± 0%232B ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4165kB ± 0%165kB ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-4188kB ± 0%188kB ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-41.76MB ± 0%1.76MB ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-46.98MB ± 0%6.99MB ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-48.09kB ± 0%8.09kB ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-413.4kB ± 0%13.4kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-432.0B ± 0%32.0B ± 0%~(all equal)
 
allocs/opdelta
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ByteArrayTransfer-47.00 ± 0%7.00 ± 0%~(all equal)
ByteArrayValueToByteSlice-41.00 ± 0%1.00 ± 0%~(all equal)
ByteSliceToByteArrayValue-45.00 ± 0%5.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-42.25k ± 0%2.25k ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-429.0 ± 0%29.0 ± 0%~(all equal)
Emit-440.0k ± 0%40.0k ± 0%~(all equal)
EnumTransfer-413.0 ± 0%13.0 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-43.00 ± 0%3.00 ± 0%~(all equal)
ExportType/simple_type-40.00 0.00 ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-4176 ± 0%176 ± 0%~(all equal)
InterpretRecursionFib-417.7k ± 0%17.7k ± 0%~(all equal)
NewInterpreter/new_interpreter-415.0 ± 0%15.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-44.00 ± 0%4.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-43.08k ± 0%3.08k ± 0%~(all equal)
RuntimeFungibleTokenTransferVM-43.61k ± 0%3.61k ± 0%~(all equal)
RuntimeResourceDictionaryValues-436.7k ± 0%36.7k ± 0%~(all equal)
RuntimeResourceTracking-4129k ± 0%129k ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-4114 ± 0%114 ± 0%~(all equal)
RuntimeVMInvokeContractImperativeFib-4426 ± 0%426 ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-41.00 ± 0%1.00 ± 0%~(all equal)
 

@turbolent turbolent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

Comment thread stdlib/contracts/test.cdc Resolved
Co-authored-by: Bastian Müller <bastian@turbolent.com>
@turbolent

Copy link
Copy Markdown
Member

Great idea @holyfuchs! Is there still anything left to be done before this PR can be reviewed/merged? Do you need any help?

@holyfuchs
holyfuchs marked this pull request as ready for review April 8, 2026 13:41
@turbolent
turbolent merged commit 71131d6 into master Apr 8, 2026
18 of 20 checks passed
@turbolent
turbolent deleted the holyfuchs/test-computation-metering branch April 8, 2026 15:40
@coderabbitai coderabbitai Bot mentioned this pull request Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址