github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/engine/execution/computation/result/consumer.go (about)

     1  package result
     2  
     3  import (
     4  	"github.com/onflow/flow-go/fvm/storage/snapshot"
     5  	"github.com/onflow/flow-go/model/flow"
     6  	"github.com/onflow/flow-go/module"
     7  )
     8  
     9  type ExecutableCollection interface {
    10  	// BlockHeader returns the block header in which collection was included
    11  	BlockHeader() *flow.Header
    12  
    13  	// Collection returns the content of the collection
    14  	Collection() *flow.Collection
    15  
    16  	// CollectionIndex returns the index of collection in the block
    17  	CollectionIndex() int
    18  
    19  	// IsSystemCollection returns true if the collection is the last collection of the block
    20  	IsSystemCollection() bool
    21  }
    22  
    23  // ExecutedCollection holds results of a collection execution
    24  type ExecutedCollection interface {
    25  
    26  	// Events returns a list of all the events emitted during collection execution
    27  	Events() flow.EventsList
    28  
    29  	// ServiceEventList returns a list of only service events emitted during this collection
    30  	ServiceEventList() flow.EventsList
    31  
    32  	// ConvertedServiceEvents returns a list of converted service events
    33  	ConvertedServiceEvents() flow.ServiceEventList
    34  
    35  	// TransactionResults returns a list of transaction results
    36  	TransactionResults() flow.TransactionResults
    37  
    38  	// ExecutionSnapshot returns the execution snapshot
    39  	ExecutionSnapshot() *snapshot.ExecutionSnapshot
    40  }
    41  
    42  // ExecutedCollectionConsumer consumes ExecutedCollections
    43  type ExecutedCollectionConsumer interface {
    44  	module.ReadyDoneAware
    45  	OnExecutedCollection(res ExecutedCollection) error
    46  }
    47  
    48  // AttestedCollection holds results of a collection attestation
    49  type AttestedCollection interface {
    50  	ExecutedCollection
    51  
    52  	// StartStateCommitment returns a commitment to the state before collection execution
    53  	StartStateCommitment() flow.StateCommitment
    54  
    55  	// EndStateCommitment returns a commitment to the state after collection execution
    56  	EndStateCommitment() flow.StateCommitment
    57  
    58  	// StateProof returns state proofs that could be used to build a partial trie
    59  	StateProof() flow.StorageProof
    60  
    61  	// TODO(ramtin): unlock these
    62  	// // StateDeltaCommitment returns a commitment over the state delta
    63  	// StateDeltaCommitment()  flow.Identifier
    64  
    65  	// // TxResultListCommitment returns a commitment over the list of transaction results
    66  	// TxResultListCommitment() flow.Identifier
    67  
    68  	// EventCommitment returns commitment over eventList
    69  	EventListCommitment() flow.Identifier
    70  }
    71  
    72  // AttestedCollectionConsumer consumes AttestedCollection
    73  type AttestedCollectionConsumer interface {
    74  	module.ReadyDoneAware
    75  	OnAttestedCollection(ac AttestedCollection) error
    76  }
    77  
    78  type ExecutedBlock interface {
    79  	// BlockHeader returns the block header in which collection was included
    80  	BlockHeader() *flow.Header
    81  
    82  	// Receipt returns the execution receipt
    83  	Receipt() *flow.ExecutionReceipt
    84  
    85  	// AttestedCollections returns attested collections
    86  	//
    87  	// TODO(ramtin): this could be reduced, currently we need this
    88  	// to store chunk data packs, trie updates package used by access nodes,
    89  	AttestedCollections() []AttestedCollection
    90  }
    91  
    92  // ExecutedBlockConsumer consumes ExecutedBlock
    93  type ExecutedBlockConsumer interface {
    94  	module.ReadyDoneAware
    95  	OnExecutedBlock(eb ExecutedBlock) error
    96  }