-
Notifications
You must be signed in to change notification settings - Fork 66
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
feat: experimental payment v2 migration script #616
Conversation
This commit allow deployment of payment v2 with EXPERIMENT env var flag set to true. Payment V2 here is the exactly same feature set as payment V1.
- add the explanation of using `EXPERIMENT` env var - add explantion of other existing env var in migration scripts - put the deploying.md link to README - add a bit more detailed explantion on `local` and `remote` network flag in README
Smoke test using standard exit
From slack: https://omisego.slack.com/archives/C9KNA675J/p1587376124427600?thread_ts=1587375985.425600&cid=C9KNA675J Ino 3 minutes ago Ino 2 minutes ago Ino 2 minutes ago |
const PAYMENT_V2_TX_TYPE = config.registerKeys.txTypes.paymentV2; | ||
const MERKLE_TREE_DEPTH = 16; | ||
|
||
const alicePrivateKey = '0x7151e5dab6f8e95b5436515b83f423c4df64fe4c6149f864daa209b26adb10ca'; |
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.
Can we load the private key from the the environment?
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 could but why?
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, this key is just for testing - no need to hide it
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.
It's generally a bad practice to have private keys in code.
@boolafish how will that experiment flag be used in the future? For future development will we always have a deployable (and audited) version on master? |
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.
Let's think whether we want to use experimental
in the future - if yes, then let's refactor these scripts, so that they will not need any changes, no matter what experiment is.
- 2000: Future extensions, new exit games, etc. | ||
|
||
## ENV VAR settings | ||
- TENDERLY: set to `true` when needed to push the contract to tenderly. Default not pushing to tenderly. |
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.
- TENDERLY: set to `true` when needed to push the contract to tenderly. Default not pushing to tenderly. | |
- TENDERLY: set to `true` to push the contract to tenderly. Default: `false`. |
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.
Default:
false
.
This is slightly incorrect. It is default to undefined
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.
actually it is false :
const isExperiment = process.env.EXPERIMENT || false;
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.
eh..yes. the || false
part make isExperiment
false. I think what I want to point out is that the env var itself (process.env.EXPERIMENT
) would be considered undefined
, so it is slightly incorrect in this sense.
|
||
## ENV VAR settings | ||
- TENDERLY: set to `true` when needed to push the contract to tenderly. Default not pushing to tenderly. | ||
- DEPLOY_TEST_CONTRACTS: set to `true` when need to deploy some testing contracts like mock, wrapper for conformance testing. Default not deploying test contracts. |
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.
- DEPLOY_TEST_CONTRACTS: set to `true` when need to deploy some testing contracts like mock, wrapper for conformance testing. Default not deploying test contracts. | |
- DEPLOY_TEST_CONTRACTS: set to `true` to deploy helpers contracts like mocks, wrappers for conformance testing. Default: `false`. |
## ENV VAR settings | ||
- TENDERLY: set to `true` when needed to push the contract to tenderly. Default not pushing to tenderly. | ||
- DEPLOY_TEST_CONTRACTS: set to `true` when need to deploy some testing contracts like mock, wrapper for conformance testing. Default not deploying test contracts. | ||
- EXPERIMENT: set to `true` when needed to deploy experimental contracts. For instance, deploying new payment exit game contract to test the flow of extension. |
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.
- EXPERIMENT: set to `true` when needed to deploy experimental contracts. For instance, deploying new payment exit game contract to test the flow of extension. | |
- EXPERIMENT: set to `true` to deploy experimental contracts. For instance, deploying new payment exit game contract to test the flow of extension. Default: `false`. |
@@ -10,11 +10,15 @@ module.exports = async ( | |||
// eslint-disable-next-line no-unused-vars | |||
[deployerAddress, maintainerAddress, authorityAddress], | |||
) => { | |||
const isExperiment = process.env.EXPERIMENT || false; | |||
const initialImmuneExitGames = (isExperiment) | |||
? config.experimental.frameworks.initialImmuneExitGames : config.frameworks.initialImmuneExitGames; |
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.
What about just swapping the used config?
This works only for this additional exit game, but if we switched the whole config, then whatever changes in the future - no changes are required.
const isExperiment = process.env.EXPERIMENT || false; | ||
if (isExperiment) { |
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.
const isExperiment = process.env.EXPERIMENT || false; | |
if (isExperiment) { | |
if (process.env.EXPERIMENT) { |
.circleci/config.yml
Outdated
@@ -72,7 +72,7 @@ jobs: | |||
- setup_truffle_env | |||
- run: | |||
name: Run tests | |||
command: truffle test | |||
command: EXPERIMENT=true npm run test |
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.
what about making parametrising these jobs and running them once forEXPERIMENT=true
and once for EXPERIMENT=false
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 don't think it brings any benefits now and the whole set of tests is pretty time consuming.
Currently test with EXPERIMENT=true
runs all the test suite already.
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.
but, what Im worried about is that now when I run EXPERIMENT=false
Im still getting:
Registering paymentToPaymentCondition (0xf204a4Ef082f5c04bB89F7D5E6568B796096735a) to spendingConditionRegistry
Registering paymentToPaymentV2Condition (0x82D50AD3C1091866E258Fd0f1a7cC9674609D254) to spendingConditionRegistry
Registering feeClaimOutputToPaymentTxCondition (0x0d8cc4b8d15D4c3eF1d70af0071376fb26B5669b) to spendingConditionRegistry
Registering paymentToPaymentV2Condition (0x1411CB266FCEd1587b0AA29E9d5a9Ef3Db64A9C5) to spendingConditionRegistry
Registering paymentV2ToPaymentV2Condition (0x855d1c79Ad3fb086D516554Dc7187E3Fdfc1C79a) to spendingConditionRegistry
Registering paymentV2ToPaymentV3Condition (0x8065F4c7b8c2bf53561af92D9DA2Ea022A0b28Ca) to spendingConditionRegistry
{"authority_address":"0xc5fdf4076b8f3a5357c5e395ab970b5b54098fef","eth_vault":"0x4d2d24899c0b115a1fce8637fca610fe02f1909e","erc20_vault":"0xc8c03647d39a96f02f6ce8999bc22493c290e734","payment_exit_game":"0xcfed223fab2a41b5a5a5f9aaae2d1e882cb6fe2d","plasma_framework_tx_hash":"0x938aa3c16a2840b79c365ffde567d1edaa0e4739402ad89ca60bb7a738e6a418","plasma_framework":"0x345ca3e014aaf5dca488057592ee47305d9b3e10"}
commit: 62b841c7f7673e34760567e7ebaf714c51420591
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.
you mean you set EXPERIMENT=false rpm run test
and it is still printing the log above? 😨
Or can you point me to the setup that you found this?
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 I run migrations scripts on the current HEAD and the problem does not persist (maybe that was sth with my env back then), but still one paymentToPaymentV2Condition
is being registered (do not know if it is an issue though).
$ MULTI_EXIT_GAME_EXPERIMENT=true npx truffle migrate --network local | grep 'Registering.*V2'
Registering paymentToPaymentV2Condition (0x170f89CFed0bE4dd0875c8EB403094B24f7b7b34) to spendingConditionRegistry
Registering paymentToPaymentV2Condition (0x0EEa09b4E919C511Da053bD85cb88A5dD501b541) to spendingConditionRegistry
Registering paymentV2ToPaymentV2Condition (0xc29bE658676d32f16e31AC54C67875a0D1a72298) to spendingConditionRegistry
Registering paymentV2ToPaymentV3Condition (0x1f75D1F63bD0d62e56Cfa7E8B759536649DD467A) to spendingConditionRegistry
$ npx truffle migrate --network local | grep 'Registering.*V2'
Registering paymentToPaymentV2Condition (0xa5a60d16bDC4d5694b2eDF94b144e8513D4E78aE) to spendingConditionRegistry
plasma_framework/config.js
Outdated
@@ -35,6 +35,21 @@ const development = { | |||
erc20: 2, | |||
}, | |||
}, | |||
experimental: { |
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 copy default config and just override changed values? This may make it easier to reason about what changes in comparison to non-experimental
[deployerAddress, maintainerAddress, authorityAddress], | ||
) => { | ||
const isExperiment = process.env.EXPERIMENT || false; | ||
if (isExperiment) { |
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.
same as a few files above
[deployerAddress, maintainerAddress, authorityAddress], | ||
) => { | ||
const isExperiment = process.env.EXPERIMENT || false; | ||
if (isExperiment) { |
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.
☝️
PR review suggestion Co-Authored-By: thec00n <thec00n@fork.at>
Use MUTLI_EXIT_GAME_EXPERIMENT to be the feature flag name instead. Also restructure the config a little bit.
I think the master should always be deployable and that is why using the flag. I think probably each experiment would bring their own flag and can start some POC first quickly in local docker env. Although I don't think we can assume master only have audited contract code....like a new experiment contract would still be merged to master first and probably make it elixir-omg and other downstream dependency code close-to-ready and then do the audit. However, I think master should default to deploy the audited code if without flags. |
@boolafish such an explicit flag, means that each time we want to create docker images, we have not only to create a PR pointing to a commit we want to build, but we also have to change building scripts. Is it ok, or should we think about some more convenient method? Maybe grouping all experimental features under some sth like: and then used like this |
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.
LGTM
@pik694 yeah, I think probably the docker side should be more flexible on injecting the env var then the current PR if we would like to go with explicit feature flag naming. But I don't think we should put the file in this Also, I don't think we need explicit |
Test with commit of this PR from plasma-contracts: 1d25e66420aaa4d23cac145c2ecea64123218b9a Using MULTI_EXIT_GAME_EXPERIMENT flag. omgnetwork/plasma-contracts#616
Test with commit of this PR from plasma-contracts: 1d25e66420aaa4d23cac145c2ecea64123218b9a Using MULTI_EXIT_GAME_EXPERIMENT flag. omgnetwork/plasma-contracts#616
Test with commit of this PR from plasma-contracts: 1d25e66420aaa4d23cac145c2ecea64123218b9a Using MULTI_EXIT_GAME_EXPERIMENT flag. omgnetwork/plasma-contracts#616
Test with commit of this PR from plasma-contracts: 1d25e66420aaa4d23cac145c2ecea64123218b9a Using MULTI_EXIT_GAME_EXPERIMENT flag. omgnetwork/plasma-contracts#616
Test with commit of this PR from plasma-contracts: 1d25e66420aaa4d23cac145c2ecea64123218b9a Using MULTI_EXIT_GAME_EXPERIMENT flag. omgnetwork/plasma-contracts#616
Co-Authored-By: Piotr Żelazko <piotr.zelazko@imapp.pl>
const PAYMENT_V2_TX_TYPE = config.registerKeys.txTypes.paymentV2; | ||
const MERKLE_TREE_DEPTH = 16; | ||
|
||
const alicePrivateKey = '0x7151e5dab6f8e95b5436515b83f423c4df64fe4c6149f864daa209b26adb10ca'; |
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, this key is just for testing - no need to hide it
* feature: add flag to enable experimental contracts' features Refers omisego/new-tx-type-poc#3 * docs: update readme * fix: allow reset to commit in PR branch instead of master Previous setup it would only pull the master by default. Thus you cannot reset to commit still in a PR stage. * test: it works with the experiment flag Test with commit of this PR from plasma-contracts: 1d25e66420aaa4d23cac145c2ecea64123218b9a Using MULTI_EXIT_GAME_EXPERIMENT flag. omgnetwork/plasma-contracts#616 * revert: "test: it works with the experiment flag" This reverts commit d01163d. * fix: grammar Co-authored-by: boolafish <boolafish945@gmail.com>
Note
Add experimental payment v2 contract into the migration scripts.
Chosen the
300+
instead of2000+
to be the migration index to not disrupt with the future deployment. So even if we run this migration script in existing deployed network. It would not take any effect.Also, the deployment is guarded by env var
MULTI_EXIT_GAME_EXPERIMENT
. Need to be set totrue
to deploy the payment v2 contracts.closes: https://github.com/omisego/new-tx-type-poc/issues/2
Test
MULTI_EXIT_GAME_EXPERIMENT
env var in CI and shows sth like:"Registering paymentV2ToPaymentV3Condition (0x963eC3789de59707309bAe6D955E44c7D0756513) to spendingConditionRegistry"
Experimental e2e test with `MULTI_EXIT_GAME_EXPERIMENT` env var