-
Notifications
You must be signed in to change notification settings - Fork 38
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
store incoming transactions in a database #1828
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
id INT AUTO_INCREMENT PRIMARY KEY, | ||
user_id varbinary(20), | ||
tx TEXT, | ||
tx_time DATETIME DEFAULT CURRENT_TIMESTAMP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if it be possible to store the tx hash as well or is that going to be too expensive to figure out on the fly? Just thinking about being able to do lookups if investigating an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added tx_hash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple minor tweaks/things I wanted to check.
w.Logger().Error(fmt.Errorf("error decoding string (%s), %w", hexUserID[2:], err).Error()) | ||
return nil, errors.New("error decoding userID. It should be in hex format") | ||
} | ||
err = w.storage.StoreTransaction(request.Params[0].(string), userIDBytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we 100% certain that the first param exists, can be cast to a string and will have "0x" as the first two characters so you can strip them off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things are checked in a function that calls that function, but added additional check there to avoid an edge case that might happen.
// Calculate tx hash | ||
rawTxBytes, err := hex.DecodeString(rawTx[2:]) | ||
if err != nil { | ||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't panic here imo, just log the error and store it without the tx hash. (Same on the sqlite impl)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Why this change is needed
For debugging purposes we would like to store unencrypted transactions in the gateway to be able to reproduce some errors if they occur.
What changes were made as part of this PR
Additional database table, storing transactions
PR checks pre-merging
Please indicate below by ticking the checkbox that you have read and performed the required
PR checks
https://github.com/ten-protocol/ten-test/actions/runs/8143119529