Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Uniswap deployment #263

Merged
merged 162 commits into from
Sep 19, 2019
Merged

Uniswap deployment #263

merged 162 commits into from
Sep 19, 2019

Conversation

liamzebedee
Copy link
Contributor

@liamzebedee liamzebedee commented Aug 27, 2019

Closes #129

This issue breaks away work from #160 into something more deliverable:

Running tests

Integration

cd scripts/
./deploy_uniswap.sh
cd ..
npm run integration-test

Unit

As before:

npm run test


uint256 currentDifficulty = 1;
uint256 previousDifficulty = 1;
uint256 oraclePrice = 10 ** 12;

address public tbtcUniswapExchange;

function initialize(address _tbtcUniswapExchange) external onlyOwner {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use a constructor here? Is there going to be any proxy contract deployment using TBTCSystem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gakonst previously discussed this here - shame that github doesn't autoexpand all resolved items, otherwise it would've been simple to Ctrl+F the PR.

initialize was chosen as this is the pattern used in the KeepFactory. Since the current test migration setup uses utils.deploySystem, which doesn't deal with constructor params, it is also a bit less work. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we'll have to revisit this when working on upgrades but I'd say it's fine for now - at least it's consistent with what we have in other places.

@pdyraga
Copy link
Member

pdyraga commented Sep 16, 2019

I think we are close, we need to sort out Circle configuration and figure out why integration_tests job still lists some unit tests.

Can we add an instruction to tthe PR description on how to run integration tests locally and how to run unit tests?

@liamzebedee
Copy link
Contributor Author

@pdyraga take one more look at PR desc. - will add this to README if it's good.

@pdyraga
Copy link
Member

pdyraga commented Sep 16, 2019

  • ✅ I was able to run unit tests locally without uniswap deployed
  • ✅ I was not able to run integration tests locally without uniswap deployed
  • ✅ I was able to deploy uniswap with deploy_uniswap.sh
  • 🚫 I don't have my integration tests passing
> Compiled successfully using:
   - solc: 0.5.10+commit.5a6ea5b1.Emscripten.clang


  Integration tests
    Contract: Uniswap
      deployment
        ✓ created the tBTC UniswapExchange
      end-to-end trade with tBTC
        ✓ has no liquidity by default

        1) adds liquidity and trades ETH for tBTC

    Events emitted during test:
    ---------------------------

    Transfer(from: <indexed> 0x0000000000000000000000000000000000000000 (address), to: <indexed> 0xAECB81b304068b12D4DF2525C9A59cc2508Fb534 (address), value: 50000000000000000000 (uint256))
    Approval(owner: <indexed> 0xAECB81b304068b12D4DF2525C9A59cc2508Fb534 (address), spender: <indexed> 0x1f7dE91012609539E84768e8433389F23EE637Cb (address), value: 50000000000000000000 (uint256))

(...)

  2 passing (7s)
  1 failing

  1) Integration tests
       Contract: Uniswap
         end-to-end trade with tBTC
           adds liquidity and trades ETH for tBTC:
     Error: Returned error: VM Exception while processing transaction: invalid JUMP at 6050053677bbcd1e6911ca398710e15ed383256ac8424074a6d7e5c53fbf36ab/1f7de91012609539e84768e8433389f23ee637cb:39
      at Object.ErrorResponse (node_modules/truffle/build/webpack:/~/web3-core-requestmanager/~/web3-core-helpers/src/errors.js:29:1)
      at node_modules/truffle/build/webpack:/~/web3-core-requestmanager/src/index.js:140:1
      at node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:112:1
      at XMLHttpRequest.request.onreadystatechange (node_modules/truffle/build/webpack:/~/web3-providers-http/src/index.js:96:1)
      at XMLHttpRequestEventTarget.dispatchEvent (node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
      at XMLHttpRequest._setReadyState (node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:208:1)
      at XMLHttpRequest._onHttpResponseEnd (node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:318:1)
      at IncomingMessage.<anonymous> (node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:289:47)
      at endReadableNT (_stream_readable.js:1139:12)
      at processTicksAndRejections (internal/process/task_queues.js:81:17)



npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] integration-test: `NODE_ENV=test INTEGRATION_TEST=true truffle test`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] integration-test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/piotr/.npm/_logs/2019-09-16T11_23_56_729Z-debug.log

@@ -36,7 +36,7 @@ jobs:
set -ex
npm install
npm run sol:lint
test_solidity:
unit_tests:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are still solidity, I suggest we include that (or contract or something) in the job name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of leaving this until we do have tests in another language? I agree with the original naming, at the same time, I'm not sure if it adds anything to refer to contracts/solidity here - at least until we have other code (and notably, we've got it in tbtc-dapp for now).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

< shrug > ultimately I don't care enough to block this particular PR as we'll border on bikeshedding, but I also don't think it's helpful to avoid detail in general. We already have lint_solidity vs lint_js, for example---doesn't seem crazy to follow the pattern vs trigger another “required jobs” setting dance when we decide we're ready to change the job name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take back my original comment - we do have other Kubes code written here, so it's not strictly true that this is only contract code. Will go ahead and change it.

