Fix StakingEscrow state for upgrading#1345
Conversation
|
Failing CI/CLI test is resolved in #1339 |
| result := memoryAddress | ||
| // copy data to the right position after the array pointer place | ||
| // measureWork | ||
| mstore(add(memoryAddress, 0x140), mload(add(memoryAddress, 0x100))) |
There was a problem hiding this comment.
Is this direct memory addressing the result of previous version not having those two fields? E.g. is it how we will handle similar upgrades in future?
There was a problem hiding this comment.
It's independent from previous version, issue that structure has array pointers between fields. And function stakerInfo returns without array pointers but without gap. To correct translate from returned value to StakerInfo struct need to move tail of memory. In future need to add copying for each new slot of memory
There was a problem hiding this comment.
Still not understanding fully - So this is specific to the upgrade issue with different struct layouts? If we deploy on another network, with a fresh dispatcher and this as the initially deployed contract, then this code will have no effect (rather what effect will it have)?
There was a problem hiding this comment.
I'm afraid I too don't understand. Why is measureWork (L1220) relevant here?
There was a problem hiding this comment.
Oh, is it because pastDowntime and subStakes are arrays? and these arrays in the struct have a different memory structure in storage than when returned by stakerInfo()?
There was a problem hiding this comment.
This means we'd also need to redeploy the token, start with 0 stakes, redistribute, etc. considering our current standing - I think this fix is still the best course of action for this deployment set.
There was a problem hiding this comment.
One of the best responses we can make is some tooling to help mitigate this class of problem in the future. How can we prevent this in CI? (Perhaps another discussion)
There was a problem hiding this comment.
I'm for having this code maybe even in production, because it shows narrow places and we will meet with those type of upgrading on mainnet.
Other idea - do hardfork test (before mainnet), not just redeploy but also break contract and copy information from old to new one
There was a problem hiding this comment.
Well, we don't need to be attached for this deployment set. If we deploy this new contract then at some point we'll still have to do hard fork if we want to deploy in mainnet with the correct structure from the start.
My point is that now is the moment to do unorthodox changes, not just before mainnet.
There was a problem hiding this comment.
@cygnusv I totally agree with that. Nevertheless, it is very valuable to test, how we will do upgrades in similar cases.
I think, incentivized testnet is a good candidate for a "clean" deployment without this patch
2bbbf85 to
f38aad8
Compare
|
Since this fix is deployed anyway... Do we want to go and merge it? |
|
I think we will merge it together 1344. However, there's something I still don't have clear: we're going to merge this but we will deploy at some moment before mainnet (e g. Incentivized testnet) a new version with the correct memory layout from the start, and hence, reverting this fix. Is my understanding correct? In that case, we'd like to open an issue |
|
@cygnusv Yes, that's correct. We need an issue |
|
Created issue #1363, and assigned it a milestone for next testnet release. |
|
Did we ever figure out tooling as a check for this in the future? |
|
Included in #1344 |
Deployed in testnet:
and in master:
and
requirewithdelegateGet(_testTarget, "getPastDowntimeLength(address)", staker)fails inverifyStatebecausepastDowntimein new contract in a wrong slotmeasureWorkandcompletedWorkmust be aftersubStakes