Skip to content

Conversation

@awrichar
Copy link
Contributor

@awrichar awrichar commented Jan 12, 2022

Pre-requisite refactoring for #393

The goal is to split all blockchain-related information out of Transaction, and store it in an associated BlockchainEvent object. Transaction just becomes a grouping construct for other objects (with no real data of its own), and BlockchainEvent contains all blockchain-ish data, including from internal events like "BatchPin," and from user-created subscriptions as well.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Blockchain-specific data has all moved to BlockchainEvent.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
A transfer will always be associated with a blockchain event, which may or may not be
associated with a transaction.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
@awrichar
Copy link
Contributor Author

Here's a diagram to describe the new relationships between Transactions, BlockchainEvents, and other items in FireFly:
Firefly___Asset_Trail_-_architecture_whiteboard__Online_Whiteboard_for_Visual_Collaboration

Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a simplification throughout the code changes, and I'm very glad you were able to make the time to tackle this now. Thank you!

Couple of comments to consider.

@@ -0,0 +1,10 @@
BEGIN;
ALTER TABLE transactions ADD COLUMN ref UUID;
ALTER TABLE transactions ADD COLUMN signer VARCHAR(1024) NOT NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think the NOT NULL will work, as we've lost the data.

@@ -0,0 +1,16 @@
BEGIN;
CREATE TABLE blockchainevents (
Copy link
Contributor

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_id for this one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and id

Copy link
Contributor Author

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-logic branch has these indexes now (they are on contractevents but I just renamed that table):

CREATE INDEX blockchainevents_name ON blockchainevents(namespace,name);
CREATE INDEX blockchainevents_timestamp ON blockchainevents(timestamp);
CREATE INDEX blockchainevents_subscription_id ON blockchainevents(subscription_id);

If we add 2 more indexes, is that a bit much for a potentially high-write-volume table?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Event Event
}

type Event struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in our current codebase, this object might be better located at fftypes.BlockchainEvent understand the difference now

PoolProtocolID string

// Event contains info on the underlying blockchain event for this transfer
Event blockchain.Event
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels slightly odd to me having the tokens plugin refer to the blockchain plugin (rather than exclusively fftypes).

However, I understand if blockchain.Event moved to fftypes it would need to be distinguished from fftypes.BlockchainEvent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I struggled a bit with where to define types. We have two versions of a lot of things - one is the shape of the raw object that pops out of the plugin, the other is the shape of the object built and stored by FireFly. For instance, blockchain.BatchPin and fftypes.Batch. I followed somewhat similar patterns with token types for pools/transfers (there is one struct in tokens and another in fftypes, and event manager does a mapping).

But blockchain.Event is now odd because it's describing the shape of a thing that is emitted in common from multiple plugins (blockchain and tokens). Couldn't decide where that should live, as it's fundamentally an internal "wire format" and didn't quite feel like it belongs in fftypes.

Copy link
Contributor Author

@awrichar awrichar Jan 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I have another option of defining a separate type as tokens.BlockchainEvent, and just giving it all the same fields as blockchain.Event.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with this for now - journey makes sense

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the extra comments 👍

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.

2 participants