The linting example helped with this ✌️ - linting addresses styling, which we have two targets for (sol/js). Testing addresses functionality, for which we also have two targets - contracts and infrastructure.

@pdyraga
Copy link
Member

pdyraga commented Sep 16, 2019

Still having the same problem when running integration tests after unit tests:

  Integration tests
    Contract: Uniswap
      deployment
        ✓ created the tBTC UniswapExchange
      end-to-end trade with tBTC
        ✓ has no liquidity by default

        1) adds liquidity and trades ETH for tBTC

    Events emitted during test:
    ---------------------------

    Transfer(from: <indexed> 0x0000000000000000000000000000000000000000 (address), to: <indexed> 0xAECB81b304068b12D4DF2525C9A59cc2508Fb534 (address), value: 50000000000000000000 (uint256))
    Approval(owner: <indexed> 0xAECB81b304068b12D4DF2525C9A59cc2508Fb534 (address), spender: <indexed> 0x9179A545B6A52C44f8d6FA941bFEF04944A6A33e (address), value: 50000000000000000000 (uint256))

(...)

  2 passing (6s)
  1 failing

  1) Integration tests
       Contract: Uniswap
         end-to-end trade with tBTC
           adds liquidity and trades ETH for tBTC:
     Error: Returned error: VM Exception while processing transaction: invalid JUMP at 02cec8c2e544b73319613bf45dca16e87a882815268ffa625de5b0fc37a7b9de/9179a545b6a52c44f8d6fa941bfef04944a6a33e:39
      at Object.ErrorResponse (node_modules/truffle/build/webpack:/~/web3-core-requestmanager/~/web3-core-helpers/src/errors.js:29:1)
      at node_modules/truffle/build/webpack:/~/web3-core-requestmanager/src/index.js:140:1
      at node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:112:1
      at XMLHttpRequest.request.onreadystatechange (node_modules/truffle/build/webpack:/~/web3-providers-http/src/index.js:96:1)
      at XMLHttpRequestEventTarget.dispatchEvent (node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
      at XMLHttpRequest._setReadyState (node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:208:1)
      at XMLHttpRequest._onHttpResponseEnd (node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:318:1)
      at IncomingMessage.<anonymous> (node_modules/truffle/build/webpack:/~/xhr2-cookies/dist/xml-http-request.js:289:47)
      at endReadableNT (_stream_readable.js:1139:12)
      at processTicksAndRejections (internal/process/task_queues.js:81:17)

Scenario 1

  • started ganache-cli
  • deployed uniswap with ./deploy_uniswap.sh
  • ran integration-test, passed
  • ran integration-test again, passed

Scenario 2

  • started ganache-cli
  • ran test, passed
  • ran test, passed

Scenario 3

  • started ganache-cli
  • deployed uniswap with ./deploy_uniswap.sh
  • ran test, passed
  • ran integration-test, failed as above

@pdyraga
Copy link
Member

pdyraga commented Sep 17, 2019

  • ✅ can run unit tests without uniswap deployed, passing
  • ✅ can not run integration tests without uniswap deployed
  • ✅ passing integration tests
  • ✅ passing integration tests when run twice, and when run after unit tests
  • ✅ passing unit tests when run after integration tests

@pdyraga
Copy link
Member

pdyraga commented Sep 17, 2019

Two last outstanding items and I am good to merge:

@nkuba since you requested some changed, do you want to take a look or are you fine with approval just from my side?

pdyraga
pdyraga previously approved these changes Sep 18, 2019
Copy link
Member

@nkuba nkuba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I left some minor comments

implementation/test/integration/UniswapTest.js Outdated Show resolved Hide resolved
implementation/test/integration/UniswapTest.js Outdated Show resolved Hide resolved
implementation/test/integration/UniswapTest.js Outdated Show resolved Hide resolved
implementation/test/integration/UniswapTest.js Outdated Show resolved Hide resolved
implementation/test/integration/UniswapTest.js Outdated Show resolved Hide resolved
implementation/test/integration/UniswapTest.js Outdated Show resolved Hide resolved
@nkuba nkuba merged commit 46a5dfe into master Sep 19, 2019
@nkuba nkuba deleted the uniswap-deployment branch September 19, 2019 07:41
@mhluongo
Copy link
Member

Sorry I'm late to the party, but it looks like the build is broken- any idea what's up?

@nkuba
Copy link
Member

nkuba commented Sep 22, 2019

Sorry I'm late to the party, but it looks like the build is broken- any idea what's up?

Oh, I had the same when I ran it on my local env, but couldn't reproduce it. Seems like it wasn't just my messed up env, but happens on a very first run of the scripts.

I created a ticket for it: #296

@mhluongo
Copy link
Member

🙇

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More realistic Uniswap deployment on testnet
7 participants