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

Add function TxIDExists and use in validation path #2075

Merged
merged 1 commit into from
Nov 6, 2020

Conversation

manish-sethi
Copy link
Contributor

@manish-sethi manish-sethi commented Nov 5, 2020

Signed-off-by: manish manish.sethi@gmail.com

Type of change

  • New feature

Description

This commit adds a function in ledger TxIDExists and uses this in validation path for checking duplicate txids.

Additional details

The current validation code, in order to checks for a duplicate txid, uses the API GetTransactionByID on ledger and relies on the error types returned by this API. For a ledger that is bootstrapped from a snapshot, this API returns another untyped error (stating that the TxID details not available) if the TxID belongs to a block that is committed prior to the snapshot height. In the current code, in validation path, this error will be interpreted as general ledger error that results in a peer panic.
One option is to return a typed error (e.g., TxIDBeforeSnapshot) and modify the validation to check for this error type as well. However, instead of exposing one more error type for validation code, it is cleaner to add an explicit function for checking the existence of a TxID. This makes the existing code relatively more readable as well.

Related issues

FAB-18318

@manish-sethi manish-sethi requested a review from a team as a code owner November 5, 2020 04:42
This commit adds a function in ledger TxIDExists and uses this in
validation path for checking duplicate txids.

The current validation code, in order to checks for a duplicate txid,
uses the API GetTransactionByID on ledger and relies on the error types
returned by this API. For a ledger that is bootstrapped from a snapshot,
this API needs to return an additional error if the txid belongs to a
block that is committed prior to the snapshot height.
Instead of exposing one more error type for validation code, we add an
explicit function for checking the existence of a TxID

Signed-off-by: manish <manish.sethi@gmail.com>
@manish-sethi manish-sethi force-pushed the txid_exists_validation branch from 539e791 to 77b8a73 Compare November 5, 2020 14:39
@denyeart denyeart merged commit 17f075c into hyperledger:master Nov 6, 2020
@manish-sethi manish-sethi deleted the txid_exists_validation branch November 6, 2020 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants