Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Access] Clean up blockID argument from deriveTransactionStatus #5619

2 changes: 1 addition & 1 deletion engine/access/rpc/backend/backend_stream_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (b *backendSubscribeTransactions) getTransactionStatusResponse(txInfo *Tran
// When a block with the transaction is available, it is possible to receive a new transaction status while
// searching for the transaction result. Otherwise, it remains unchanged. So, if the old and new transaction
// statuses are the same, the current transaction status should be retrieved.
txInfo.Status, err = b.txLocalDataProvider.DeriveTransactionStatus(txInfo.BlockID, txInfo.blockWithTx.Height, txInfo.txExecuted)
txInfo.Status, err = b.txLocalDataProvider.DeriveTransactionStatus(txInfo.blockWithTx.Height, txInfo.txExecuted)
}
if err != nil {
if !errors.Is(err, state.ErrUnknownSnapshotReference) {
Expand Down
12 changes: 6 additions & 6 deletions engine/access/rpc/backend/backend_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (b *backendTransactions) GetTransactionResult(
if block == nil {
txStatus, err = b.DeriveUnknownTransactionStatus(tx.ReferenceBlockID)
} else {
txStatus, err = b.DeriveTransactionStatus(blockID, blockHeight, false)
txStatus, err = b.DeriveTransactionStatus(blockHeight, false)
}

if err != nil {
Expand Down Expand Up @@ -439,7 +439,7 @@ func (b *backendTransactions) getTransactionResultsByBlockIDFromExecutionNode(
txResult := resp.TransactionResults[i]

// tx body is irrelevant to status if it's in an executed block
txStatus, err := b.DeriveTransactionStatus(blockID, block.Header.Height, true)
txStatus, err := b.DeriveTransactionStatus(block.Header.Height, true)
if err != nil {
if !errors.Is(err, state.ErrUnknownSnapshotReference) {
irrecoverable.Throw(ctx, err)
Expand Down Expand Up @@ -488,7 +488,7 @@ func (b *backendTransactions) getTransactionResultsByBlockIDFromExecutionNode(
}

systemTxResult := resp.TransactionResults[len(resp.TransactionResults)-1]
systemTxStatus, err := b.DeriveTransactionStatus(blockID, block.Header.Height, true)
systemTxStatus, err := b.DeriveTransactionStatus(block.Header.Height, true)
if err != nil {
if !errors.Is(err, state.ErrUnknownSnapshotReference) {
irrecoverable.Throw(ctx, err)
Expand Down Expand Up @@ -573,7 +573,7 @@ func (b *backendTransactions) getTransactionResultByIndexFromExecutionNode(
}

// tx body is irrelevant to status if it's in an executed block
txStatus, err := b.DeriveTransactionStatus(blockID, block.Header.Height, true)
txStatus, err := b.DeriveTransactionStatus(block.Header.Height, true)
if err != nil {
if !errors.Is(err, state.ErrUnknownSnapshotReference) {
irrecoverable.Throw(ctx, err)
Expand Down Expand Up @@ -626,7 +626,7 @@ func (b *backendTransactions) GetSystemTransactionResult(ctx context.Context, bl
}

systemTxResult := resp.TransactionResults[len(resp.TransactionResults)-1]
systemTxStatus, err := b.DeriveTransactionStatus(blockID, block.Header.Height, true)
systemTxStatus, err := b.DeriveTransactionStatus(block.Header.Height, true)
if err != nil {
return nil, rpc.ConvertStorageError(err)
}
Expand Down Expand Up @@ -793,7 +793,7 @@ func (b *backendTransactions) getTransactionResultFromExecutionNode(
}

// tx body is irrelevant to status if it's in an executed block
txStatus, err := b.DeriveTransactionStatus(blockID, block.Header.Height, true)
txStatus, err := b.DeriveTransactionStatus(block.Header.Height, true)
if err != nil {
if !errors.Is(err, state.ErrUnknownSnapshotReference) {
irrecoverable.Throw(ctx, err)
Expand Down
2 changes: 1 addition & 1 deletion engine/access/rpc/backend/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (r *Retry) retryTxsAtHeight(heightToRetry uint64) error {
if block == nil {
status, err = r.backend.DeriveUnknownTransactionStatus(tx.ReferenceBlockID)
} else {
status, err = r.backend.DeriveTransactionStatus(block.ID(), block.Header.Height, false)
status, err = r.backend.DeriveTransactionStatus(block.Header.Height, false)
}

if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions engine/access/rpc/backend/transactions_local_data_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (t *TransactionsLocalDataProvider) GetTransactionResultFromStorage(
txStatusCode = 1 // statusCode of 1 indicates an error and 0 indicates no error, the same as on EN
}

txStatus, err := t.DeriveTransactionStatus(blockID, block.Header.Height, true)
txStatus, err := t.DeriveTransactionStatus(block.Header.Height, true)
if err != nil {
if !errors.Is(err, state.ErrUnknownSnapshotReference) {
irrecoverable.Throw(ctx, err)
Expand Down Expand Up @@ -178,7 +178,7 @@ func (t *TransactionsLocalDataProvider) GetTransactionResultsByBlockIDFromStorag
txStatusCode = 1
}

txStatus, err := t.DeriveTransactionStatus(blockID, block.Header.Height, true)
txStatus, err := t.DeriveTransactionStatus(block.Header.Height, true)
if err != nil {
if !errors.Is(err, state.ErrUnknownSnapshotReference) {
irrecoverable.Throw(ctx, err)
Expand Down Expand Up @@ -255,7 +255,7 @@ func (t *TransactionsLocalDataProvider) GetTransactionResultByIndexFromStorage(
txStatusCode = 1 // statusCode of 1 indicates an error and 0 indicates no error, the same as on EN
}

txStatus, err := t.DeriveTransactionStatus(blockID, block.Header.Height, true)
txStatus, err := t.DeriveTransactionStatus(block.Header.Height, true)
if err != nil {
if !errors.Is(err, state.ErrUnknownSnapshotReference) {
irrecoverable.Throw(ctx, err)
Expand Down Expand Up @@ -338,9 +338,9 @@ func (t *TransactionsLocalDataProvider) DeriveUnknownTransactionStatus(refBlockI
return flow.TransactionStatusPending, nil
}

// DeriveTransactionStatus is used to determine the status of a transaction based on the provided block ID, block height, and execution status.
// DeriveTransactionStatus is used to determine the status of a transaction based on the provided block height, and execution status.
// No errors expected during normal operations.
func (t *TransactionsLocalDataProvider) DeriveTransactionStatus(blockID flow.Identifier, blockHeight uint64, executed bool) (flow.TransactionStatus, error) {
func (t *TransactionsLocalDataProvider) DeriveTransactionStatus(blockHeight uint64, executed bool) (flow.TransactionStatus, error) {
if !executed {
// If we've gotten here, but the block has not yet been executed, report it as only been finalized
return flow.TransactionStatusFinalized, nil
Expand Down
Loading