-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
Failing test case for debugging constant inherited arguments #320
Conversation
@fubuloubu After doing some research it's not only an issue
I should be to the bottom of this shortly, looking into the opcode calls now. |
Yeah, I just added |
It makes sense, I was just noting it. |
@fubuloubu I figured out the opcodes to get it working properly, mind if I make a PR or I can push to your repo if you'd prefer. |
Push to my repo probably best so this PR will pass CI |
Hey, I got msg.sender persist by using |
@DavidKnott not sure I entirely understand what you are saying, but from what I understand the context shifts from the client ( Curious as to why this context shift is necessary and what might be causing the shift if it is unintentional. |
Do you have a specific line you can point to where the context shift occurs? |
Yes, exactly. Basically when I change the context to keep client(msg.sender) Yes, in Parser line 772 |
Man that file is super large and needs to be cleaned up. Hmm. I could see Summary:
Definitely a significant change proposal there worth discussion. @vbuterin, what do you think? |
@DavidKnott can you post what your currently solution is? (diff fmt?) |
Sure, though I think the change I made is wrong as I'm not sure how to get
The above code checks that the |
24721b5
to
d67366e
Compare
Rebased this to latest updates. |
Analyzing the IR it appears that whenever I believe this implicit context change is somewhat dangerous if the contract coder does not understand this nuance, e.g. using a function directly produces different results than if used internally inside another function. As an example: balance: currency_value[address]
pending: {from: address, to: address, amt: currency_value}[num]
def pay(_to: address, _amt: currency_value):
assert self.balance[msg.sender] >= _amt
self.balance[msg.sender] -= _amt
self.balance[_to] += _amt
def accept(tx_id: num):
assert msg.sender == self.pending[tx_id].from
self.pay(self.pending[tx_id].to, self.pending[tx_id].amt)
self.pending[tx_id] = None # Delete
... If you called An obvious solution here is to specify both parties in the @vbuterin @DavidKnott thoughts? |
Figured it out. I'm assuming the original intent was that @vbuterin @DavidKnott thoughts? P.S. When I make the update from |
@fubuloubu I think Viper needs both, I prefer using msg.sender over tx.origin because it's easier to control. Tx.origin messes things up when you have contracts interacting with one another see (this and this). Basically msg.sender shouldn't change between function calls but should change between contract calls (I believes msg.value should behave similarly). |
Kind of revisited this for a bit today. @DavidKnott are you trying to say that there is a potential problem here with how |
@fubuloubu I'll look into this again tomorrow and get back to you tomorrow, right now I suspect it's a fixable issue with viper. |
Looking at these lines in parser.py again, It seems like it's making a call to something that is in EVM. Namely, I think that references to these opcodes. If solidity doesn't have this same problem, then I would agree something in Viper has to be wrong, but I'm not as familiar with Solidity. That, or I am totally misunderstanding what the problem is here. Let me know what you find. |
I copied the failing test case over to Solidity here and it seems to work fine. You must be right there is probably an issue with something on the Viper end. Although, doesn't viper use a different implementation of the EVM? |
@fubuloubu I looked into how Solidity maintains Generally speaking, I think the |
@fubuloubu I talked to Vitalik and as of now the proper way to use |
I will close this PR then because there's nothing unique in this additional test case. |
See #315
Looking for help resolving this problem as the compiler should be passing through all the inherited arguments (e.g.
msg.sender
) in the context call to a function from within another function.