-
Notifications
You must be signed in to change notification settings - Fork 377
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
Upgrade contracts to v0.14.0 #3581
Upgrade contracts to v0.14.0 #3581
Conversation
@@ -333,7 +331,7 @@ def private_rooms(): | |||
@pytest.fixture | |||
def environment_type(): | |||
"""Specifies the environment type""" | |||
return Environment.PRODUCTION | |||
return Environment.DEVELOPMENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use latest version of contracts in tests. This is needed since the production mode still uses an old version of the contract where the interfaces in the new contract version were broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then this is a breaking change that is not backwards compatible. When will we release this? If we do, I think it's the right time to also do #3254
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... i think it is backwards compatible because for people running Red eyes, using newer version of Raiden with this change is not going to break their existing nodes as they use "production" mode and that uses a specific contract version which is defined in Raiden as 0.4.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a definition for backwards incompatibility. I remember we did discuss this in person, but I'm lacking the vocabulary to talk about this.
My understand persists though, this will not work with previous clients so we might as well fix the messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in the office, this is only for the Development contracts. Which means not the ones deployed on the mainnet. The point of breaking compatibility with red eyes is when we switch the Environment.PRODUCTION
variable to point to anything other than Red Eyes.
So that would be the best point to have the message changes and any other backwards compatibility breaking changes we can fit in.
@rakanalh shall I take over, proceed, and ask you questions when things get foggy? |
@pirapira thanks for suggesting to take over... there were only some CLI tests that need to be fixed by the time i left this PR. Most of the other work has already been done. |
Codecov Report
@@ Coverage Diff @@
## master #3581 +/- ##
==========================================
- Coverage 77.56% 77.22% -0.34%
==========================================
Files 104 103 -1
Lines 13880 13713 -167
Branches 1942 1923 -19
==========================================
- Hits 10766 10590 -176
- Misses 2451 2460 +9
Partials 663 663
Continue to review full report at Codecov.
|
@@ -104,18 +136,20 @@ def add_token(self, token_address: TokenAddress, given_block_identifier: BlockSp | |||
|
|||
checking_block = self.client.get_checking_block() | |||
error_prefix = 'Call to createERC20TokenNetwork will fail' | |||
|
|||
arguments = [token_address] + additional_arguments | |||
gas_limit = self.proxy.estimate_gas( | |||
checking_block, | |||
'createERC20TokenNetwork', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we would merge the two smart contracts into one, which would allows us to remove the limits and have an easy upgrade, did that change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related issue raiden-network/raiden-contracts#694
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We always have limits. Sometimes it's MAX_UINT256
, meaning no limits.
@@ -452,6 +467,11 @@ def set_total_channel_deposit( | |||
if channel_state is None: | |||
raise InvalidAddress('No channel with partner_address for the given token') | |||
|
|||
if self.raiden.config['environment_type'] == Environment.PRODUCTION: | |||
per_token_network_deposit_limit = RED_EYES_PER_TOKEN_NETWORK_LIMIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't this going to be provided by the smart contract itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the latest change in the contracts, limits are no longer hard coded there but rather, they're specified once the contract is instantiated on-chain. For the existing Red eyes contracts, the limits are hard coded and we need to work with them, so that's what i am doing here.
I am guessing that what you expect is for a query to fetch the limits for the Red eyes contracts and then just use those right? If that's the case, i thought about it and opted for defining the limits in Red eyes since they're not going to change in the contracts anyway so i would shave-off the additional query. Let me know if you think this must be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the existing Red eyes contracts, the limits are hard coded and we need to work with them, so that's what i am doing here.
So, maintaining support for old contracts versions, but we are not maintaining compatibility across contract networks? why don't we just drop support for the old red eyes altogether?
Let me know if you think this must be changed.
Not really, a comment would be helpful though. An alternative is to use inheritance and have that optimization hidden in a RedEyes
subclass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't drop support for Red Eyes at this point when we have no other mainnet release ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't drop support for Red Eyes at this point when we have no other mainnet release ready.
That's okay, but IMO we should not deploy the new smart contracts in the mainnet without the message fix, since the networks will be disjoint.
else: | ||
registry.add_token_without_limits( | ||
token_address=to_canonical_address(token.contract.address), | ||
given_block_identifier='latest', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: The places which are using given_block_identifier='latest'
will have to be upgraded to follow the consistent view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we use latest
only in tests... i have checked if i am using this in other places in the code but my code doesn't really change anything that wasn't already using "latest".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, but the problem persists, the tests are susceptible to the same race conditions, I would argue that in the tests because we use PoA it's even more likely to happen.
As discussed during standup, I am giving this a review. |
@@ -333,7 +331,7 @@ def private_rooms(): | |||
@pytest.fixture | |||
def environment_type(): | |||
"""Specifies the environment type""" | |||
return Environment.PRODUCTION | |||
return Environment.DEVELOPMENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in the office, this is only for the Development contracts. Which means not the ones deployed on the mainnet. The point of breaking compatibility with red eyes is when we switch the Environment.PRODUCTION
variable to point to anything other than Red Eyes.
So that would be the best point to have the message changes and any other backwards compatibility breaking changes we can fit in.
token_address=token, | ||
channel_participant_deposit_limit=RED_EYES_PER_CHANNEL_PARTICIPANT_LIMIT, | ||
token_network_deposit_limit=RED_EYES_PER_TOKEN_NETWORK_LIMIT, | ||
given_block_identifier='latest', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As also discussed in the office with @hackaugusto please replace all these 'latest'
with appropriate blockhashes, or make an issue pointing to them and having as the issue's task to do it.
Can you directly update to 0.14? That fixes a problem in the services that we found in 0.13 |
@palango yup... i upgraded to 14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So looking a lot better!
I added a small commit to fix a typo.
Two remaining comments:
- The development version of the contracts seems wrong
- Some uses of 'latest' remain.
@@ -46,6 +46,6 @@ | |||
ETHERSCAN_API = 'https://{network}.etherscan.io/api?module=proxy&action={action}' | |||
|
|||
RED_EYES_CONTRACT_VERSION = '0.4.0' | |||
DEVELOPMENT_CONTRACT_VERSION = '0.3._' | |||
DEVELOPMENT_CONTRACT_VERSION = '0.10.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be 0.14.0 ???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pypi package's version is different than the ones we have for contracts-version.
pypi version: 0.14.0
contracts version: 0.10.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duh ... 😅
I remember last week I was explaining that to someone and now even I got confused. We gotta do something about the drift between packages and contract version. If it confused us, imagine the users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Maybe contract_version
should just look very different. raiden-network/raiden-contracts#584
else: | ||
registry.add_token_without_limits( | ||
token_address=token, | ||
given_block_identifier='latest', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this file you seem to still have 'latest' blocks. Will you use blockhash as we discussed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to create a separate issue for converting tests to use the actual blockhash instead of latest
... but that's going to be in a different PR/issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough! Please do though, I normally would ask for the issue to be created first so we don't forget but let's get this merged since it's open for a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created: #3619
This is a pre-requisite for #3511.
Separated into it's own PR to simplify the review process