github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/model/flow/transaction_result.go (about)

     1  package flow
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  // TransactionResult contains the artifacts generated after executing a Cadence transaction.
     8  type TransactionResult struct {
     9  	// TransactionID is the ID of the transaction this error was emitted from.
    10  	TransactionID Identifier
    11  	// ErrorMessage contains the error message of any error that may have occurred when the transaction was executed
    12  	ErrorMessage string
    13  	// Computation used
    14  	ComputationUsed uint64
    15  	// Memory used (estimation)
    16  	MemoryUsed uint64
    17  }
    18  
    19  // String returns the string representation of this error.
    20  func (t TransactionResult) String() string {
    21  	return fmt.Sprintf("Transaction ID: %s, Error Message: %s", t.TransactionID.String(), t.ErrorMessage)
    22  }
    23  
    24  // ID returns a canonical identifier that is guaranteed to be unique.
    25  func (t TransactionResult) ID() Identifier {
    26  	return t.TransactionID
    27  }
    28  
    29  func (te *TransactionResult) Checksum() Identifier {
    30  	return te.ID()
    31  }
    32  
    33  // TODO(ramtin): add canonical encoding and ID
    34  type TransactionResults []TransactionResult
    35  
    36  // LightTransactionResult represents a TransactionResult, omitting any fields that are prone to
    37  // non-determinism; i.e. the error message and memory used estimate.
    38  //
    39  // While the net causes of a transaction failing are deterministic, the specific error and message
    40  // propagated back to FVM are prone to bugs resulting in slight variations. Rather than including
    41  // the error and risking execution forks if an undetected bug is introduced, we simplify it to just
    42  // a boolean value. This will likely change in the future to include some additional information
    43  // about the error.
    44  //
    45  // Additionally, MemoryUsed is omitted because it is an estimate from the specific execution node,
    46  // and will vary across nodes.
    47  type LightTransactionResult struct {
    48  	// TransactionID is the ID of the transaction this result was emitted from.
    49  	TransactionID Identifier
    50  	// Failed is true if the transaction's execution failed resulting in an error, false otherwise.
    51  	Failed bool
    52  	// ComputationUsed is amount of computation used while executing the transaction.
    53  	ComputationUsed uint64
    54  }