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

[EVM] Emit events as Cadence events #5090

Merged
merged 17 commits into from
Dec 4, 2023
Merged

Conversation

sideninja
Copy link
Contributor

@sideninja sideninja commented Nov 30, 2023

Closes: #5079

This PR implements converting EVM events into native Cadence events so the can be emitted and encoded using the same modules as other Flow events. This also benefits clients that already parse events in a certain way.

An example of event output now looks something like:

Events:		
    Index	0
    Type	A.0ae53cb6e3f42a79.FlowToken.TokensWithdrawn
    Tx ID	55b4e2f6517ac5293a49e2f82991b9481f01a6091b7d2e87a6176cebb773f6b9
    Values
		- amount (UFix64): 1.00000000
		- from (Address?): 0xf8d6e0586b0a20c7

    Index	1
    Type	flow.evm.TransactionExecuted
    Tx ID	55b4e2f6517ac5293a49e2f82991b9481f01a6091b7d2e87a6176cebb773f6b9
    Values
		- blockHeight (UInt64): 1
		- transactionHash (String): "0x080d3c8f073fbce565b1aaf0c90b12007d57344405637ad357c252c92b89fff3"
		- transaction (String): "fff83a81ff0194000000000000000000000000000000000000000094000000000000000000000000000000000000000180880de0b6b3a7640000825208"
		- failed (Bool): false
		- transactionType (UInt8): 255
		- gasConsumed (UInt64): 21000
		- stateRootHash (String): "0x176a3fe6cfe66b3061f2f8750206530da568ca5be992641af0d1fe227156159f"
		- deployedContractAddress (String): "0000000000000000000000000000000000000000"
		- returnedValue (String): ""
		- logs (String): ""

    Index	2
    Type	flow.evm.BlockExecuted
    Tx ID	55b4e2f6517ac5293a49e2f82991b9481f01a6091b7d2e87a6176cebb773f6b9
    Values
		- height (UInt64): 1
		- totalSupply (UInt64): 1000000000000000000
		- parentHash (String): "0x0000000000000000000000000000000000000000000000000000000000000000"
		- stateRoot (String): "0xe81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421c0"
		- receiptRoot (String): "0x176a3fe6cfe66b3061f2f8750206530da568ca5be992641af0d1fe227156159f"
		- transactionHashes (?): ["0x080d3c8f073fbce565b1aaf0c90b12007d57344405637ad357c252c92b89fff3"]
		hex: 5b22307830383064336338663037336662636535363562316161663063393062313230303764353733343434303536333761643335376332353263393262383966666633225d

    Index	3
    Type	flow.evm.TransactionExecuted
    Tx ID	55b4e2f6517ac5293a49e2f82991b9481f01a6091b7d2e87a6176cebb773f6b9
    Values
		- blockHeight (UInt64): 2
		- transactionHash (String): "0x8c54ae5f25c3fbf82e8d08624bb5443fd5ee05e51c3583a878a2a33711e652bc"
		- transaction (String): "fff9027c81ff04940000000000000000000000000000000000000001940000000000000000000000000000000000000000b9023f608060405261022c806100136000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632e64cec11461005c57806348b151661461007a57806357e871e7146100985780636057361d146100b657806385df51fd146100d2575b600080fd5b610064610102565b6040516100719190610149565b60405180910390f35b61008261010b565b60405161008f9190610149565b60405180910390f35b6100a0610113565b6040516100ad9190610149565b60405180910390f35b6100d060048036038101906100cb9190610195565b61011b565b005b6100ec60048036038101906100e79190610195565b610125565b6040516100f991906101db565b60405180910390f35b60008054905090565b600042905090565b600043905090565b8060008190555050565b600081409050919050565b6000819050919050565b61014381610130565b82525050565b600060208201905061015e600083018461013a565b92915050565b600080fd5b61017281610130565b811461017d57600080fd5b50565b60008135905061018f81610169565b92915050565b6000602082840312156101ab576101aa610164565b5b60006101b984828501610180565b91505092915050565b6000819050919050565b6101d5816101c2565b82525050565b60006020820190506101f060008301846101cc565b9291505056fea26469706673582212203ee61567a25f0b1848386ae6b8fdbd7733c8a502c83b5ed305b921b7933f4e8164736f6c634300081200338806f05b59d3b20000830493e0"
		- failed (Bool): false
		- transactionType (UInt8): 255
		- gasConsumed (UInt64): 173055
		- stateRootHash (String): "0x986e17da0d670441dceffcaba027efb1e2b5b02cd55830429fe8d82b3e78e389"
		- deployedContractAddress (String): "522b3294e6d06aa25ad0f1b8891242e335d3b459"
		- returnedValue (String): "608060405234801561001057600080fd5b50600436106100575760003560e01c80632e64cec11461005c57806348b151661461007a57806357e871e7146100985780636057361d146100b657806385df51fd146100d2575b600080fd5b610064610102565b6040516100719190610149565b60405180910390f35b61008261010b565b60405161008f9190610149565b60405180910390f35b6100a0610113565b6040516100ad9190610149565b60405180910390f35b6100d060048036038101906100cb9190610195565b61011b565b005b6100ec60048036038101906100e79190610195565b610125565b6040516100f991906101db565b60405180910390f35b60008054905090565b600042905090565b600043905090565b8060008190555050565b600081409050919050565b6000819050919050565b61014381610130565b82525050565b600060208201905061015e600083018461013a565b92915050565b600080fd5b61017281610130565b811461017d57600080fd5b50565b60008135905061018f81610169565b92915050565b6000602082840312156101ab576101aa610164565b5b60006101b984828501610180565b91505092915050565b6000819050919050565b6101d5816101c2565b82525050565b60006020820190506101f060008301846101cc565b9291505056fea26469706673582212203ee61567a25f0b1848386ae6b8fdbd7733c8a502c83b5ed305b921b7933f4e8164736f6c63430008120033"
		- logs (String): ""

    Index	4
    Type	flow.evm.BlockExecuted
    Tx ID	55b4e2f6517ac5293a49e2f82991b9481f01a6091b7d2e87a6176cebb773f6b9
    Values
		- height (UInt64): 2
		- totalSupply (UInt64): 1000000000000000000
		- parentHash (String): "0x0000000000000000000000000000000000000000000000000000000000000000"
		- stateRoot (String): "0x080d3c8f073fbce565b1aaf0c90b12007d57344405637ad357c252c92b89fff3"
		- receiptRoot (String): "0x986e17da0d670441dceffcaba027efb1e2b5b02cd55830429fe8d82b3e78e389"
		- transactionHashes (?): ["0x8c54ae5f25c3fbf82e8d08624bb5443fd5ee05e51c3583a878a2a33711e652bc"]
		hex: 5b22307838633534616535663235633366626638326538643038363234626235343433666435656530356535316333353833613837386132613333373131653635326263225d

