Skip to content

Commit 272a225

Browse files
Merge #4064
4064: Update fvm GetAccount to use StorageSnapshot as input r=pattyshack a=pattyshack Co-authored-by: Patrick Lee <[email protected]>
2 parents c24efa9 + 2d830a2 commit 272a225

File tree

5 files changed

+36
-15
lines changed

5 files changed

+36
-15
lines changed

engine/execution/computation/manager_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,9 @@ func (p *PanickingVM) Run(f fvm.Context, procedure fvm.Procedure, view state.Vie
519519
}
520520

521521
func (p *PanickingVM) GetAccount(
522-
f fvm.Context,
522+
ctx fvm.Context,
523523
address flow.Address,
524-
view state.View,
524+
storageSnapshot state.StorageSnapshot,
525525
) (
526526
*flow.Account,
527527
error,
@@ -560,9 +560,9 @@ func (l *LongRunningVM) Run(f fvm.Context, procedure fvm.Procedure, view state.V
560560
}
561561

562562
func (l *LongRunningVM) GetAccount(
563-
f fvm.Context,
563+
ctx fvm.Context,
564564
address flow.Address,
565-
view state.View,
565+
storageSnapshot state.StorageSnapshot,
566566
) (
567567
*flow.Account,
568568
error,

engine/execution/computation/query/executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (e *QueryExecutor) GetAccount(
225225
account, err := e.vm.GetAccount(
226226
blockCtx,
227227
address,
228-
delta.NewDeltaView(snapshot))
228+
snapshot)
229229
if err != nil {
230230
return nil, fmt.Errorf(
231231
"failed to get account (%s) at block (%s): %w",

fvm/fvm.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ type VM interface {
122122
)
123123

124124
Run(Context, Procedure, state.View) error
125-
GetAccount(Context, flow.Address, state.View) (*flow.Account, error)
125+
GetAccount(Context, flow.Address, state.StorageSnapshot) (*flow.Account, error)
126126
}
127127

128128
var _ VM = (*VirtualMachine)(nil)
@@ -235,13 +235,14 @@ func (vm *VirtualMachine) Run(
235235
func (vm *VirtualMachine) GetAccount(
236236
ctx Context,
237237
address flow.Address,
238-
v state.View,
238+
storageSnapshot state.StorageSnapshot,
239239
) (
240240
*flow.Account,
241241
error,
242242
) {
243243
nestedTxn := state.NewTransactionState(
244-
v,
244+
// TODO(patrick): initialize view inside TransactionState
245+
delta.NewDeltaView(storageSnapshot),
245246
state.DefaultParameters().
246247
WithMaxKeySizeAllowed(ctx.MaxStateKeySize).
247248
WithMaxValueSizeAllowed(ctx.MaxStateValueSize).

fvm/mock/vm.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

module/chunks/chunkVerifier_test.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,13 @@ func (vm *vmMock) Run(ctx fvm.Context, proc fvm.Procedure, led state.View) error
426426
return nil
427427
}
428428

429-
func (vmMock) GetAccount(_ fvm.Context, _ flow.Address, _ state.View) (*flow.Account, error) {
429+
func (vmMock) GetAccount(
430+
_ fvm.Context,
431+
_ flow.Address,
432+
_ state.StorageSnapshot,
433+
) (
434+
*flow.Account,
435+
error) {
430436
panic("not expected")
431437
}
432438

@@ -483,7 +489,14 @@ func (vm *vmSystemOkMock) Run(ctx fvm.Context, proc fvm.Procedure, led state.Vie
483489
return nil
484490
}
485491

486-
func (vmSystemOkMock) GetAccount(_ fvm.Context, _ flow.Address, _ state.View) (*flow.Account, error) {
492+
func (vmSystemOkMock) GetAccount(
493+
_ fvm.Context,
494+
_ flow.Address,
495+
_ state.StorageSnapshot,
496+
) (
497+
*flow.Account,
498+
error,
499+
) {
487500
panic("not expected")
488501
}
489502

@@ -528,6 +541,13 @@ func (vm *vmSystemBadMock) Run(ctx fvm.Context, proc fvm.Procedure, led state.Vi
528541
return nil
529542
}
530543

531-
func (vmSystemBadMock) GetAccount(_ fvm.Context, _ flow.Address, _ state.View) (*flow.Account, error) {
544+
func (vmSystemBadMock) GetAccount(
545+
_ fvm.Context,
546+
_ flow.Address,
547+
_ state.StorageSnapshot,
548+
) (
549+
*flow.Account,
550+
error,
551+
) {
532552
panic("not expected")
533553
}

0 commit comments

Comments
 (0)