-
Notifications
You must be signed in to change notification settings - Fork 310
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
Add TXCREATE transaction initcodes support - new approach #709
Conversation
616def3
to
4f517ff
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #709 +/- ##
=======================================
Coverage 93.49% 93.49%
=======================================
Files 25 25
Lines 3861 3861
Branches 396 396
=======================================
Hits 3610 3610
Misses 139 139
Partials 112 112 |
bindings/go/evmc/evmc.go
Outdated
out[i].code = bytesPtr(initcodes[i].code) | ||
out[i].code_size = C.size_t(len(initcodes[i].code)) | ||
} | ||
return &out[0] |
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.
Are you sure you can pass this GC pointer to C?
And the formatting is wrong.
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 think it make sense to add a Go unit test where we actually pass some initcodes. Go has a runtime inspection of passed pointers and will likely report errors if we are doing something wrong.
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 think it's definitely wrong, but digging deeper into this I am now confused, because when returning output data from Go host call
to C side it does something similar:
Line 233 in 954944a
outputData = (*C.uint8_t)(&output[0]) |
Go byte array is converted to C pointer and returned in
evmc_result
. This seems very wrong, because Go array is going to be garbage-collected, and then C has a dangling poiner.
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.
There the C.evmc_make_result
makes a copy.
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.
Ah I see, missed that, thanks.
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 general, it looks you should pin the array make([]C.evmc_tx_initcode, len(initcodes))
somewhere. Maybe add a private field cInitcodes
to TxContext
.
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.
Add commit description and mention EOF.
include/evmc/evmc.h
Outdated
@@ -169,7 +169,8 @@ struct evmc_message | |||
/** | |||
* The optional value used in new contract address construction. | |||
* | |||
* Needed only for a Host to calculate created address when kind is ::EVMC_CREATE2. | |||
* Needed only for a Host to calculate created address when kind is ::EVMC_CREATE2, |
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.
* Needed only for a Host to calculate created address when kind is ::EVMC_CREATE2, | |
* Needed only for a Host to calculate created address when kind is ::EVMC_CREATE2 or |
Extends the trasaction context with initcodes to support EOF TXCREATE.
Replaces #702