-
Notifications
You must be signed in to change notification settings - Fork 72
Receipt fixes #77
Receipt fixes #77
Conversation
58e00b8
to
77d60c1
Compare
@benjamincburns Since this is a pretty substantial change (some previous transactions that were previously invalid are now valid), can you summarize the discussion from RocketChat about why this is the desired behavior, what the pros and cons are, and what use cases this support. |
77d60c1
to
0cca59b
Compare
Go formatting issues are now fixed. |
@aludvik sure thing. To be clear, this change doesn't allow for contract state updates when transaction execution fails. It simply records the transaction execution failure in the transaction receipt format that is appropriate for the transaction family. Prior to these changes there was no way for a client which submitted its transactions via Seth's RPC interface to determine whether the transaction was executed, and what the result of that execution was. Via the Ethereum RPC interface, the usual transaction flow looks like this:
If no receipt is produced when a message call to a contract address fails due to a runtime error (e.g. due to the |
As to what use-cases this supports, I'm working on integrating the Truffle toolsuite with Sawtooth-Seth. See the blocked tickets on the commit-referenced Jira issue for more info. |
Signed-off-by: Ben Burns <benjamin.c.burns@gmail.com>
0cca59b
to
6ef6310
Compare
Looks like I had some rust formatting issues as well - those should be fixed up now. |
32c15f0
to
7145595
Compare
rpc/tests/test_seth_rpc.py
Outdated
@@ -238,6 +239,9 @@ def test_get_block_by_hash(self): | |||
self.assertEqual(result["stateRoot"], "0x" + self.state_root) | |||
self.assertEqual(result["gasUsed"], hex(self.gas)) | |||
self.assertEqual(result["transactions"][0], "0x" + self.txn_id) | |||
self.assertEqual(result["status"], "0x" + self.status) |
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.
Looks like this line is causing issues in Jenkins atm:
47b3065
to
1f3b704
Compare
Signed-off-by: Ben Burns <benjamin.c.burns@gmail.com>
1f3b704
to
115e220
Compare
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.
Some minor feedback, but overall LGTM
rpc/tests/test_seth_rpc.py
Outdated
@@ -80,6 +80,7 @@ def setUpClass(cls): | |||
# account values | |||
cls.public_key = "036d7bb6ca0fd581eb037e91042320af97508003264f08545a9db134df215f373e" | |||
cls.account_address = "434d46456b6973a678b77382fca0252629f4389f" | |||
cls.account_address_b = bytes([0x43, 0x4d, 0x46, 0x45, 0x6b, 0x69, 0x73, 0xa6, 0x78, 0xb7, 0x73, 0x82, 0xfc, 0xa0, 0x25, 0x26, 0x29, 0xf4, 0x38, 0x9f]) |
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.
Might be worth writing this as cls.account_address_b = bytes.fromhex(cls.account_address)
so that the two definitions don't get out of sync
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.
good point - I missed that helper function - will fix.
status=self.status, | ||
to=self.contract_address_b, | ||
) | ||
setattr(receipt, 'from', self.account_address_b) |
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.
Wondering what the purpose of setattr
is here vs just passing it into the constructor
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.
Sadly due to a limitation of python you can't use reserved words as keyword arguments for a function. The protobuf devs seem to be aware of that limitation, but it's as yet unresolved, and setattr
is the only viable workaround I could find.
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'll add a comment to make this more clear, since I'm already going to do that bytes.fromhex
fix you mentioned elsewhere...
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.
Cool, makes sense. Another option is that you could do is SethTransactionReceipt(**{'from': self.account_address_b, ...})
, but either way works
Signed-off-by: Ben Burns <benjamin.c.burns@gmail.com>
115e220
to
60fdccf
Compare
@benjamincburns Thanks for the response. Am I correct in understanding there are three types of validity with Ethereum transactions?
Is that characterization accurate? Does the nonce still get updated if the transaction execution fails? |
@aludvik sorry that I didn't see your question above! Yes, your characterization is accurate. The nonce gets updated in cases 1 and 2, as in these cases a transaction receipt is generated. Transaction receipts are included in block hash calculations, and as such they're stored on chain under the transaction receipt storage trie data structure. |
Noticed that this branch has gone a bit stale, so I fixed up the outstanding conflicts. I've also ruthlessly culled the projects/issues I'm watching, so with any luck I won't miss future notifications on this PR! |
I suppose that's what I get for fixing conflicts with GitHub's internal tooling - will fix and force-push. |
5334748
to
939ae23
Compare
Signed-off-by: Ben Burns <benjamin.c.burns@gmail.com>
939ae23
to
cb62796
Compare
@benjamincburns Looks great. Can you rebase on top of master (instead of adding the merge commit) and force-push? Also, in your commit messages, can you remove the STL- from the first line? When we reference bugs (which isn't often currently), we prefer to follow https://chris.beams.io/posts/git-commit/ which is to put "Resolves: xxx" at the bottom of the commit message. |
I'm not sure where this left off and it's been quite some time since the original submission. I've moved on to other projects in that time, so I think it's best if I go ahead and close. |
Makes it so that receipts are returned when EVM runtime errors occur (e.g.
REVERT
). Adds missingstatus
,from
, andto
fields to the transaction receipt.