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

Add TXCREATE transaction initcodes support - new approach #709

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

gumb0
Copy link
Member

@gumb0 gumb0 commented Mar 18, 2024

Replaces #702

@gumb0 gumb0 force-pushed the eof/tx_initcodes branch 7 times, most recently from 616def3 to 4f517ff Compare March 19, 2024 14:16
Copy link

codecov bot commented Mar 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.49%. Comparing base (954944a) to head (777698f).

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           

out[i].code = bytesPtr(initcodes[i].code)
out[i].code_size = C.size_t(len(initcodes[i].code))
}
return &out[0]
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

@gumb0 gumb0 Mar 21, 2024

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:

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

@gumb0 gumb0 marked this pull request as draft March 21, 2024 14:56
@gumb0 gumb0 marked this pull request as ready for review March 25, 2024 10:46
@gumb0 gumb0 requested a review from chfast March 25, 2024 10:56
Copy link
Member

@chfast chfast left a 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.

@@ -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,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* 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

@gumb0 gumb0 merged commit ec74e1c into master Mar 26, 2024
19 checks passed
@gumb0 gumb0 deleted the eof/tx_initcodes branch March 26, 2024 13:44
chfast pushed a commit that referenced this pull request Mar 26, 2024
Extends the trasaction context with initcodes to support EOF TXCREATE.
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