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 ecrecover() builtin for EVM #1543

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

seanyoung
Copy link
Contributor

@seanyoung seanyoung commented Sep 17, 2023

Fixes #1536

@seanyoung seanyoung marked this pull request as ready for review September 17, 2023 18:11
@LucasSte
Copy link
Contributor

Is there a test for this change?

@seanyoung seanyoung force-pushed the ecrecover branch 2 times, most recently from ab69f8f to 252848f Compare September 18, 2023 20:37
@seanyoung
Copy link
Contributor Author

Is there a test for this change?

Now there is 😊

@@ -2186,6 +2186,56 @@ fn expr_builtin(
expr: Box::new(codegen_expr),
}
}
ast::Builtin::ECRecover => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to use Instr::Unimplemented here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why Instr::Unimplemented preferable over an actual implementation?

Copy link
Contributor

Choose a reason for hiding this comment

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

My reasoning is that as you cannot test this portion of code, we could better just use Instr::Unimplemented as we did so for other Ethereum builtins. This would not diminish our test coverage numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which test coverage numbers?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, yolo in code in which we can't test isn't a good practice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I've been outvoted, it's gone

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean it could also be commented out, saying that this is how we think it should be implemented, but it's commented out and an Unreachable instead until we can test it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I've added the code I wrote as a comment

@seanyoung seanyoung added the EVM EVM target label Sep 21, 2023
src/sema/ast.rs Outdated
@@ -1658,6 +1658,8 @@ pub enum Builtin {
Accounts,
UserTypeWrap,
UserTypeUnwrap,
/// EVM only, not implemented yet. This is useful for anyone using Solang to create an AST for EVM contracts
Copy link
Contributor

Choose a reason for hiding this comment

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

The contracts pallet provides ecdsa recovery

@@ -2186,6 +2186,56 @@ fn expr_builtin(
expr: Box::new(codegen_expr),
}
}
ast::Builtin::ECRecover => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, yolo in code in which we can't test isn't a good practice

@seanyoung seanyoung force-pushed the ecrecover branch 2 times, most recently from 90ce9d2 to 488126d Compare September 22, 2023 11:26
Copy link
Contributor

@xermicus xermicus left a comment

Choose a reason for hiding this comment

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

LGTM. Gonna implement it for Polakdot soon, thanks!

@seanyoung seanyoung merged commit 41eab11 into hyperledger-solang:main Sep 22, 2023
16 checks passed
@seanyoung seanyoung deleted the ecrecover branch September 22, 2023 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EVM EVM target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse and resolve error: unknown function or type 'ecrecover'
3 participants