-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
Raise exception on internal payable function declaration #3123
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3123 +/- ##
===========================================
- Coverage 88.49% 67.37% -21.13%
===========================================
Files 95 95
Lines 10759 10757 -2
Branches 2265 2201 -64
===========================================
- Hits 9521 7247 -2274
- Misses 796 2867 +2071
- Partials 442 643 +201
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
i'm not convinced this is a good solution. can |
i think a better solution is to allow |
IMHO the modifier |
I don't think you can access msg.value from internal, nonpayable functions. EDIT: you can't, so banning |
right - you are absolutely correct, I just tested that as well. But still, it doesn't feel right to use that modifier twice. Also, I would strive for some consistency with Solidity (in order to make onboarding overall easier for new devs) where it's disallowed to use |
@pcaversaccio since internal is now optional, should |
Hmm, I personally dislike implied behaviour. I think it could be confusing that functions are now |
This currently compiles and would imply for both functions an @payable
def _sending() -> uint256:
return 1
def sending() -> uint256:
return 1 |
For me |
transfer of ether doesn't target an external function, it targets an account. the transfer happens outside of bytecode interpretation. if an external function is nonpayble, we check that the associated message has zero associated value, if it's payable, it's nop so it's like an assert which can be used to sanity check the given flow through the contract i think that the problem partly lies in the naming - i'd prefer modifiers like also, i think that from UX i probably prefer |
yea, it would be breaking - calling an internal function would now fail as it would be promoted to external one |
What I did
Added an exception when a function is declared as both
payable
andinternal
as reported in #3099 (pure
functions are also mentioned in the issue but are now already prevented from being declaredpayable
).How I did it
Check function visibility and state mutability during validation and raise a
FunctionDeclarationException
exception if a function is found to be bothpayable
andinternal
.How to verify it
Run the
test_invalid_conflicting_decorators
test added totests/parser/features/decorators/test_payable.py
.Commit message
Raise exception on internal payable function declaration
Description for the changelog
Prevent internal functions from being declared as payable
Cute Animal Picture