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 return code to get_block_hash_fn #73

Merged
merged 3 commits into from
Sep 3, 2018
Merged

Add return code to get_block_hash_fn #73

merged 3 commits into from
Sep 3, 2018

Conversation

axic
Copy link
Member

@axic axic commented Aug 20, 2018

Fixes #63.

typedef void (*evmc_get_block_hash_fn)(struct evmc_uint256be* result,
struct evmc_context* context,
int64_t number);
typedef int (*evmc_get_block_hash_fn)(struct evmc_uint256be* result,
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so, but we could consider having another enum for more regular cases.

Success/failure/invalid args.

Copy link
Member Author

Choose a reason for hiding this comment

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

@chfast do we want an enum instead?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know yet. I have the review all similar cases and create the superset of possible error codes. If we end up with up to 4 items we can use it in all cases.

Copy link
Member

Choose a reason for hiding this comment

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

We can merge it with int, but you have to improve documentation of @result and @param number.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we wait for #116 first?

Copy link
Member

Choose a reason for hiding this comment

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

The #116 is ready, just needs review.

@chfast
Copy link
Member

chfast commented Aug 31, 2018

Quick analysis in #117, the int should be fine here.

Should I take it over?

@axic
Copy link
Member Author

axic commented Aug 31, 2018

Still waiting for an answer on
#73 (comment)

r := C.int(0)
if blockhash != (common.Hash{}) {
// All zeroes hash is considered a failure in lookup.
// FIXME: should we instead adjust `ctx.GetBlockHash`?
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is the main question. Leaning towards this.

Copy link
Member Author

Choose a reason for hiding this comment

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

@chfast if you think that's a better idea, can you please push a new commit which changes it? (just leave the current one as it is)

Copy link
Member

Choose a reason for hiding this comment

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

This should be changed to blockhash, err := ctx.GetBlockHash(number). I can push the change later on.

@axic axic changed the title [WIP] Add return code to get_block_hash_fn Add return code to get_block_hash_fn Aug 31, 2018
@@ -160,10 +160,11 @@ typedef struct evmc_tx_context (*evmc_get_tx_context_fn)(struct evmc_context* co
* @param context The pointer to the Host execution context.
* @param number The block number. Must be a value between
* (and including) 0 and 255.
* @return 1 if exists, 0 otherwise.
Copy link
Member

Choose a reason for hiding this comment

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

This comment is wrong. It should be something like 1 if the information is available, 0 otherwise or something better.
Also:

  • The comment for number is wrong. In this case leave "The block number" only and explain when the information is available in the main description.
  • In the result explain that result is written only if the function returns 1 i.e. when information is available.

r := C.int(0)
if blockhash != (common.Hash{}) {
// All zeroes hash is considered a failure in lookup.
// FIXME: should we instead adjust `ctx.GetBlockHash`?
Copy link
Member

Choose a reason for hiding this comment

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

This should be changed to blockhash, err := ctx.GetBlockHash(number). I can push the change later on.

@axic
Copy link
Member Author

axic commented Aug 31, 2018

This should be changed to blockhash, err := ctx.GetBlockHash(number). I can push the change later on.

I do the first fix, but you should do this one.

Will let you know when I pushed my fix.

@axic
Copy link
Member Author

axic commented Aug 31, 2018

@chfast updated, you can take it over now.

@chfast chfast merged commit e799acb into master Sep 3, 2018
@chfast chfast deleted the blockhash branch September 3, 2018 17:58
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