A follow-up PR will introduce special EVM event type ID. #5091

@sideninja sideninja self-assigned this Nov 30, 2023
@sideninja sideninja changed the title Gregor/evm/cadence event [EVM] Emit events as Cadence events Nov 30, 2023
@sideninja sideninja requested a review from turbolent November 30, 2023 16:10
@@ -39,14 +39,11 @@ func DefaultEventEmitterParams() EventEmitterParams {
// with the runtime environment interface.
type EventEmitter interface {
// EmitEvent satisfies Cadence's runtime API.
// This will encode the cadence event and call EmitRawEvent.
// This will encode the cadence event and call emitRawEvent.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is not needed anymore

@codecov-commenter
Copy link

codecov-commenter commented Dec 1, 2023

Codecov Report

Attention: 41 lines in your changes are missing coverage. Please review.

Comparison is base (5c206e4) 56.24% compared to head (3eb8afa) 56.65%.
Report is 189 commits behind head on master.

Files Patch % Lines
fvm/evm/types/events.go 0.00% 41 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5090      +/-   ##
==========================================
+ Coverage   56.24%   56.65%   +0.41%     
==========================================
  Files         977      656     -321     
  Lines       91105    66455   -24650     
==========================================
- Hits        51238    37650   -13588     
+ Misses      36062    25949   -10113     
+ Partials     3805     2856     -949     
Flag Coverage Δ
unittests 56.65% <14.58%> (+0.41%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sideninja sideninja enabled auto-merge December 1, 2023 16:10
@sideninja sideninja added this pull request to the merge queue Dec 1, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 1, 2023
@sideninja sideninja added this pull request to the merge queue Dec 4, 2023
Merged via the queue into master with commit f6b2370 Dec 4, 2023
54 checks passed
@sideninja sideninja deleted the gregor/evm/cadence-event branch December 4, 2023 13:16
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.

[EVM] Events emitted from EVM are not encoded as other FVM events
4 participants