diff --git a/pkg/protocol/engine/ledger/ledger/vm.go b/pkg/protocol/engine/ledger/ledger/vm.go index 20eb5bf3a..8e4ef5d94 100644 --- a/pkg/protocol/engine/ledger/ledger/vm.go +++ b/pkg/protocol/engine/ledger/ledger/vm.go @@ -21,7 +21,7 @@ func NewVM(ledger *Ledger) *VM { } } -func (v *VM) TransactionInputs(transaction mempool.Transaction) (inputReferences []iotago.Input, err error) { +func (v *VM) StateReferences(transaction mempool.Transaction) (inputReferences []iotago.Input, err error) { stardustTransaction, ok := transaction.(*iotago.Transaction) if !ok { return nil, iotago.ErrTxTypeInvalid @@ -143,7 +143,7 @@ func (v *VM) ValidateSignatures(signedTransaction mempool.SignedTransaction, res return executionContext, nil } -func (v *VM) ExecuteTransaction(executionContext context.Context, transaction mempool.Transaction) (outputs []mempool.State, err error) { +func (v *VM) Execute(executionContext context.Context, transaction mempool.Transaction) (outputs []mempool.State, err error) { stardustTransaction, ok := transaction.(*iotago.Transaction) if !ok { return nil, iotago.ErrTxTypeInvalid diff --git a/pkg/protocol/engine/mempool/mempool.go b/pkg/protocol/engine/mempool/mempool.go index 4f4bb8e18..d9b611009 100644 --- a/pkg/protocol/engine/mempool/mempool.go +++ b/pkg/protocol/engine/mempool/mempool.go @@ -15,7 +15,7 @@ type MemPool[VoteRank conflictdag.VoteRankType[VoteRank]] interface { MarkAttachmentIncluded(blockID iotago.BlockID) bool - StateMetadata(reference iotago.Input) (state StateMetadata, err error) + StateMetadata(reference StateReference) (state StateMetadata, err error) TransactionMetadata(id iotago.TransactionID) (transaction TransactionMetadata, exists bool) diff --git a/pkg/protocol/engine/mempool/state_metadata.go b/pkg/protocol/engine/mempool/state_metadata.go index 6227fd432..1a8b8cb2e 100644 --- a/pkg/protocol/engine/mempool/state_metadata.go +++ b/pkg/protocol/engine/mempool/state_metadata.go @@ -6,8 +6,6 @@ import ( ) type StateMetadata interface { - StateID() StateID - State() State ConflictIDs() reactive.Set[iotago.TransactionID] diff --git a/pkg/protocol/engine/mempool/state_reference.go b/pkg/protocol/engine/mempool/state_reference.go index 9c9de8d7e..37e7f596e 100644 --- a/pkg/protocol/engine/mempool/state_reference.go +++ b/pkg/protocol/engine/mempool/state_reference.go @@ -1,9 +1,5 @@ package mempool -import ( - "github.com/iotaledger/iota-core/pkg/core/promise" - iotago "github.com/iotaledger/iota.go/v4" -) +import iotago "github.com/iotaledger/iota.go/v4" -// StateReferenceResolver is a function that resolves a StateReference to a State. -type StateReferenceResolver func(reference iotago.Input) *promise.Promise[State] +type StateReference = iotago.Input diff --git a/pkg/protocol/engine/mempool/state_resolver.go b/pkg/protocol/engine/mempool/state_resolver.go new file mode 100644 index 000000000..0102800ff --- /dev/null +++ b/pkg/protocol/engine/mempool/state_resolver.go @@ -0,0 +1,8 @@ +package mempool + +import ( + "github.com/iotaledger/iota-core/pkg/core/promise" +) + +// StateResolver is a function that resolves a StateReference to a Promise with the State. +type StateResolver func(reference StateReference) *promise.Promise[State] diff --git a/pkg/protocol/engine/mempool/tests/testframework.go b/pkg/protocol/engine/mempool/tests/testframework.go index 57451f283..02125a3b3 100644 --- a/pkg/protocol/engine/mempool/tests/testframework.go +++ b/pkg/protocol/engine/mempool/tests/testframework.go @@ -22,7 +22,7 @@ type TestFramework struct { Instance mempool.MemPool[vote.MockedRank] ConflictDAG conflictdag.ConflictDAG[iotago.TransactionID, mempool.StateID, vote.MockedRank] - referencesByAlias map[string]iotago.Input + referencesByAlias map[string]mempool.StateReference stateIDByAlias map[string]mempool.StateID signedTransactionByAlias map[string]mempool.SignedTransaction transactionByAlias map[string]mempool.Transaction @@ -39,7 +39,7 @@ func NewTestFramework(test *testing.T, instance mempool.MemPool[vote.MockedRank] t := &TestFramework{ Instance: instance, ConflictDAG: conflictDAG, - referencesByAlias: make(map[string]iotago.Input), + referencesByAlias: make(map[string]mempool.StateReference), stateIDByAlias: make(map[string]mempool.StateID), signedTransactionByAlias: make(map[string]mempool.SignedTransaction), transactionByAlias: make(map[string]mempool.Transaction), @@ -311,7 +311,7 @@ func (t *TestFramework) setupHookedEvents() { }) } -func (t *TestFramework) stateReference(alias string) iotago.Input { +func (t *TestFramework) stateReference(alias string) mempool.StateReference { if alias == "genesis" { return &iotago.UTXOInput{} } @@ -393,7 +393,7 @@ func (t *TestFramework) Cleanup() { iotago.UnregisterIdentifierAliases() - t.referencesByAlias = make(map[string]iotago.Input) + t.referencesByAlias = make(map[string]mempool.StateReference) t.stateIDByAlias = make(map[string]mempool.StateID) t.transactionByAlias = make(map[string]mempool.Transaction) t.signedTransactionByAlias = make(map[string]mempool.SignedTransaction) diff --git a/pkg/protocol/engine/mempool/tests/transaction.go b/pkg/protocol/engine/mempool/tests/transaction.go index a21fb2523..0726b032b 100644 --- a/pkg/protocol/engine/mempool/tests/transaction.go +++ b/pkg/protocol/engine/mempool/tests/transaction.go @@ -21,7 +21,7 @@ func (s *SignedTransaction) String() string { type Transaction struct { id iotago.TransactionID - inputs []iotago.Input + inputs []mempool.StateReference outputCount uint16 invalidTransaction bool } @@ -33,7 +33,7 @@ func NewSignedTransaction(transaction mempool.Transaction) *SignedTransaction { } } -func NewTransaction(outputCount uint16, inputs ...iotago.Input) *Transaction { +func NewTransaction(outputCount uint16, inputs ...mempool.StateReference) *Transaction { return &Transaction{ id: tpkg.RandTransactionID(), inputs: inputs, @@ -45,7 +45,7 @@ func (t *Transaction) ID() (iotago.TransactionID, error) { return t.id, nil } -func (t *Transaction) Inputs() ([]iotago.Input, error) { +func (t *Transaction) Inputs() ([]mempool.StateReference, error) { return t.inputs, nil } diff --git a/pkg/protocol/engine/mempool/tests/vm.go b/pkg/protocol/engine/mempool/tests/vm.go index b8f91a84a..594e49d5f 100644 --- a/pkg/protocol/engine/mempool/tests/vm.go +++ b/pkg/protocol/engine/mempool/tests/vm.go @@ -6,12 +6,11 @@ import ( "github.com/iotaledger/hive.go/ierrors" ledgertests "github.com/iotaledger/iota-core/pkg/protocol/engine/ledger/tests" "github.com/iotaledger/iota-core/pkg/protocol/engine/mempool" - iotago "github.com/iotaledger/iota.go/v4" ) type VM struct{} -func (V *VM) TransactionInputs(transaction mempool.Transaction) ([]iotago.Input, error) { +func (V *VM) StateReferences(transaction mempool.Transaction) ([]mempool.StateReference, error) { return transaction.(*Transaction).Inputs() } @@ -19,7 +18,7 @@ func (V *VM) ValidateSignatures(signedTransaction mempool.SignedTransaction, res return context.Background(), nil } -func (V *VM) ExecuteTransaction(executionContext context.Context, transaction mempool.Transaction) (outputs []mempool.State, err error) { +func (V *VM) Execute(executionContext context.Context, transaction mempool.Transaction) (outputs []mempool.State, err error) { typedTransaction, ok := transaction.(*Transaction) if !ok { return nil, ierrors.New("invalid transaction type in MockedVM") diff --git a/pkg/protocol/engine/mempool/v1/mempool.go b/pkg/protocol/engine/mempool/v1/mempool.go index 76a9f677f..83a9a763d 100644 --- a/pkg/protocol/engine/mempool/v1/mempool.go +++ b/pkg/protocol/engine/mempool/v1/mempool.go @@ -25,7 +25,7 @@ type MemPool[VoteRank conflictdag.VoteRankType[VoteRank]] struct { vm mempool.VM // resolveState is the function that is used to request state from the ledger. - resolveState mempool.StateReferenceResolver + resolveState mempool.StateResolver // attachments is the storage that is used to keep track of the attachments of transactions. attachments *memstorage.IndexedStorage[iotago.SlotIndex, iotago.BlockID, *SignedTransactionMetadata] @@ -66,7 +66,7 @@ type MemPool[VoteRank conflictdag.VoteRankType[VoteRank]] struct { // New is the constructor of the MemPool. func New[VoteRank conflictdag.VoteRankType[VoteRank]]( vm mempool.VM, - stateResolver mempool.StateReferenceResolver, + stateResolver mempool.StateResolver, workers *workerpool.Group, conflictDAG conflictdag.ConflictDAG[iotago.TransactionID, mempool.StateID, VoteRank], errorHandler func(error), @@ -128,7 +128,7 @@ func (m *MemPool[VoteRank]) TransactionMetadata(id iotago.TransactionID) (transa } // StateMetadata returns the metadata of the output state with the given ID. -func (m *MemPool[VoteRank]) StateMetadata(stateReference iotago.Input) (state mempool.StateMetadata, err error) { +func (m *MemPool[VoteRank]) StateMetadata(stateReference mempool.StateReference) (state mempool.StateMetadata, err error) { stateRequest, exists := m.cachedStateRequests.Get(stateReference.StateID()) // create a new request that does not wait for missing states @@ -190,7 +190,7 @@ func (m *MemPool[VoteRank]) storeTransaction(signedTransaction mempool.SignedTra return nil, false, false, ierrors.Errorf("blockID %d is older than last evicted slot %d", blockID.Slot(), m.lastEvictedSlot) } - inputReferences, err := m.vm.TransactionInputs(transaction) + inputReferences, err := m.vm.StateReferences(transaction) if err != nil { return nil, false, false, ierrors.Wrap(err, "failed to get input references of transaction") } @@ -249,7 +249,7 @@ func (m *MemPool[VoteRank]) solidifyInputs(transaction *TransactionMetadata) { func (m *MemPool[VoteRank]) executeTransaction(executionContext context.Context, transaction *TransactionMetadata) { m.executionWorkers.Submit(func() { - if outputStates, err := m.vm.ExecuteTransaction(executionContext, transaction.Transaction()); err != nil { + if outputStates, err := m.vm.Execute(executionContext, transaction.Transaction()); err != nil { transaction.setInvalid(err) } else { transaction.setExecuted(outputStates) @@ -261,11 +261,13 @@ func (m *MemPool[VoteRank]) executeTransaction(executionContext context.Context, func (m *MemPool[VoteRank]) bookTransaction(transaction *TransactionMetadata) { if m.optForkAllTransactions { - m.forkTransaction(transaction, ds.NewSet(lo.Map(transaction.inputs, (*StateMetadata).StateID)...)) + m.forkTransaction(transaction, ds.NewSet(lo.Map(transaction.inputs, func(stateMetadata *StateMetadata) mempool.StateID { + return stateMetadata.state.StateID() + })...)) } else { lo.ForEach(transaction.inputs, func(input *StateMetadata) { input.OnDoubleSpent(func() { - m.forkTransaction(transaction, ds.NewSet(input.StateID())) + m.forkTransaction(transaction, ds.NewSet(input.state.StateID())) }) }) } @@ -287,7 +289,7 @@ func (m *MemPool[VoteRank]) forkTransaction(transactionMetadata *TransactionMeta func (m *MemPool[VoteRank]) publishOutputStates(transaction *TransactionMetadata) { for _, output := range transaction.outputs { - stateRequest, isNew := m.cachedStateRequests.GetOrCreate(output.StateID(), lo.NoVariadic(promise.New[*StateMetadata])) + stateRequest, isNew := m.cachedStateRequests.GetOrCreate(output.State().StateID(), lo.NoVariadic(promise.New[*StateMetadata])) stateRequest.Resolve(output) if isNew { @@ -296,7 +298,7 @@ func (m *MemPool[VoteRank]) publishOutputStates(transaction *TransactionMetadata } } -func (m *MemPool[VoteRank]) requestState(stateRef iotago.Input, waitIfMissing ...bool) *promise.Promise[*StateMetadata] { +func (m *MemPool[VoteRank]) requestState(stateRef mempool.StateReference, waitIfMissing ...bool) *promise.Promise[*StateMetadata] { return promise.New(func(p *promise.Promise[*StateMetadata]) { request := m.resolveState(stateRef) @@ -430,15 +432,15 @@ func (m *MemPool[VoteRank]) setupTransaction(transaction *TransactionMetadata) { }) } -func (m *MemPool[VoteRank]) setupOutputState(state *StateMetadata) { - state.OnCommitted(func() { - if !m.cachedStateRequests.Delete(state.StateID(), state.HasNoSpenders) && m.cachedStateRequests.Has(state.StateID()) { - state.onAllSpendersRemoved(func() { m.cachedStateRequests.Delete(state.StateID(), state.HasNoSpenders) }) +func (m *MemPool[VoteRank]) setupOutputState(stateMetadata *StateMetadata) { + stateMetadata.OnCommitted(func() { + if !m.cachedStateRequests.Delete(stateMetadata.state.StateID(), stateMetadata.HasNoSpenders) && m.cachedStateRequests.Has(stateMetadata.state.StateID()) { + stateMetadata.onAllSpendersRemoved(func() { m.cachedStateRequests.Delete(stateMetadata.state.StateID(), stateMetadata.HasNoSpenders) }) } }) - state.OnOrphaned(func() { - m.cachedStateRequests.Delete(state.StateID()) + stateMetadata.OnOrphaned(func() { + m.cachedStateRequests.Delete(stateMetadata.state.StateID()) }) } diff --git a/pkg/protocol/engine/mempool/v1/mempool_test.go b/pkg/protocol/engine/mempool/v1/mempool_test.go index a79ff1068..c4f64dee2 100644 --- a/pkg/protocol/engine/mempool/v1/mempool_test.go +++ b/pkg/protocol/engine/mempool/v1/mempool_test.go @@ -34,11 +34,11 @@ func TestMempoolV1_ResourceCleanup(t *testing.T) { ledgerState := ledgertests.New(ledgertests.NewMockedState(iotago.TransactionID{}, 0)) conflictDAG := conflictdagv1.New[iotago.TransactionID, mempool.StateID, vote.MockedRank](func() int { return 0 }) - mempoolInstance := New[vote.MockedRank](new(mempooltests.VM), func(reference iotago.Input) *promise.Promise[mempool.State] { + memPoolInstance := New[vote.MockedRank](new(mempooltests.VM), func(reference mempool.StateReference) *promise.Promise[mempool.State] { return ledgerState.ResolveOutputState(reference.StateID()) }, workers, conflictDAG, func(error) {}) - tf := mempooltests.NewTestFramework(t, mempoolInstance, conflictDAG, ledgerState, workers) + tf := mempooltests.NewTestFramework(t, memPoolInstance, conflictDAG, ledgerState, workers) issueTransactions := func(startIndex, transactionCount int, prevStateAlias string) (int, string) { index := startIndex @@ -58,7 +58,7 @@ func TestMempoolV1_ResourceCleanup(t *testing.T) { tf.CommitSlot(iotago.SlotIndex(index)) tf.Instance.Evict(iotago.SlotIndex(index)) - require.Nil(t, mempoolInstance.attachments.Get(iotago.SlotIndex(index), false)) + require.Nil(t, memPoolInstance.attachments.Get(iotago.SlotIndex(index), false)) } return index, prevStateAlias @@ -70,19 +70,19 @@ func TestMempoolV1_ResourceCleanup(t *testing.T) { txIndex, prevStateAlias := issueTransactions(1, 10, "genesis") tf.WaitChildren() - require.Equal(t, 0, mempoolInstance.cachedTransactions.Size()) - require.Equal(t, 0, mempoolInstance.stateDiffs.Size()) - require.Equal(t, 0, mempoolInstance.cachedStateRequests.Size()) + require.Equal(t, 0, memPoolInstance.cachedTransactions.Size()) + require.Equal(t, 0, memPoolInstance.stateDiffs.Size()) + require.Equal(t, 0, memPoolInstance.cachedStateRequests.Size()) txIndex, prevStateAlias = issueTransactions(txIndex, 10, prevStateAlias) tf.WaitChildren() - require.Equal(t, 0, mempoolInstance.cachedTransactions.Size()) - require.Equal(t, 0, mempoolInstance.stateDiffs.Size()) - require.Equal(t, 0, mempoolInstance.cachedStateRequests.Size()) + require.Equal(t, 0, memPoolInstance.cachedTransactions.Size()) + require.Equal(t, 0, memPoolInstance.stateDiffs.Size()) + require.Equal(t, 0, memPoolInstance.cachedStateRequests.Size()) attachmentsSlotCount := 0 - mempoolInstance.attachments.ForEach(func(index iotago.SlotIndex, storage *shrinkingmap.ShrinkingMap[iotago.BlockID, *SignedTransactionMetadata]) { + memPoolInstance.attachments.ForEach(func(index iotago.SlotIndex, storage *shrinkingmap.ShrinkingMap[iotago.BlockID, *SignedTransactionMetadata]) { attachmentsSlotCount++ }) @@ -103,7 +103,7 @@ func newTestFramework(t *testing.T) *mempooltests.TestFramework { ledgerState := ledgertests.New(ledgertests.NewMockedState(iotago.TransactionID{}, 0)) conflictDAG := conflictdagv1.New[iotago.TransactionID, mempool.StateID, vote.MockedRank](account.NewAccounts().SelectCommittee().SeatCount) - return mempooltests.NewTestFramework(t, New[vote.MockedRank](new(mempooltests.VM), func(reference iotago.Input) *promise.Promise[mempool.State] { + return mempooltests.NewTestFramework(t, New[vote.MockedRank](new(mempooltests.VM), func(reference mempool.StateReference) *promise.Promise[mempool.State] { return ledgerState.ResolveOutputState(reference.StateID()) }, workers, conflictDAG, func(error) {}), conflictDAG, ledgerState, workers) } @@ -114,7 +114,7 @@ func newForkingTestFramework(t *testing.T) *mempooltests.TestFramework { ledgerState := ledgertests.New(ledgertests.NewMockedState(iotago.TransactionID{}, 0)) conflictDAG := conflictdagv1.New[iotago.TransactionID, mempool.StateID, vote.MockedRank](account.NewAccounts().SelectCommittee().SeatCount) - return mempooltests.NewTestFramework(t, New[vote.MockedRank](new(mempooltests.VM), func(reference iotago.Input) *promise.Promise[mempool.State] { + return mempooltests.NewTestFramework(t, New[vote.MockedRank](new(mempooltests.VM), func(reference mempool.StateReference) *promise.Promise[mempool.State] { return ledgerState.ResolveOutputState(reference.StateID()) }, workers, conflictDAG, func(error) {}, WithForkAllTransactions[vote.MockedRank](true)), conflictDAG, ledgerState, workers) } diff --git a/pkg/protocol/engine/mempool/v1/state_diff.go b/pkg/protocol/engine/mempool/v1/state_diff.go index b152f489d..f9efc845d 100644 --- a/pkg/protocol/engine/mempool/v1/state_diff.go +++ b/pkg/protocol/engine/mempool/v1/state_diff.go @@ -56,17 +56,17 @@ func (s *StateDiff) Mutations() ads.Set[iotago.TransactionID] { } func (s *StateDiff) updateCompactedStateChanges(transaction *TransactionMetadata, direction int) { - transaction.Inputs().Range(func(input mempool.StateMetadata) { - s.compactStateChanges(input, s.stateUsageCounters.Compute(input.StateID(), func(currentValue int, _ bool) int { + for _, input := range transaction.inputs { + s.compactStateChanges(input, s.stateUsageCounters.Compute(input.State().StateID(), func(currentValue int, _ bool) int { return currentValue - direction })) - }) + } - transaction.Outputs().Range(func(output mempool.StateMetadata) { - s.compactStateChanges(output, s.stateUsageCounters.Compute(output.StateID(), func(currentValue int, _ bool) int { + for _, output := range transaction.outputs { + s.compactStateChanges(output, s.stateUsageCounters.Compute(output.State().StateID(), func(currentValue int, _ bool) int { return currentValue + direction })) - }) + } } func (s *StateDiff) AddTransaction(transaction *TransactionMetadata, errorHandler func(error)) error { @@ -97,19 +97,19 @@ func (s *StateDiff) RollbackTransaction(transaction *TransactionMetadata) error return nil } -func (s *StateDiff) compactStateChanges(output mempool.StateMetadata, newValue int) { - if output.State().Type() != iotago.InputUTXO { +func (s *StateDiff) compactStateChanges(output *StateMetadata, newValue int) { + if output.state.Type() != iotago.InputUTXO { return } switch { case newValue > 0: - s.createdOutputs.Set(output.StateID(), output) + s.createdOutputs.Set(output.State().StateID(), output) case newValue < 0: - s.spentOutputs.Set(output.StateID(), output) + s.spentOutputs.Set(output.State().StateID(), output) default: - s.createdOutputs.Delete(output.StateID()) - s.spentOutputs.Delete(output.StateID()) + s.createdOutputs.Delete(output.State().StateID()) + s.spentOutputs.Delete(output.State().StateID()) } } diff --git a/pkg/protocol/engine/mempool/v1/state_metadata.go b/pkg/protocol/engine/mempool/v1/state_metadata.go index 67a3f6aca..f7f1a6593 100644 --- a/pkg/protocol/engine/mempool/v1/state_metadata.go +++ b/pkg/protocol/engine/mempool/v1/state_metadata.go @@ -59,14 +59,6 @@ func (s *StateMetadata) setup(optSource ...*TransactionMetadata) *StateMetadata return s } -func (s *StateMetadata) StateID() mempool.StateID { - return s.state.StateID() -} - -func (s *StateMetadata) Type() iotago.StateType { - return iotago.InputUTXO -} - func (s *StateMetadata) State() mempool.State { return s.state } diff --git a/pkg/protocol/engine/mempool/v1/transaction_metadata.go b/pkg/protocol/engine/mempool/v1/transaction_metadata.go index 98e968577..c14b6fa08 100644 --- a/pkg/protocol/engine/mempool/v1/transaction_metadata.go +++ b/pkg/protocol/engine/mempool/v1/transaction_metadata.go @@ -16,7 +16,7 @@ import ( type TransactionMetadata struct { id iotago.TransactionID - inputReferences []iotago.Input + inputReferences []mempool.StateReference inputs []*StateMetadata outputs []*StateMetadata transaction mempool.Transaction @@ -57,7 +57,7 @@ func (t *TransactionMetadata) ValidAttachments() []iotago.BlockID { return t.validAttachments.Keys() } -func NewTransactionMetadata(transaction mempool.Transaction, referencedInputs []iotago.Input) (*TransactionMetadata, error) { +func NewTransactionMetadata(transaction mempool.Transaction, referencedInputs []mempool.StateReference) (*TransactionMetadata, error) { transactionID, transactionIDErr := transaction.ID() if transactionIDErr != nil { return nil, ierrors.Errorf("failed to retrieve transaction ID: %w", transactionIDErr) diff --git a/pkg/protocol/engine/mempool/v1/transaction_metadata_test.go b/pkg/protocol/engine/mempool/v1/transaction_metadata_test.go index dae4107c4..988bbb42f 100644 --- a/pkg/protocol/engine/mempool/v1/transaction_metadata_test.go +++ b/pkg/protocol/engine/mempool/v1/transaction_metadata_test.go @@ -15,7 +15,7 @@ func TestAttachments(t *testing.T) { "2": iotago.SlotIdentifierRepresentingData(2, []byte("block2")), } - transactionMetadata, err := NewTransactionMetadata(mempooltests.NewTransaction(2), []iotago.Input{}) + transactionMetadata, err := NewTransactionMetadata(mempooltests.NewTransaction(2), nil) require.NoError(t, err) signedTransactionMetadata, err := NewSignedTransactionMetadata(mempooltests.NewSignedTransaction(transactionMetadata.Transaction()), transactionMetadata) diff --git a/pkg/protocol/engine/mempool/vm.go b/pkg/protocol/engine/mempool/vm.go index 49ffc1d80..95f62ec74 100644 --- a/pkg/protocol/engine/mempool/vm.go +++ b/pkg/protocol/engine/mempool/vm.go @@ -2,18 +2,16 @@ package mempool import ( "context" - - iotago "github.com/iotaledger/iota.go/v4" ) // VM is the interface that defines the virtual machine that is used to validate and execute transactions. type VM interface { - // TransactionInputs returns the inputs of the given transaction. - TransactionInputs(transaction Transaction) ([]iotago.Input, error) + // StateReferences returns the inputs of the given transaction. + StateReferences(transaction Transaction) ([]StateReference, error) // ValidateSignatures validates the signatures of the given SignedTransaction and returns the execution context. - ValidateSignatures(signedTransaction SignedTransaction, resolvedInputs []State) (executionContext context.Context, err error) + ValidateSignatures(signedTransaction SignedTransaction, inputs []State) (executionContext context.Context, err error) - // ExecuteTransaction executes the transaction in the given execution context and returns the resulting states. - ExecuteTransaction(executionContext context.Context, transaction Transaction) (outputs []State, err error) + // Execute executes the transaction in the given execution context and returns the resulting states. + Execute(executionContext context.Context, transaction Transaction) (outputs []State, err error) }