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

address.code and address.codesize #3044

Closed
axic opened this issue Oct 6, 2017 · 8 comments
Closed

address.code and address.codesize #3044

axic opened this issue Oct 6, 2017 · 8 comments
Labels
breaking change ⚠️ language design :rage4: Any changes to the language, e.g. new features

Comments

@axic
Copy link
Member

axic commented Oct 6, 2017

Add a member called "code" to the address type that returns a variably-sized byte array which contains the code at that address.
Translate "address.code.length" directly to CODESIZE.

(From https://www.pivotaltracker.com/story/show/89623638)

@axic axic added the feature label Oct 6, 2017
@axic axic added the language design :rage4: Any changes to the language, e.g. new features label Jul 28, 2018
@axic
Copy link
Member Author

axic commented Jul 28, 2018

With Constantinople's extcodehash feature this should also support address.hash or address.codehash.

@axic
Copy link
Member Author

axic commented Apr 22, 2020

I think these features would be nice, especially considering that a lot of contracts now use assembly to access them, which puts an extra burden on the SMTChecker.

cc @leonardoalt

Probably should be considered in conjunction with #4910

@chriseth
Copy link
Contributor

.codeHash, .code, .codeSize? Or .codeLength?

@axic
Copy link
Member Author

axic commented Apr 23, 2020

I think codesize is fine as it is close to the opcode. A user can also do code.length at the cost of memory expansion, unless we want to make a weird shortcut where code.length translates to extcodesize.

Also question: should the compiler generate codesize/codecopy (and not extcodesize/extcodecopy) in case of address(this).codesize and address(this).code?

@chriseth
Copy link
Contributor

Sure, same mechanism as with selfbalance.

@chriseth
Copy link
Contributor

chriseth commented May 6, 2020

Let's implement .code as memory array with a shortcut for .code.length (and for codecopy / extcodecopy)

@axic
Copy link
Member Author

axic commented Sep 24, 2020

We agreed to .code (and .code.length), but there seems to be no clarity on hash. Is it .hash or .codeHash or .codehash? Or adding yet another hack of translating keccak256(...code) in the codegen? I would rather not.

@axic
Copy link
Member Author

axic commented Sep 24, 2020

Or adding yet another hack of translating keccak256(...code) in the codegen? I would rather not.

Actually a good point against this is the push for code merkleization (i.e. EIP-2926) which would change the way the codehash is calculated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change ⚠️ language design :rage4: Any changes to the language, e.g. new features
Projects
None yet
Development

No branches or pull requests

2 participants