Skip to content
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

v2 #8

Merged
merged 17 commits into from
Apr 25, 2019
Merged

v2 #8

merged 17 commits into from
Apr 25, 2019

Conversation

troggy
Copy link
Member

@troggy troggy commented Apr 11, 2019

Features:

Refactoring:

  • using serverless for deployment and local development
  • 🐌 web3 → ethers 🚀
  • 🐌 babel → sucrase 🚀
  • reusing code from leap-lambda-boilerplate and leap-guardian

Resolves #3, #4, #5, #6.

Required for leapdao/plasma-burner-wallet#4

Features:
- generating proof on a serverside, so user don't have to wait

Refactoring:
- using serverless for deployment and local development
- 🐌 web3 → ethers 🚀
- 🐌 babel → sucrase 🚀
- reusing code from leap-lambda-boilerplate and leap-guardian
@johannbarbie
Copy link
Member

my exit didn't make it into the database:
https://eu-west-1.console.aws.amazon.com/cloudwatch/home?region=eu-west-1#logEventViewer:group=/aws/lambda/exit-market-testnet-manager;stream=2019/04/13/[$LATEST]19d722370044489cb3126f04a5aa126b;start=2019-04-12T14:20:00Z

2019-04-13T14:20:00.723Z    f5c0eec5-db8c-4689-b38e-04e0dc5eae41
{
    "errorMessage": "Value ({\"value\":\"100000000000000000000\",\"color\":0,\"hash\":\"0x834869620fba3aa754c4608cc161e9d6d44f9ffa823765314b39375ae7d9ab1f\",\"from\":\"0x8db6B632D743aef641146DC943acb64957155388\",\"raw\":\"0x035279454abbd45a7372ccc0d38dba6722d89a02802e3808b66708288d27ace2f5ac0013ca28fead0a110f258a0a356084b78afd0f83a553ba970c480de8d95fa33ac6166124e85526e947eda381d0a34e74a8b0d5998e3ba731c82b3ca71a5bb573321bdd89e504bc1443470b7273126a2377d1ceca260a97b08c2eaa5c9f15a9d39ffc0013ca28fead0a110f258a0a356084b78afd0f83a553ba970c480de8d95fa33ac6166124e85526e947eda381d0a34e74a8b0d5998e3ba731c82b3ca71a5bb573321b2eab16af49494316fac704f364a0bd7aab52cad319511f921c2b55c758423fc00013ca28fead0a110f258a0a356084b78afd0f83a553ba970c480de8d95fa33ac6166124e85526e947eda381d0a34e74a8b0d5998e3ba731c82b3ca71a5bb573321b230ecf545a52e4b87bdec71c22f17faf5033edafa989e5e901967f3b651328740013ca28fead0a110f258a0a356084b78afd0f83a553ba970c480de8d95fa33ac6166124e85526e947eda381d0a34e74a8b0d5998e3ba731c82b3ca71a5bb573321b3739e0de0fa76f4f62c980565bf261cb5b85b58dffa628acb6c485801c3bf64a0113ca28fead0a110f258a0a356084b78afd0f83a553ba970c480de8d95fa33ac6166124e85526e947eda381d0a34e74a8b0d5998e3ba731c82b3ca71a5bb573321b0000000000000000000000000000000000000000000000056bc75e2d631000000000b1ee5da9cad3951a875ba45e2114a30f4153edc4000000000000000000000000000000000000000000000009838d4029410e03e800008db6b632d743aef641146dc943acb64957155388\",\"blockHash\":\"0x0aac64763d18c3880141611f3a2a6df2bfd96a7c5013642538bcad63aa846110\",\"blockNumber\":16519,\"transactionIndex\":0,\"to\":\"0xB1eE5da9CAd3951a875ba45e2114a30F4153edc4\",\"gas\":0,\"gasPrice\":\"0\",\"nonce\":0,\"input\":\"0x\"}) for parameter Value is invalid. Value exceeds maximum length of 1024",
    "errorType": "InvalidParameterValue",
    "stackTrace": [
        "Request.extractError (/var/task/src/exitManager/index.js:5799:29)",
        "Request.callListeners (/var/task/src/exitManager/index.js:6486:20)",
        "Request.emit (/var/task/src/exitManager/index.js:6458:10)",
        "Request.emit (/var/task/src/exitManager/index.js:11882:14)",
        "Request.transition (/var/task/src/exitManager/index.js:11221:10)",
        "AcceptorStateMachine.runTo (/var/task/src/exitManager/index.js:12026:12)",
        "/var/task/src/exitManager/index.js:12038:10",
        "Request.<anonymous> (/var/task/src/exitManager/index.js:11237:9)",
        "Request.<anonymous> (/var/task/src/exitManager/index.js:11884:12)",
        "Request.callListeners (/var/task/src/exitManager/index.js:6496:18)"
    ]
}

address: 0x8db6B632D743aef641146DC943acb64957155388

@troggy
Copy link
Member Author

troggy commented Apr 15, 2019 via email

troggy and others added 8 commits April 16, 2019 18:36
* feat: add direct sell support

Given:
- user with plasma tokens wants to fast exit them

Flow:
- user queries /deals endpoint to see if there is a market and liquidity for a given token
- if user decides to proceed, he transfers his tokens to market maker address on plasma. Address is provided by /deals endpoint as well
- user does POST /directSell with { txHash } payload. Market maker should check given tx and payout the user on the root network. Endpoint returns txHash of the payout
- (optionally, for sunDai) user waits for payout tx to mine and executes `burnSender` to get his DAI on the root network

Market maker performs the following checks on provided txHash:
- should be included in a block
- should not be payed out already
- should spend to market maker address
- market should exit for the color in tx
- balance for the token should be enough for payout

Payout rules:
- payout goes to the signer of the tx input
- payout amount is the value of the first output to market maker.

* fix: correct KMS id for mainnet

* fix: endpoint

* feat: call finalizer every 3 minutes

* feat: user fast gasPrice from ethGasStation for payouts

* chore: debug print

* docs: README

* fix: hopefully addressing timeout issue
@troggy troggy merged commit 0b93153 into master Apr 25, 2019
@troggy troggy deleted the feat/v2 branch April 25, 2019 11:52
result[market.color].done += 1;
return this.db.setAsFinalized(exit.utxoId, rsp.hash);
}).catch(e => console.error(e));
}
Copy link
Member

Choose a reason for hiding this comment

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

Rare case when no-await-in-loop rule really helps. Now we waiting for each exit, but maybe would be a good idea to use Promise.all here as well?

Like

await Promise.all(exits.map(exit => {
  return this.sellExit(exit).then((rsp) => { // eslint-disable-line no-await-in-loop
    console.log('Processed sold exit:', exit.utxoId, rsp);
    result[market.color].done += 1;
    return this.db.setAsFinalized(exit.utxoId, rsp.hash);
  }).catch(e => console.error(e))
}));

Copy link
Member Author

Choose a reason for hiding this comment

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

I had the code like this initially, but reworked to sync, because a proper nonce management is required (sellExits sends a transaction) and I haven't figured out the easy way (lame)

Copy link
Member

Choose a reason for hiding this comment

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

I see. That's good then 👍

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

Successfully merging this pull request may close these issues.

add endpoint to query tokens
3 participants