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

Finalization of the Backend #7

Open
wants to merge 107 commits into
base: main
Choose a base branch
from
Open

Finalization of the Backend #7

wants to merge 107 commits into from

Conversation

iljabvh
Copy link
Collaborator

@iljabvh iljabvh commented Feb 16, 2024

No description provided.

janbormet and others added 30 commits July 24, 2023 13:01
This implements conversion between the types from the
backend/go-perun (types.Participant, channel.State, channel.Params) and
our wire representation types of the contract-types.
wire: Implement XDR encoding and Decoding of contract types
…dd MakeAccountAddress and ToAccountAddress functions. wire: Move MakeAccountAddress and ToAccountAddress to channel/types to avoid cyclic imports.
* Adapt tests to change of type

wire: Include initialization of backend and randomizer for go-perun tests

* Add tests for ToState, MakeState, ToParams, MakeParams.

* Modify error handling

wallet: Include NewRandomAddress for go-perun tests

go.mod, go.sum: Update stellar/go library commit hash
* Adjust the remaining subpackages to this change

* Change error handling t.Fatal -> require

wire: Move test files to wire, rename package

wallet: Move Randomizer initialization to wallet/test

go.mod, go.sum: Adjust packages to fixes
return errors instead of panic in StellarAsset methods

wire: Use methods from go-perun to make allocation for go-perun state
interfaces, event handling

channel/env: Add StellarClient to connect to the Stellar blockchain
 and Soroban.

 client: Implement payment channel workflow by adding PaymentChannel
 and PaymentClient

 services/horizon/docker, testdata: Add docker files and Stellar client binaries
  to ensure Soroban functionality, as imeplemented in Protocol 20
  in the stellar/go SDK.
channel: Finalize Funder workflow, simplify Stellar transactions

channel/env: Change StellarClient interaction

util: Remove global contract path constant
channel: small formatting changes

.assets: Add Perun image for README
channel: Remove comments
channel: Increase DefaultSubscriptionPollingInterval,
DefaultPollingInterval constants to allow slow query
responses during listening of
adjudicator events.

Remove comments and Println statements.

testdata: Include perun_soroban_token.wasm,
implementing generic Stellar asset tokens
channel: Adapt channel to Token Asset contract.
Include transactions that realize the asset token contract functions.
wire: Include string encoding for ScVal
channel: Include contract function calls and arguments to invoke stellar asset token functions. Also, extend IntegrationTestEnv functionality.
util: Modify Deploy function to output contract id hash
env: Keep simulateTransaction function from integration test environment
…de Payments between clients

channel: Increase buffer size to arbitrarily high value, include "transfer" event hotfix.

env: Add BuildGetTokenBalanceArgs function.

util: Add wrapping functions to generate accounts and to make it easier to create a payment demo.
channel: Remove xdr.SorobanAuthorizationEntry since the authorization is completed by stellar/go since the recent versions. Also remove makePreImgAuth, which was used to calculate the Signature field in the SorobanAuthorizationEntry. This is now obsolete.

channel/env: Remove the TestInteractContract function, which was used to invoke the testinteract function of the payment channel contract. This was used for testing purposes only and is now obsolete.
Include a global shared mutex, sharedMtx, to prevent both users invoking the same contract function at the same time.

util: Remove CreateFundNewRandomStellarKP, which is now substituted by CreateFundStellarAccounts. Remove SorobanAuthorizationEntry and the i128Param function because it is unused.

testdata: perun_soroban_contract and perun_soroban_token are updated to represent the most recent versions of the contracts.
… for testing and debugging purposes only and is now obsolete.
iljabvh added 5 commits April 4, 2024 10:52
…ity from the channel package, use the buildtx types from the client package, stored in buildtx.go.
…d funding and funds retrieval calling abort_funding.

* refactor(channel): Implement TimeoutError to track failed user funding. Define makeTimeoutErr for this.

* feat(channel/test): Decrease DefaultTestTimeout to have a stricter timeout limit.

* fix(client): Fix abort_funding call in Client.Abort
…f a final state after funding and one state update.
iljabvh and others added 24 commits April 9, 2024 12:54
…terface, add EventType field. Add GetType() method to show event type. Add Assert...Event functions to test for events related to contract calls.

* refactor(client): Add checks for events after contract calls. Also add error handling for cases in which events are not triggered during the present call.

* refactor(channel): Adapt to changes in event package.
… error in this place.

* refactor(client): Add ErrCouldNotDecodeTxMeta to use it in InvokeAndProcessHostFunction.
…atorSubscription in go-perun. In run method, do not return if adjEvent is found.

* refactor(channel/subscribe.go): Add IMPORTANT fix: In the DifferencesInControls function, if current state and next state are both Closed in the payment contract, then return a CloseEvent. This  triggers a ConcludedEvent in Next(). This fix removes potential problems in edge cases in which the contract is closed, but no event was caught. This could have blocked the conclusion of the channel. The added code prevents such cases and guarantees that a closed channel in the contract is always detected.
Rename variables in Next() to be more descriptive.

* test(channel_test): Add client_test.go, testing the go-perun client functionality with the payment channel workflow.

* refactor(channel/test): Add wallet.EphemeralWallet as return value in MakeRandPerunAccWallet(), satisfying requirements in the client_test.go test. Improve file path parsing, using getDataFilePath.

* refactor(event): Rename PerunEvent methods to adhere to AdjudicatorEvent interface from go-perun.

*add(payment): Add payment package to include test infrastructure for the go-perun client, used by client_test.go.
Remove global mutex from client package, in favor of a mutex in the Client struct.
…sting. For this purpose, several new types were introduced. The Invoker interface is introduced for broadcasting contract invocations. The StellarSigner is introduced to sign and the ContractBackend struct uses the StellarSigner to sign, and the Invoker to broadcast transactions.
Separate signing and broadcasting of contract calls
…ccount to initialize the TransactorConfig struct.
* feat(channel/AppID): Add AppID struct as a universal identifier for dApps

* chore(channel/backend): Add NewAppID() method to satisfy the backend interface of go-perun v0.11.0

* chore(wallet/types): Wrap Stellar address type keypair.FromAddress into wallet.Address interface to use it inside the AppID struct required by go-perun v0.11.0
* fix(channel/test): Correct error message in InitTokenContract function
* feat(channel): Adapt channel functionality to support multiple assets on one channel, tested for two assets.

* feat(client): Adapt contract invocation to new version, temporarily hard coding a transaction fee to 500000 stroops.

* feat(payment): Adapt payment channel test/demo to two-asset channels

* feat(testdata): Add multichannel contract, perun_soroban_multi_contract.wasm.

* feat(wire): Adapt encoding between contract types and backend types to multi-asset channels.
…ich the channel is deleted after the second withdrawal (Bob's withdrawal). Hence, GetChannelInfo returns no channel state anymore after a successful withdrawal.

* docs(channel, client): Add logs (temporarily).

* test(payment/test, payment_test): Modify TestHappyPerun to test swap.

* fix(testdata): Update contract perun_soroban_multi_contract.wasm, including the multiasset fixes.
…ance

* refactor(payment_test/client_test.go): Change initial balance to have more general swap case.

* chore(payment/test/client.go): Remove Printing of initAlloc.

* fix(wire/balances.go): Fix balance mismatch, introduced by multiasset feature.
…ding a signed transaction - decode the result of the simulated transaction result
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.

2 participants