Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Conversation

@jtakalai
Copy link
Contributor

@jtakalai jtakalai commented Mar 30, 2021

New withdraw functionality.

Alpha version is already in NPM, this PR is just adding tests. After that it should be good for master.

@linear
Copy link

linear bot commented Mar 30, 2021

ETH-81 Expose DU2 functions for signature transport

Swash withdraw pattern:

  • browser plugin sends HTTP request to server saying "X wants to withdraw to address A in mainnet, here's the signature"
  • server calls DataUnion.withdraw* function and returns the message-hash M in HTTP reply
  • browser plugin polls the AMB, if the signatures have been collected for message-hash M
  • after signatures have been collected, browser plugin will call DataUnion.transportSignaturesForMessage

Expose the necessary functions for each step of that flow:

  • (signatures already exist)
  • in freeWithdraw mode, return the messageHash(es) from the withdraw promise
    • split transportSignaturesForTransaction into getMessageHashes and move rest of code to _executeWithdraw (for !freeWithdraw), figure out what to do with messageId and whether transportSignaturesForMessage should check if signatures already were transported (required messageId, MAYBE)
  • expose requiredSignaturesHaveBeenCollected
  • expose transportSignaturesForMessage

Juuso Takalainen added 13 commits March 30, 2021 12:36
because the method to do it is transportMessage and that's really all it means, so either it should be the SAME name, or else a bit more descriptive
also using describe.each instead of the homebrew loop. WebStorm recognizes this syntax, so please never use homebrew loops!
apparently ethers doesn't do enough to tell tx.wait() returns a ContractReceipt...
strange that `instanceof String` doesn't actually catch a string
for some reason it was polling every 100ms, which is definitely too much in production
tests should pass now (fingers crossed)
@jtakalai jtakalai requested review from teogeb and timoxley April 22, 2021 07:53
Juuso Takalainen added 13 commits April 22, 2021 13:16
all tests timed out for some reason; could be that now that there are so many cases (5 x 4, I think) it requires the whole thing to run under 5min, which it might not

TODO: turn it down to what's actually needed
bridge timeout probably too low for real world?
also TrReceipt -> ContractReceipt was changed in this PR
making choices based on fairly arbitrary line length limits feels bad man. Adding eslint-disables also feels bad. But I acknowledge it's good to limit line length, in general. I guess.
Date.now() feels a bit hacky, running count is better
All tests run in parallel. Even trying to start bridge "for those cases that need it" ends up bridge paying for other transports as well and every test case being confused. Also for some reason the transport doesn't even happen to the cases that want it. Augh.
@jtakalai
Copy link
Contributor Author

Data union tests are all green. Merging after a review.

just to guard against the super improbable failure of shared ids in parallel-run tests
Copy link
Contributor

@timoxley timoxley left a comment

Choose a reason for hiding this comment

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

Would like it if more functions took options objects instead of positional parameters, my IDE doesn't have the nice positional naming stuff that yours does, but otherwise LGTM.

Juuso Takalainen added 3 commits April 30, 2021 09:45
format strings are MUCH nicer for a lot of things: they show the JS type, also pretty-print objects (no need to JSON.stringify)
One is the property of the bridge, one is the property of the function call, it's like the opposite angle of looking at it.

But I'll still change it so that the name is the same. So freeWithdraw -> !payForTransport everywhere. It's better that way.
@jtakalai jtakalai merged commit 108afd3 into master Apr 30, 2021
@jtakalai jtakalai deleted the ETH-81-expose-signature-transport branch April 30, 2021 15:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants