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

Check Expr length when converting to abi.Address #414

Closed
jasonpaulos opened this issue Jun 23, 2022 · 4 comments
Closed

Check Expr length when converting to abi.Address #414

jasonpaulos opened this issue Jun 23, 2022 · 4 comments

Comments

@jasonpaulos
Copy link
Contributor

Right now abi.Address.set called with an Expr argument does not verify at runtime that the length of the argument is in fact 32 bytes:

return self.stored_value.store(value)

Without this verification, it's possible for the address variable to contain an invalid value.

There is some precedent for verifying this constraint, namely the checks that occur in abi.Uint.set when called with an Expr:

def set(self: T, value: Union[int, Expr, "Uint", ComputedValue[T]]) -> Expr:

@barnjamin
Copy link
Contributor

I guess we may also want to verify at runtime the transaction types are accurate?

@cusma
Copy link

cusma commented Jun 23, 2022

@jasonpaulos @barnjamin would be good also to generate checks that abi.Bool value is actually Int(0) or Int(1).

@jasonpaulos
Copy link
Contributor Author

jasonpaulos commented Jun 23, 2022

I guess we may also want to verify at runtime the transaction types are accurate?

Yes, this is even more important.

edit: #427

@jasonpaulos @barnjamin would be good also to generate checks that abi.Bool value is actually Int(0) or Int(1).

We do this one correctly!

Assert(self.stored_value.load() < Int(2)),

Though I wonder if it would be more consistent with the rest of the AVM to convert values greater than 1 to 1. This is how the && and || opcodes behave.

@ahangsu
Copy link
Contributor

ahangsu commented Jul 1, 2022

fixed by #432

@ahangsu ahangsu closed this as completed Jul 1, 2022
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

No branches or pull requests

4 participants