Skip to content

Commit 857f733

Browse files
Merge #4175
4175: Misc. delta view cleanup r=pattyshack a=pattyshack Co-authored-by: Patrick Lee <[email protected]>
2 parents c7d0a2c + d87ae06 commit 857f733

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

engine/execution/computation/computer/result_collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type resultCollector struct {
7777
blockStats module.ExecutionResultStats
7878

7979
currentCollectionStartTime time.Time
80-
currentCollectionView *delta.View
80+
currentCollectionView state.View
8181
currentCollectionStats module.ExecutionResultStats
8282
}
8383

fvm/fvm_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616

1717
"github.com/onflow/flow-go/crypto"
1818

19-
"github.com/onflow/flow-go/engine/execution/state/delta"
2019
"github.com/onflow/flow-go/engine/execution/testutil"
2120
exeUtils "github.com/onflow/flow-go/engine/execution/utils"
2221
"github.com/onflow/flow-go/fvm"
@@ -25,6 +24,7 @@ import (
2524
errors "github.com/onflow/flow-go/fvm/errors"
2625
"github.com/onflow/flow-go/fvm/meter"
2726
reusableRuntime "github.com/onflow/flow-go/fvm/runtime"
27+
"github.com/onflow/flow-go/fvm/state"
2828
"github.com/onflow/flow-go/fvm/storage"
2929
"github.com/onflow/flow-go/model/flow"
3030
"github.com/onflow/flow-go/utils/unittest"
@@ -1488,15 +1488,15 @@ func TestStorageUsed(t *testing.T) {
14881488
accountStatusId := flow.AccountStatusRegisterID(
14891489
flow.BytesToAddress(address))
14901490

1491-
simpleView := delta.NewDeltaView(nil)
14921491
status := environment.NewAccountStatus()
14931492
status.SetStorageUsed(5)
1494-
err = simpleView.Set(accountStatusId, status.ToBytes())
1495-
require.NoError(t, err)
1496-
1497-
script := fvm.Script(code)
14981493

1499-
_, output, err := vm.RunV2(ctx, script, simpleView)
1494+
_, output, err := vm.RunV2(
1495+
ctx,
1496+
fvm.Script(code),
1497+
state.MapStorageSnapshot{
1498+
accountStatusId: status.ToBytes(),
1499+
})
15001500
require.NoError(t, err)
15011501

15021502
require.Equal(t, cadence.NewUInt64(5), output.Value)

fvm/state/execution_state.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
// it holds draft of updates and captures
2222
// all register touches
2323
type ExecutionState struct {
24-
// NOTE: A finalized view is no longer accessible. It can however be
24+
// NOTE: A finalized state is no longer accessible. It can however be
2525
// re-attached to another transaction and be committed (for cached result
2626
// bookkeeping purpose).
2727
finalized bool
@@ -144,7 +144,7 @@ func (state *ExecutionState) BytesWritten() uint64 {
144144

145145
func (state *ExecutionState) DropChanges() error {
146146
if state.finalized {
147-
return fmt.Errorf("cannot DropChanges on a finalized view")
147+
return fmt.Errorf("cannot DropChanges on a finalized state")
148148
}
149149

150150
return state.view.DropChanges()
@@ -153,7 +153,7 @@ func (state *ExecutionState) DropChanges() error {
153153
// Get returns a register value given owner and key
154154
func (state *ExecutionState) Get(id flow.RegisterID) (flow.RegisterValue, error) {
155155
if state.finalized {
156-
return nil, fmt.Errorf("cannot Get on a finalized view")
156+
return nil, fmt.Errorf("cannot Get on a finalized state")
157157
}
158158

159159
var value []byte
@@ -179,7 +179,7 @@ func (state *ExecutionState) Get(id flow.RegisterID) (flow.RegisterValue, error)
179179
// Set updates state delta with a register update
180180
func (state *ExecutionState) Set(id flow.RegisterID, value flow.RegisterValue) error {
181181
if state.finalized {
182-
return fmt.Errorf("cannot Set on a finalized view")
182+
return fmt.Errorf("cannot Set on a finalized state")
183183
}
184184

185185
if state.enforceLimits {
@@ -201,7 +201,7 @@ func (state *ExecutionState) Set(id flow.RegisterID, value flow.RegisterValue) e
201201
// MeterComputation meters computation usage
202202
func (state *ExecutionState) MeterComputation(kind common.ComputationKind, intensity uint) error {
203203
if state.finalized {
204-
return fmt.Errorf("cannot MeterComputation on a finalized view")
204+
return fmt.Errorf("cannot MeterComputation on a finalized state")
205205
}
206206

207207
if state.enforceLimits {
@@ -228,7 +228,7 @@ func (state *ExecutionState) TotalComputationLimit() uint {
228228
// MeterMemory meters memory usage
229229
func (state *ExecutionState) MeterMemory(kind common.MemoryKind, intensity uint) error {
230230
if state.finalized {
231-
return fmt.Errorf("cannot MeterMemory on a finalized view")
231+
return fmt.Errorf("cannot MeterMemory on a finalized state")
232232
}
233233

234234
if state.enforceLimits {
@@ -255,7 +255,7 @@ func (state *ExecutionState) TotalMemoryLimit() uint {
255255

256256
func (state *ExecutionState) MeterEmittedEvent(byteSize uint64) error {
257257
if state.finalized {
258-
return fmt.Errorf("cannot MeterEmittedEvent on a finalized view")
258+
return fmt.Errorf("cannot MeterEmittedEvent on a finalized state")
259259
}
260260

261261
if state.enforceLimits {
@@ -279,7 +279,7 @@ func (state *ExecutionState) Finalize() *ExecutionSnapshot {
279279
// MergeState the changes from a the given view to this view.
280280
func (state *ExecutionState) Merge(other *ExecutionSnapshot) error {
281281
if state.finalized {
282-
return fmt.Errorf("cannot Merge on a finalized view")
282+
return fmt.Errorf("cannot Merge on a finalized state")
283283
}
284284

285285
err := state.view.Merge(other)

fvm/state/transaction_state_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,5 +568,5 @@ func TestFinalizeMainTransaction(t *testing.T) {
568568

569569
// Sanity check state is no longer accessible after FinalizeMainTransaction.
570570
_, err = txn.Get(registerId)
571-
require.ErrorContains(t, err, "cannot Get on a finalized view")
571+
require.ErrorContains(t, err, "cannot Get on a finalized state")
572572
}

0 commit comments

Comments
 (0)