-
Notifications
You must be signed in to change notification settings - Fork 306
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
Simplify get_block_hash() method by returning null hash #155
Conversation
I'm fine with this, I think it's nice to be consistent with functions in #154 and it might simplify calling code in VM. |
bindings/go/evmc/host.c
Outdated
@@ -41,7 +41,7 @@ static inline void go_exported_functions_type_checks() | |||
{ | |||
struct evmc_context* context = NULL; | |||
evmc_address* address = NULL; | |||
evmc_bytes32* bytes32 = NULL; | |||
evmc_bytes32 bytes32; |
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.
These names bytes32
& uint256be
look too much as type names, it confuses me a bit every time.
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.
That's the intention. I have to do hard-core function pointer casts in Go, because cgo (Go's C tool) does not support const
types. Then whenever I change the EVMC part there is no error in Go bindings.
In this "fake" function I'm using the function pointer before case and the one after with exactly the same arguments and return types so this detect almost all mismatches (because non-const types bind to const ones).
docs/EVMC.md
Outdated
@@ -40,6 +40,7 @@ can be referenced as EVMC ABIv3 or just EVMC 3. | |||
2. **Host** – An entity controlling the VM. | |||
The Host requests code execution and responses to VM queries by callback | |||
functions. This usually represents an Ethereum Client. | |||
3. **null hash** – a hash which all bytes are zeros. |
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.
"for which", "in which" maybe? Or maybe just call it "null bytes" for get_block_hash
, too
include/evmc/evmc.h
Outdated
* a given block. If the requested block is not found, then an appropriate | ||
* result code is returned. | ||
* This callback function is used by a VM to query the hash of the header of the given block. | ||
* If the information about the requested block is not available then this is signaled by |
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.
"signalled" and comma before "then"
f38de05
to
d39c179
Compare
This has been rebased. Any comments about the design? |
d39c179
to
6914e23
Compare
Use cases
Possible VM implementations
Conclusions
// Variant with error:
bytes32 hash;
bool success = host->get_block_hash(&hash, number);
assert(success);
if (!success)
hash = {}; // Make is deterministic.
stack[0] = hash; // Variant with null hash:
bytes32 hash = host->get_block_hash(number);
assert(hash != {});
stack[0] = hash; |
6914e23
to
e461b45
Compare
I'm still strictly against this change. Would have preferred not merging it. |
This applies to EVM, but nothing else. The main point of the #73 change was that hera wouldn't need to do black magic (checking if I think this change makes sense if EVMC guarantees that in case of an error the null hash is returned. Which it currently doesn't do. |
What kind of error? |
Continuation of changes in #154.
Reverts #73.