@@ -7,8 +7,12 @@ import (
77 "github.com/hashicorp/go-multierror"
88
99 "github.com/onflow/flow-go/fvm/state"
10+ "github.com/onflow/flow-go/fvm/storage/logical"
1011)
1112
13+ // TODO(patrick): rm once emulator is updated
14+ const EndOfBlockExecutionTime = logical .EndOfBlockExecutionTime
15+
1216// ValueComputer is used by DerivedDataTable's GetOrCompute to compute the
1317// derived value when the value is not in DerivedDataTable (i.e., "cache miss").
1418type ValueComputer [TKey any , TVal any ] interface {
@@ -43,7 +47,7 @@ type DerivedDataTable[TKey comparable, TVal any] struct {
4347 lock sync.RWMutex
4448 items map [TKey ]* invalidatableEntry [TVal ]
4549
46- latestCommitExecutionTime LogicalTime
50+ latestCommitExecutionTime logical. Time
4751
4852 invalidators chainedTableInvalidators [TKey , TVal ] // Guarded by lock.
4953}
@@ -53,10 +57,10 @@ type TableTransaction[TKey comparable, TVal any] struct {
5357
5458 // The start time when the snapshot first becomes readable (i.e., the
5559 // "snapshotTime - 1"'s transaction committed the snapshot view).
56- snapshotTime LogicalTime
60+ snapshotTime logical. Time
5761
5862 // The transaction (or script)'s execution start time (aka TxIndex).
59- executionTime LogicalTime
63+ executionTime logical. Time
6064
6165 // toValidateTime is used to amortize cost of repeated Validate calls.
6266 // Each Validate call will only validate the time range
@@ -66,7 +70,7 @@ type TableTransaction[TKey comparable, TVal any] struct {
6670 // Note that since newly derived values are computed based on snapshotTime's
6771 // view, each time a newly derived value is added to the transaction,
6872 // toValidateTime is reset back to snapshotTime.
69- toValidateTime LogicalTime
73+ toValidateTime logical. Time
7074
7175 readSet map [TKey ]* invalidatableEntry [TVal ]
7276 writeSet map [TKey ]* invalidatableEntry [TVal ]
@@ -77,7 +81,7 @@ type TableTransaction[TKey comparable, TVal any] struct {
7781}
7882
7983func newEmptyTable [TKey comparable , TVal any ](
80- latestCommit LogicalTime ,
84+ latestCommit logical. Time ,
8185) * DerivedDataTable [TKey , TVal ] {
8286 return & DerivedDataTable [TKey , TVal ]{
8387 items : map [TKey ]* invalidatableEntry [TVal ]{},
@@ -87,7 +91,7 @@ func newEmptyTable[TKey comparable, TVal any](
8791}
8892
8993func NewEmptyTable [TKey comparable , TVal any ]() * DerivedDataTable [TKey , TVal ] {
90- return newEmptyTable [TKey , TVal ](ParentBlockTime )
94+ return newEmptyTable [TKey , TVal ](logical . ParentBlockTime )
9195}
9296
9397// This variant is needed by the chunk verifier, which does not start at the
@@ -98,7 +102,7 @@ func NewEmptyTableWithOffset[
98102](
99103 offset uint32 ,
100104) * DerivedDataTable [TKey , TVal ] {
101- return newEmptyTable [TKey , TVal ](LogicalTime (offset ) - 1 )
105+ return newEmptyTable [TKey , TVal ](logical . Time (offset ) - 1 )
102106}
103107
104108func (table * DerivedDataTable [TKey , TVal ]) NewChildTable () * DerivedDataTable [TKey , TVal ] {
@@ -122,7 +126,7 @@ func (table *DerivedDataTable[TKey, TVal]) NewChildTable() *DerivedDataTable[TKe
122126
123127 return & DerivedDataTable [TKey , TVal ]{
124128 items : items ,
125- latestCommitExecutionTime : ParentBlockTime ,
129+ latestCommitExecutionTime : logical . ParentBlockTime ,
126130 invalidators : nil ,
127131 }
128132}
@@ -131,7 +135,7 @@ func (table *DerivedDataTable[TKey, TVal]) NextTxIndexForTestingOnly() uint32 {
131135 return uint32 (table .LatestCommitExecutionTimeForTestingOnly ()) + 1
132136}
133137
134- func (table * DerivedDataTable [TKey , TVal ]) LatestCommitExecutionTimeForTestingOnly () LogicalTime {
138+ func (table * DerivedDataTable [TKey , TVal ]) LatestCommitExecutionTimeForTestingOnly () logical. Time {
135139 table .lock .RLock ()
136140 defer table .lock .RUnlock ()
137141
@@ -235,7 +239,7 @@ func (table *DerivedDataTable[TKey, TVal]) commit(
235239
236240 if table .latestCommitExecutionTime + 1 < txn .snapshotTime &&
237241 (! txn .isSnapshotReadTransaction ||
238- txn .snapshotTime != EndOfBlockExecutionTime ) {
242+ txn .snapshotTime != logical . EndOfBlockExecutionTime ) {
239243
240244 return newNotRetryableError (
241245 "invalid TableTransaction: missing commit range [%v, %v)" ,
@@ -290,9 +294,9 @@ func (table *DerivedDataTable[TKey, TVal]) commit(
290294}
291295
292296func (table * DerivedDataTable [TKey , TVal ]) newTableTransaction (
293- upperBoundExecutionTime LogicalTime ,
294- snapshotTime LogicalTime ,
295- executionTime LogicalTime ,
297+ upperBoundExecutionTime logical. Time ,
298+ snapshotTime logical. Time ,
299+ executionTime logical. Time ,
296300 isSnapshotReadTransaction bool ,
297301) (
298302 * TableTransaction [TKey , TVal ],
@@ -323,28 +327,28 @@ func (table *DerivedDataTable[TKey, TVal]) newTableTransaction(
323327}
324328
325329func (table * DerivedDataTable [TKey , TVal ]) NewSnapshotReadTableTransaction (
326- snapshotTime LogicalTime ,
327- executionTime LogicalTime ,
330+ snapshotTime logical. Time ,
331+ executionTime logical. Time ,
328332) (
329333 * TableTransaction [TKey , TVal ],
330334 error ,
331335) {
332336 return table .newTableTransaction (
333- LargestSnapshotReadTransactionExecutionTime ,
337+ logical . LargestSnapshotReadTransactionExecutionTime ,
334338 snapshotTime ,
335339 executionTime ,
336340 true )
337341}
338342
339343func (table * DerivedDataTable [TKey , TVal ]) NewTableTransaction (
340- snapshotTime LogicalTime ,
341- executionTime LogicalTime ,
344+ snapshotTime logical. Time ,
345+ executionTime logical. Time ,
342346) (
343347 * TableTransaction [TKey , TVal ],
344348 error ,
345349) {
346350 return table .newTableTransaction (
347- LargestNormalTransactionExecutionTime ,
351+ logical . LargestNormalTransactionExecutionTime ,
348352 snapshotTime ,
349353 executionTime ,
350354 false )
@@ -485,6 +489,6 @@ func (txn *TableTransaction[TKey, TVal]) Commit() RetryableError {
485489 return txn .table .commit (txn )
486490}
487491
488- func (txn * TableTransaction [TKey , TVal ]) ToValidateTimeForTestingOnly () LogicalTime {
492+ func (txn * TableTransaction [TKey , TVal ]) ToValidateTimeForTestingOnly () logical. Time {
489493 return txn .toValidateTime
490494}
0 commit comments