-
Notifications
You must be signed in to change notification settings - Fork 242
Rectify Transactions and BlockchainEvents #408
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
Merged
peterbroadhurst
merged 11 commits into
hyperledger:onchain-logic
from
kaleido-io:transactions
Jan 13, 2022
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ec8e390
Rename ContractEvent to BlockchainEvent
awrichar 5211a3d
Record BlockchainEvents for batch pin, token pool, and token transfer
awrichar 74efe7e
Remove unneeded fields from Transaction
awrichar ccaa89a
Link BlockchainEvents to Transactions
awrichar 0e654d2
Link TokenTransfers to BlockchainEvents (instead of Transactions)
awrichar d45a13d
Merge remote-tracking branch 'origin/onchain-logic' into HEAD
awrichar 52ecc32
Clean up database migrations and indexes
awrichar be94b48
Adjust token E2E tests to wait for exact events
awrichar 9988275
Restore remaining test coverage
awrichar 95e8f4b
Add missing "Source" field when storing BlockchainEvents
awrichar 9f24622
Rename "outputs" to "output" in BlockchainEvent JSON
awrichar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
3 changes: 3 additions & 0 deletions
3
db/migrations/postgres/000054_create_blockchainevents_table.down.sql
This file contains hidden or 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,3 @@ | ||
| BEGIN; | ||
| DROP TABLE IF EXISTS blockchainevents; | ||
| COMMIT; |
21 changes: 21 additions & 0 deletions
21
db/migrations/postgres/000054_create_blockchainevents_table.up.sql
This file contains hidden or 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,21 @@ | ||
| BEGIN; | ||
| CREATE TABLE blockchainevents ( | ||
| seq INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| id UUID NOT NULL, | ||
| source VARCHAR(256) NOT NULL, | ||
| namespace VARCHAR(64) NOT NULL, | ||
| name VARCHAR(256) NOT NULL, | ||
| protocol_id VARCHAR(256) NOT NULL, | ||
| timestamp BIGINT NOT NULL, | ||
| subscription_id UUID, | ||
| output BYTEA, | ||
| info BYTEA, | ||
| tx_type VARCHAR(64), | ||
| tx_id UUID | ||
| ); | ||
|
|
||
| CREATE INDEX blockchainevents_id ON blockchainevents(id); | ||
| CREATE INDEX blockchainevents_tx ON blockchainevents(tx_id); | ||
| CREATE INDEX blockchainevents_timestamp ON blockchainevents(timestamp); | ||
| CREATE INDEX blockchainevents_subscription_id ON blockchainevents(subscription_id); | ||
| COMMIT; | ||
3 changes: 0 additions & 3 deletions
3
db/migrations/postgres/000054_create_contractevents_table.down.sql
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
db/migrations/postgres/000054_create_contractevents_table.up.sql
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
db/migrations/postgres/000056_drop_transactions_columns.down.sql
This file contains hidden or 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,10 @@ | ||
| BEGIN; | ||
| ALTER TABLE transactions ADD COLUMN ref UUID; | ||
| ALTER TABLE transactions ADD COLUMN signer VARCHAR(1024); | ||
| ALTER TABLE transactions ADD COLUMN hash CHAR(64); | ||
| ALTER TABLE transactions ADD COLUMN protocol_id VARCHAR(256); | ||
| ALTER TABLE transactions ADD COLUMN info BYTEA; | ||
|
|
||
| CREATE INDEX transactions_protocol_id ON transactions(protocol_id); | ||
| CREATE INDEX transactions_ref ON transactions(ref); | ||
| COMMIT; |
10 changes: 10 additions & 0 deletions
10
db/migrations/postgres/000056_drop_transactions_columns.up.sql
This file contains hidden or 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,10 @@ | ||
| BEGIN; | ||
| DROP INDEX transactions_protocol_id; | ||
| DROP INDEX transactions_ref; | ||
|
|
||
| ALTER TABLE transactions DROP COLUMN ref; | ||
| ALTER TABLE transactions DROP COLUMN signer; | ||
| ALTER TABLE transactions DROP COLUMN hash; | ||
| ALTER TABLE transactions DROP COLUMN protocol_id; | ||
| ALTER TABLE transactions DROP COLUMN info; | ||
| COMMIT; |
5 changes: 5 additions & 0 deletions
5
db/migrations/postgres/000057_add_tokentransfer_blockchainevent.down.sql
This file contains hidden or 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 @@ | ||
| BEGIN; | ||
| ALTER TABLE tokentransfer DROP COLUMN blockchain_event; | ||
| ALTER TABLE tokentransfer ADD COLUMN tx_type VARCHAR(64); | ||
| ALTER TABLE tokentransfer ADD COLUMN tx_id UUID; | ||
| COMMIT; |
5 changes: 5 additions & 0 deletions
5
db/migrations/postgres/000057_add_tokentransfer_blockchainevent.up.sql
This file contains hidden or 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 @@ | ||
| BEGIN; | ||
| ALTER TABLE tokentransfer DROP COLUMN tx_type; | ||
| ALTER TABLE tokentransfer DROP COLUMN tx_id; | ||
| ALTER TABLE tokentransfer ADD COLUMN blockchain_event UUID; | ||
| COMMIT; |
1 change: 1 addition & 0 deletions
1
db/migrations/sqlite/000054_create_blockchainevents_table.down.sql
This file contains hidden or 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 @@ | ||
| DROP TABLE IF EXISTS blockchainevents; |
19 changes: 19 additions & 0 deletions
19
db/migrations/sqlite/000054_create_blockchainevents_table.up.sql
This file contains hidden or 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,19 @@ | ||
| CREATE TABLE blockchainevents ( | ||
| seq INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| id UUID NOT NULL, | ||
| source VARCHAR(256) NOT NULL, | ||
| namespace VARCHAR(64) NOT NULL, | ||
| name VARCHAR(256) NOT NULL, | ||
| protocol_id VARCHAR(256) NOT NULL, | ||
| timestamp BIGINT NOT NULL, | ||
| subscription_id UUID, | ||
| output TEXT, | ||
| info TEXT, | ||
| tx_type VARCHAR(64), | ||
| tx_id UUID | ||
awrichar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
|
|
||
| CREATE INDEX blockchainevents_id ON blockchainevents(id); | ||
| CREATE INDEX blockchainevents_tx ON blockchainevents(tx_id); | ||
| CREATE INDEX blockchainevents_timestamp ON blockchainevents(timestamp); | ||
| CREATE INDEX blockchainevents_subscription_id ON blockchainevents(subscription_id); | ||
1 change: 0 additions & 1 deletion
1
db/migrations/sqlite/000054_create_contractevents_table.down.sql
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
db/migrations/sqlite/000054_create_contractevents_table.up.sql
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
db/migrations/sqlite/000056_drop_transactions_columns.down.sql
This file contains hidden or 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,8 @@ | ||
| ALTER TABLE transactions ADD COLUMN ref UUID; | ||
| ALTER TABLE transactions ADD COLUMN signer VARCHAR(1024); | ||
| ALTER TABLE transactions ADD COLUMN hash CHAR(64); | ||
| ALTER TABLE transactions ADD COLUMN protocol_id VARCHAR(256); | ||
| ALTER TABLE transactions ADD COLUMN info BYTEA; | ||
|
|
||
| CREATE INDEX transactions_protocol_id ON transactions(protocol_id); | ||
| CREATE INDEX transactions_ref ON transactions(ref); |
This file contains hidden or 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,8 @@ | ||
| DROP INDEX transactions_protocol_id; | ||
| DROP INDEX transactions_ref; | ||
|
|
||
| ALTER TABLE transactions DROP COLUMN ref; | ||
| ALTER TABLE transactions DROP COLUMN signer; | ||
| ALTER TABLE transactions DROP COLUMN hash; | ||
| ALTER TABLE transactions DROP COLUMN protocol_id; | ||
| ALTER TABLE transactions DROP COLUMN info; |
3 changes: 3 additions & 0 deletions
3
db/migrations/sqlite/000057_add_tokentransfer_blockchainevent.down.sql
This file contains hidden or 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,3 @@ | ||
| ALTER TABLE tokentransfer DROP COLUMN blockchain_event; | ||
| ALTER TABLE tokentransfer ADD COLUMN tx_type VARCHAR(64); | ||
| ALTER TABLE tokentransfer ADD COLUMN tx_id UUID; |
3 changes: 3 additions & 0 deletions
3
db/migrations/sqlite/000057_add_tokentransfer_blockchainevent.up.sql
This file contains hidden or 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,3 @@ | ||
| ALTER TABLE tokentransfer DROP COLUMN tx_type; | ||
| ALTER TABLE tokentransfer DROP COLUMN tx_id; | ||
| ALTER TABLE tokentransfer ADD COLUMN blockchain_event UUID; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Think we need an index on
tx_idfor this oneThere 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.
and
idThere 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.
I see that the
onchain-logicbranch has these indexes now (they are oncontracteventsbut I just renamed that table):If we add 2 more indexes, is that a bit much for a potentially high-write-volume table?
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.
I do think the ones you mentioned are useful... I guess just wondering if I should also prune any others? Possibly
name?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.
Think we go with this for now, and test - can't see any obvious candidates to cull.
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.
In the end I did remove
namespace,name. It's easy enough to add back later if we want.