-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize transaction validation for wallet (#3537)
Description --- Optimized the transaction validation memory footprint by restricting all queries to the database to only return the information that is needed. This holds two considerable advantages for databases with many or large transactions: - The memory footprint is reduced. - Overall performance is increased. Motivation and Context --- See above. How Has This Been Tested? --- Unit tests Cucumber tests System-level tests with a large wallet
- Loading branch information
1 parent
d8e0ced
commit 9064b83
Showing
14 changed files
with
354 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
base_layer/wallet/migrations/2021-10-28-164318_add_transaction_signature/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
PRAGMA foreign_keys=OFF; | ||
ALTER TABLE completed_transactions | ||
RENAME TO completed_transactions_old; | ||
CREATE TABLE completed_transactions ( | ||
tx_id INTEGER PRIMARY KEY NOT NULL, | ||
source_public_key BLOB NOT NULL, | ||
destination_public_key BLOB NOT NULL, | ||
amount INTEGER NOT NULL, | ||
fee INTEGER NOT NULL, | ||
transaction_protocol TEXT NOT NULL, | ||
status INTEGER NOT NULL, | ||
message TEXT NOT NULL, | ||
timestamp DATETIME NOT NULL, | ||
cancelled INTEGER NOT NULL DEFAULT 0, | ||
direction INTEGER NULL DEFAULT NULL, | ||
coinbase_block_height INTEGER NULL DEFAULT NULL, | ||
send_count INTEGER NOT NULL DEFAULT 0, | ||
last_send_timestamp DATETIME NULL DEFAULT NULL, | ||
valid INTEGER NOT NULL DEFAULT 0, | ||
confirmations INTEGER NULL DEFAULT NULL, | ||
mined_height BIGINT NULL DEFAULT NULL, | ||
mined_in_block BLOB NULL DEFAULT NULL | ||
|
||
); | ||
INSERT INTO completed_transactions (tx_id, source_public_key, destination_public_key, amount, fee, transaction_protocol, | ||
status, message, timestamp, cancelled, direction, coinbase_block_height, send_count, | ||
last_send_timestamp, valid, confirmations) | ||
SELECT tx_id, | ||
source_public_key, | ||
destination_public_key, | ||
amount, | ||
fee, | ||
transaction_protocol, | ||
status, | ||
message, | ||
timestamp, | ||
cancelled, | ||
direction, | ||
coinbase_block_height, | ||
send_count, | ||
last_send_timestamp, | ||
valid, | ||
confirmations, | ||
mined_height, | ||
mined_in_block | ||
FROM completed_transactions_old; | ||
DROP TABLE completed_transactions_old; | ||
PRAGMA foreign_keys=ON; |
5 changes: 5 additions & 0 deletions
5
base_layer/wallet/migrations/2021-10-28-164318_add_transaction_signature/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ALTER TABLE completed_transactions | ||
ADD transaction_signature_nonce BLOB NOT NULL DEFAULT 0; | ||
|
||
ALTER TABLE completed_transactions | ||
ADD transaction_signature_key BLOB NOT NULL DEFAULT 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.