github.com/onflow/flow-go@v0.33.17/model/flow/transaction_result.go (about)

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