Skip to content

Commit a16142d

Browse files
Merge #4183 #4184
4183: Clean up emulator dead code r=pattyshack a=pattyshack 4184: rename RunV2 to Run r=pattyshack a=pattyshack Co-authored-by: Patrick Lee <[email protected]>
3 parents 2dde9fd + a492016 + 808249f commit a16142d

26 files changed

+207
-360
lines changed

cmd/execution_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ func getContractEpochCounter(
11011101
script := fvm.Script(scriptCode)
11021102

11031103
// execute the script
1104-
_, output, err := vm.RunV2(vmCtx, script, snapshot)
1104+
_, output, err := vm.Run(vmCtx, script, snapshot)
11051105
if err != nil {
11061106
return 0, fmt.Errorf("could not read epoch counter, internal error while executing script: %w", err)
11071107
}

cmd/util/ledger/reporters/account_reporter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func (c *balanceProcessor) balance(address flow.Address) (uint64, bool, error) {
320320
jsoncdc.MustEncode(cadence.NewAddress(address)),
321321
)
322322

323-
_, output, err := c.vm.RunV2(c.ctx, script, c.storageSnapshot)
323+
_, output, err := c.vm.Run(c.ctx, script, c.storageSnapshot)
324324
if err != nil {
325325
return 0, false, err
326326
}
@@ -341,7 +341,7 @@ func (c *balanceProcessor) fusdBalance(address flow.Address) (uint64, error) {
341341
jsoncdc.MustEncode(cadence.NewAddress(address)),
342342
)
343343

344-
_, output, err := c.vm.RunV2(c.ctx, script, c.storageSnapshot)
344+
_, output, err := c.vm.Run(c.ctx, script, c.storageSnapshot)
345345
if err != nil {
346346
return 0, err
347347
}
@@ -358,7 +358,7 @@ func (c *balanceProcessor) moments(address flow.Address) (int, error) {
358358
jsoncdc.MustEncode(cadence.NewAddress(address)),
359359
)
360360

361-
_, output, err := c.vm.RunV2(c.ctx, script, c.storageSnapshot)
361+
_, output, err := c.vm.Run(c.ctx, script, c.storageSnapshot)
362362
if err != nil {
363363
return 0, err
364364
}

cmd/util/ledger/reporters/fungible_token_tracker_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestFungibleTokenTracker(t *testing.T) {
6262
fvm.WithInitialTokenSupply(unittest.GenesisTokenSupply),
6363
}
6464

65-
snapshot, _, err := vm.RunV2(ctx, fvm.Bootstrap(unittest.ServiceAccountPublicKey, bootstrapOptions...), view)
65+
snapshot, _, err := vm.Run(ctx, fvm.Bootstrap(unittest.ServiceAccountPublicKey, bootstrapOptions...), view)
6666
require.NoError(t, err)
6767

6868
err = view.Merge(snapshot)
@@ -101,7 +101,7 @@ func TestFungibleTokenTracker(t *testing.T) {
101101
AddAuthorizer(chain.ServiceAddress())
102102

103103
tx := fvm.Transaction(txBody, 0)
104-
snapshot, output, err := vm.RunV2(ctx, tx, view)
104+
snapshot, output, err := vm.Run(ctx, tx, view)
105105
require.NoError(t, err)
106106
require.NoError(t, output.Err)
107107

@@ -130,7 +130,7 @@ func TestFungibleTokenTracker(t *testing.T) {
130130
AddAuthorizer(chain.ServiceAddress())
131131

132132
tx = fvm.Transaction(txBody, 0)
133-
snapshot, output, err = vm.RunV2(ctx, tx, view)
133+
snapshot, output, err = vm.Run(ctx, tx, view)
134134
require.NoError(t, err)
135135
require.NoError(t, output.Err)
136136

engine/execution/computation/computer/computer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func (e *blockComputer) executeTransaction(
385385

386386
txn.ctx = fvm.NewContextFromParent(txn.ctx, fvm.WithSpan(txSpan))
387387

388-
executionSnapshot, output, err := e.vm.RunV2(
388+
executionSnapshot, output, err := e.vm.Run(
389389
txn.ctx,
390390
txn.TransactionProcedure,
391391
storageSnapshot)

engine/execution/computation/computer/computer_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func TestBlockExecutor_ExecuteBlock(t *testing.T) {
305305
block := generateBlock(0, 0, rag)
306306
derivedBlockData := derived.NewEmptyDerivedBlockData()
307307

308-
vm.On("RunV2", mock.Anything, mock.Anything, mock.Anything).
308+
vm.On("Run", mock.Anything, mock.Anything, mock.Anything).
309309
Return(
310310
&state.ExecutionSnapshot{},
311311
fvm.ProcedureOutput{},
@@ -367,7 +367,7 @@ func TestBlockExecutor_ExecuteBlock(t *testing.T) {
367367
fvm.WithInitialTokenSupply(unittest.GenesisTokenSupply),
368368
}
369369
bootstrapOpts := append(baseBootstrapOpts, bootstrapOptions...)
370-
executionSnapshot, _, err := vm.RunV2(
370+
executionSnapshot, _, err := vm.Run(
371371
ctx,
372372
fvm.Bootstrap(unittest.ServiceAccountPublicKey, bootstrapOpts...),
373373
snapshotTree)
@@ -1171,7 +1171,7 @@ type testVM struct {
11711171
err fvmErrors.CodedError
11721172
}
11731173

1174-
func (vm *testVM) RunV2(
1174+
func (vm *testVM) Run(
11751175
ctx fvm.Context,
11761176
proc fvm.Procedure,
11771177
storageSnapshot state.StorageSnapshot,
@@ -1200,10 +1200,6 @@ func (vm *testVM) RunV2(
12001200
return snapshot, output, nil
12011201
}
12021202

1203-
func (testVM) Run(_ fvm.Context, _ fvm.Procedure, _ state.View) error {
1204-
panic("not implemented")
1205-
}
1206-
12071203
func (testVM) GetAccount(
12081204
_ fvm.Context,
12091205
_ flow.Address,

engine/execution/computation/manager_benchmark_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func mustFundAccounts(
9797
tx := fvm.Transaction(
9898
transferTx,
9999
derivedBlockData.NextTxIndexForTestingOnly())
100-
executionSnapshot, output, err := vm.RunV2(execCtx, tx, snapshotTree)
100+
executionSnapshot, output, err := vm.Run(execCtx, tx, snapshotTree)
101101
require.NoError(b, err)
102102
require.NoError(b, output.Err)
103103
snapshotTree = snapshotTree.Append(executionSnapshot)

engine/execution/computation/manager_test.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ func TestExecuteScript_ShortScriptsAreNotLogged(t *testing.T) {
503503

504504
type PanickingVM struct{}
505505

506-
func (p *PanickingVM) RunV2(
506+
func (p *PanickingVM) Run(
507507
f fvm.Context,
508508
procedure fvm.Procedure,
509509
storageSnapshot state.StorageSnapshot,
@@ -515,10 +515,6 @@ func (p *PanickingVM) RunV2(
515515
panic("panic, but expected with sentinel for test: Verunsicherung ")
516516
}
517517

518-
func (p *PanickingVM) Run(f fvm.Context, procedure fvm.Procedure, view state.View) error {
519-
panic("panic, but expected with sentinel for test: Verunsicherung ")
520-
}
521-
522518
func (p *PanickingVM) GetAccount(
523519
ctx fvm.Context,
524520
address flow.Address,
@@ -534,7 +530,7 @@ type LongRunningVM struct {
534530
duration time.Duration
535531
}
536532

537-
func (l *LongRunningVM) RunV2(
533+
func (l *LongRunningVM) Run(
538534
f fvm.Context,
539535
procedure fvm.Procedure,
540536
storageSnapshot state.StorageSnapshot,
@@ -552,16 +548,6 @@ func (l *LongRunningVM) RunV2(
552548
return snapshot, output, nil
553549
}
554550

555-
func (l *LongRunningVM) Run(f fvm.Context, procedure fvm.Procedure, view state.View) error {
556-
time.Sleep(l.duration)
557-
// satisfy value marshaller
558-
if scriptProcedure, is := procedure.(*fvm.ScriptProcedure); is {
559-
scriptProcedure.Value = cadence.NewVoid()
560-
}
561-
562-
return nil
563-
}
564-
565551
func (l *LongRunningVM) GetAccount(
566552
ctx fvm.Context,
567553
address flow.Address,

engine/execution/computation/query/executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (e *QueryExecutor) ExecuteScript(
159159
}()
160160

161161
var output fvm.ProcedureOutput
162-
_, output, err = e.vm.RunV2(
162+
_, output, err = e.vm.Run(
163163
fvm.NewContextFromParent(
164164
e.vmCtx,
165165
fvm.WithBlockHeader(blockHeader),

engine/execution/state/bootstrap/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (b *Bootstrapper) BootstrapLedger(
5353
opts...,
5454
)
5555

56-
executionSnapshot, _, err := vm.RunV2(ctx, bootstrap, storageSnapshot)
56+
executionSnapshot, _, err := vm.Run(ctx, bootstrap, storageSnapshot)
5757
if err != nil {
5858
return flow.DummyStateCommitment, err
5959
}

engine/execution/testutil/fixtures.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ func CreateAccountsWithSimpleAddresses(
259259
AddAuthorizer(serviceAddress)
260260

261261
tx := fvm.Transaction(txBody, 0)
262-
executionSnapshot, output, err := vm.RunV2(ctx, tx, snapshotTree)
262+
executionSnapshot, output, err := vm.Run(ctx, tx, snapshotTree)
263263
if err != nil {
264264
return snapshotTree, nil, err
265265
}
@@ -317,7 +317,7 @@ func RootBootstrappedLedger(
317317
options...,
318318
)
319319

320-
snapshot, _, err := vm.RunV2(ctx, bootstrap, nil)
320+
snapshot, _, err := vm.Run(ctx, bootstrap, nil)
321321
if err != nil {
322322
panic(err)
323323
}

0 commit comments

Comments
 (0)