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

Introduce Egoistic Funding #45

Merged
merged 36 commits into from
Mar 19, 2024

Conversation

cryptphil
Copy link
Member

This PR introduced "egoistic funding" where one participant can be tagged to be egoistic using the EgoisticPart array (which does not change the funder interface) such that it waits until all other participants have deposited their amounts before continuing to deposit.

The background to this is that in PerunX, the hub should not deposit until the client has deposited its funds to prevent losses due to gas costs if the client never actually deposits.
As a consequence, the Perun Websocket Backend needs to be adapted that one of the participants can register as egoistic (maybe even in the Initialize message?) and the WebSocket Backend provides information this to the funder.

@cryptphil cryptphil force-pushed the draft/egoistic-funding branch 2 times, most recently from 045c784 to 2653189 Compare January 19, 2024 12:29
channel/funder.go Outdated Show resolved Hide resolved
matthiasgeihs and others added 25 commits February 27, 2024 09:45
…r-labs#33)

* CI: Diff binding instead of go test

Signed-off-by: Matthias Geihs <[email protected]>

* Update binding

Use same compiler version as in CI.

Signed-off-by: Matthias Geihs <[email protected]>

Signed-off-by: Matthias Geihs <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
- The method did not have a pointer receiver and thus could not set the
  value, resulting in the previous (default) value instead of the just
  unmarshalled one.
- Additionally, the order was different from `Asset.MarshallBinary`,
  which meant unmarshalling a value just marshalled would result in
  the wrong value or an error.

The added test coveres both these cases.

Signed-off-by: Jens Winkle <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
One of the participants can be egoistic and only deposits only if the other(s) have deposited their amount

Signed-off-by: Philipp-Florens Lehwalder <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
Fix WaitForOthersFundingConfirmation to wait for all assets to be confirmed.
Works only for same-chain Swap.
For cross-chain we need coordination between funders -> go-perun.

Signed-off-by: Sophia Koehler <[email protected]>
… uses the AdjudicatorReq object during conclusion of a channel. Also remove functions that are necessary for the Secondary option.

Update(go.mod/go.sum): Update go.mod and go.sum to the most recent go-perun commit.

Signed-off-by: Ilja von Hoessle <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
…ce since v0.10.7.

* fix(channel/test): Include Randomizer for AppID type to generate random AppIDs for tests.
* fix(client/client_test.go): Adapt appID to the new AppID type.
* fix(channel/backend.go): Adapt app generation to new AppID type, include NewAppID method.
* fix(channel/subscription.go): Adapt convertEvent to new AppID type.
* chore(go.mod, go.sum): Update go-perun version to a v0.10.7 commit.

Signed-off-by: Ilja von Hoessle <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
Signed-off-by: Ilja von Hoessle <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
…nction

Signed-off-by: Ilja von Hoessle <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
* channel: Include shared Nonce object, incrementing the nonce of an account while the transaction is broadcast. Implement sync.Mutex, locking the nonce incrementals.
In erc20_depositor.go, the depositing process is locked during the "Approve" function call with ```lockKey```. The function ```(d *ERC20Depositor) Deposit``` is renamed to `````(d *ERC20Depositor) DepositOnly`

* client: To avoid timeouts caused by the added locking mechanism during ERC20 deposits, ```context.WithTimeout``` and ```twoPartyTestTimeout``` has been increased in fund_test.go and payment_test.go.

* client/test: Timeouts have been increased to avoid premature timeout errors due to the locking mechanism above.

---------

Signed-off-by: Ilja von Hoessle <[email protected]>
Signed-off-by: sophia1ch <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
Remove unused SharedNonceMtx.

Signed-off-by: sophia1ch <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
refactor(erc20_depositor):
- Create seperate function for Approval.
- Rename lock and mutex.

Signed-off-by: sophia1ch <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
- Add description to Approve function.
- Put Error as last return element in Approve function.
fix(erc20_depositor):
- remove unnecessary locking of depositLocksMtx.

Signed-off-by: sophia1ch <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
Fix comment and Argument order for Linter.

Signed-off-by: sophia1ch <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
Signed-off-by: sophia1ch <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
Co-authored-by: Philipp Lehwalder <[email protected]>
Signed-off-by: Sophia <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
- Change SharedMutex to SharedExpectedNoncesMutex.
refactor(erc20_depositor):
- Return directly if Approval returns error.
- Fix comments.

Signed-off-by: sophia1ch <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
Change position of bracket.

Signed-off-by: sophia1ch <[email protected]>
Signed-off-by: Sophia Koehler <[email protected]>
This reverts commit fe3c63f.

Signed-off-by: Sophia Koehler <[email protected]>
@sophia1ch sophia1ch force-pushed the draft/egoistic-funding branch from 91b3ddd to 13b8e9b Compare February 27, 2024 08:45
@sophia1ch sophia1ch marked this pull request as ready for review February 27, 2024 08:46
@sophia1ch sophia1ch requested a review from NhoxxKienn March 12, 2024 13:35
Copy link
Contributor

@NhoxxKienn NhoxxKienn left a comment

Choose a reason for hiding this comment

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

LGTM

channel/funder.go Show resolved Hide resolved
channel/funder.go Outdated Show resolved Hide resolved
@sophia1ch sophia1ch requested a review from NhoxxKienn March 19, 2024 08:01
Copy link
Contributor

Choose a reason for hiding this comment

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

Mock implementation of Wire Handshake and won't ensure authenticity. We probably can first merge this, but need also to create an issue and a separate PR to implement wire authentication for Perun-Eth-Backend.

Copy link
Contributor

Choose a reason for hiding this comment

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

See above.

@sophia1ch sophia1ch merged commit 06cea29 into hyperledger-labs:main Mar 19, 2024
6 checks passed
@cryptphil cryptphil changed the title Draft: Introduce Egoistic Funding Introduce Egoistic Funding Mar 19, 2024
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.

6 participants