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

sc-5933 Marshal transaction #99

Merged
merged 1 commit into from
Jun 20, 2022
Merged

sc-5933 Marshal transaction #99

merged 1 commit into from
Jun 20, 2022

Conversation

pdeziel
Copy link
Collaborator

@pdeziel pdeziel commented Jun 17, 2022

This marshals the generic.Transaction payload as a string to the database in a similar manner to how we're handling the identity payload. This allows us to avoid having to reconstruct the payload for async transactions so the rvasps can act a bit more consistent. I also discovered some bugs in local testing which I've taken the opportunity to fix.

Envelope string `gorm:"not null"`
AccountID uint `gorm:"not null"`
Account Account `gorm:"foreignKey:AccountID"`
OriginatorID uint `gorm:"column:originator_id;not null"`
Originator Identity `gorm:"foreignKey:OriginatorID"`
BeneficiaryID uint `gorm:"column:beneficiary_id;not null"`
Beneficiary Identity `gorm:"foreignKey:BeneficiaryID"`
Amount decimal.Decimal `gorm:"type:numeric(15,2)"`
Amount decimal.Decimal `gorm:"type:decimal(15,8)"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To avoid truncation in the database for small valued transfers.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hehe, you're right numeric(15,2) is for real money that has cents and not partial cents but we definitely need more precision for bitcoin transactions that can have a large fraction of a coin! Definitely a bit of bias we added when I first developed this model!

else
ALICE_ENDPOINT=admin.alice.vaspbot.net:443
BOB_ENDPOINT=admin.bob.vaspbot.net:443
fi
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've discovered that this script is really useful for local testing as well, thanks for adding it!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Glad it's helpful!

@pdeziel pdeziel requested a review from bbengfort June 17, 2022 22:00
Copy link
Collaborator

@bbengfort bbengfort left a comment

Choose a reason for hiding this comment

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

Looks good, hopefully this will make transaction handling a lot easier!

Envelope string `gorm:"not null"`
AccountID uint `gorm:"not null"`
Account Account `gorm:"foreignKey:AccountID"`
OriginatorID uint `gorm:"column:originator_id;not null"`
Originator Identity `gorm:"foreignKey:OriginatorID"`
BeneficiaryID uint `gorm:"column:beneficiary_id;not null"`
Beneficiary Identity `gorm:"foreignKey:BeneficiaryID"`
Amount decimal.Decimal `gorm:"type:numeric(15,2)"`
Amount decimal.Decimal `gorm:"type:decimal(15,8)"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hehe, you're right numeric(15,2) is for real money that has cents and not partial cents but we definitely need more precision for bitcoin transactions that can have a large fraction of a coin! Definitely a bit of bias we added when I first developed this model!

@@ -407,7 +407,7 @@
"badnews@evilvasp.gg",
3,
"SendFull",
"SyncRequire",
"AsyncRepair",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this require us to re-migrate and update the documentation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The documentation is already updated but we do need to run the migration at some point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a good stopping point that we can tag this as v1.0 to test goreleaser and the container builds then run the migrations? The postgres migrations shouldn't result in any downtime for the rVASPs, so I think we can run them when we need to; but we should still do it at off-peak hours.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can do that whenever, I don't have any more rVASP work planned for the current sprint.

@@ -524,8 +524,7 @@ func (s *Server) respondAsync(peer *peers.Peer, payload *protocol.Payload, ident
switch xfer.State {
case pb.TransactionState_AWAITING:
// Fill the transaction with a new TxID to continue the handshake
xfer.TxID = uuid.New().String()
transaction.Txid = xfer.TxID
transaction.Txid = uuid.New().String()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch - CipherTrace has been reporting an issue where the rVASP returns an incorrect "receipt ID" than the one it was sent. I wonder if this is related. Note that they claim that receipt ID == envelope ID, but I'm not sure about that terminology. CC @DanielSollis

Comment on lines 266 to +267
Identity string `gorm:"not null"`
Transaction string `gorm:"not null"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that we're using postgres we could consider making these JSON types rather than raw strings -- but only if it's easy to do.

else
ALICE_ENDPOINT=admin.alice.vaspbot.net:443
BOB_ENDPOINT=admin.bob.vaspbot.net:443
fi
Copy link
Collaborator

Choose a reason for hiding this comment

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

Glad it's helpful!

@pdeziel pdeziel merged commit 906169d into main Jun 20, 2022
@pdeziel pdeziel deleted the sc-5933 branch June 20, 2022 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants