Skip to content

Commit b950c8f

Browse files
committed
improve godocs in the indexer
1 parent ab6ac73 commit b950c8f

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

module/state_synchronization/indexer/in_memory_indexer.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ import (
1717
// designed to be used as part of the optimistic syncing processing pipeline, to index data for
1818
// unsealed execution results which is eventually persisted when the execution result is sealed.
1919
//
20+
// The data contained within the BlockExecutionData is verified by verifications nodes as part of the
21+
// approval process. Once the execution result is sealed, the Access node can accept it as valid
22+
// without further verification. However, with optimistic syncing, the Access node may index data
23+
// for execution results that are not sealed. Since this data is not certified by the protocol, it
24+
// must not be persisted to disk. It may be used by the Access node to serve Access API requests,
25+
// with the understanding that it may be later determined to be invalid.
26+
//
2027
// The provided BlockExecutionData is received over the network and its hash is compared to the value
2128
// included in an ExecutionResult within a certified block. This guarantees it is the same data that
22-
// was produced by an execution node who's stake is at risk if the data is incorrect. When the
23-
// execution result is eventually sealed, verification nodes have verified and approved the data.
24-
// Given other nodes on the newtwork are responsible for verifying the contents, the Access node
25-
// accepts the data as is. The indexer may perform opportunistic checks to ensure the data is
26-
// generally consistent, but this is not required.
29+
// was produced by an execution node whose stake is at risk if the data is incorrect. It is not
30+
// practical for an Access node to verify all data, but the indexer may perform opportunistic checks
31+
// to ensure the data is generally consistent.
2732
//
2833
// Transaction error messages are received directly from execution nodes with no protocol guarantees.
2934
// The node must validate that there is a one-to-one mapping between failed transactions and
@@ -76,7 +81,9 @@ func NewInMemoryIndexer(
7681
//
7782
// The method is idempotent and does not modify the state of the indexer.
7883
//
79-
// No error returns are expected during normal operation.
84+
// All error returns are benign and side-effect free for the node. They indicate that the BlockExecutionData
85+
// is inconsistent with the execution result and its block, which points to invalid data produced by
86+
// an external node.
8087
func (i *InMemoryIndexer) IndexBlockData(data *execution_data.BlockExecutionData) (*IndexerData, error) {
8188
if data.BlockID != i.executionResult.BlockID {
8289
return nil, fmt.Errorf("unexpected block execution data: expected block_id=%s, actual block_id=%s", i.executionResult.BlockID, data.BlockID)
@@ -163,7 +170,9 @@ func (i *InMemoryIndexer) IndexBlockData(data *execution_data.BlockExecutionData
163170
// ValidateTxErrors validates that the transaction results and error messages are consistent, and
164171
// returns an error if they are not.
165172
//
166-
// No error returns are expected during normal operation.
173+
// All error returns are benign and side-effect free for the node. They indicate that the transaction
174+
// results and error messages are inconsistent, which points to invalid data produced by an external
175+
// node.
167176
func ValidateTxErrors(results []flow.LightTransactionResult, txResultErrMsgs []flow.TransactionResultErrorMessage) error {
168177
txWithErrors := make(map[flow.Identifier]bool)
169178
for _, txResult := range txResultErrMsgs {

0 commit comments

Comments
 (0)