Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions vms/avm/unique_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ func (tx *UniqueTx) Bytes() []byte {
return tx.Tx.Bytes()
}

// Verify the validity of this transaction
func (tx *UniqueTx) Verify() error {
func (tx *UniqueTx) verifyWithoutCacheWrites() error {
switch status := tx.Status(); status {
case choices.Unknown:
return errUnknownTx
Expand All @@ -283,6 +282,17 @@ func (tx *UniqueTx) Verify() error {
}
}

// Verify the validity of this transaction
func (tx *UniqueTx) Verify() error {
if err := tx.verifyWithoutCacheWrites(); err != nil {
return err
}

tx.verifiedState = true
tx.vm.pubsub.Publish("verified", tx.ID())
return nil
}

// SyntacticVerify verifies that this transaction is well formed
func (tx *UniqueTx) SyntacticVerify() error {
tx.refresh()
Expand Down Expand Up @@ -310,11 +320,5 @@ func (tx *UniqueTx) SemanticVerify() error {
return tx.validity
}

if err := tx.Tx.SemanticVerify(tx.vm, tx.UnsignedTx); err != nil {
return err
}

tx.verifiedState = true
tx.vm.pubsub.Publish("verified", tx.ID())
return nil
return tx.Tx.SemanticVerify(tx.vm, tx.UnsignedTx)
}
6 changes: 3 additions & 3 deletions vms/avm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func (vm *VM) GetTx(txID ids.ID) (snowstorm.Tx, error) {
}
// Verify must be called in the case the that tx was flushed from the unique
// cache.
return tx, tx.Verify()
return tx, tx.verifyWithoutCacheWrites()
}

/*
Expand All @@ -328,7 +328,7 @@ func (vm *VM) IssueTx(b []byte) (ids.ID, error) {
if err != nil {
return ids.ID{}, err
}
if err := tx.Verify(); err != nil {
if err := tx.verifyWithoutCacheWrites(); err != nil {
return ids.ID{}, err
}
vm.issueTx(tx)
Expand Down Expand Up @@ -609,7 +609,7 @@ func (vm *VM) getUTXO(utxoID *avax.UTXOID) (*avax.UTXO, error) {
txID: inputTx,
}

if err := parent.Verify(); err != nil {
if err := parent.verifyWithoutCacheWrites(); err != nil {
return nil, errMissingUTXO
} else if status := parent.Status(); status.Decided() {
return nil, errMissingUTXO
Expand Down
Loading