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

Multi Group Transfer #424

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Multi Group Transfer #424

wants to merge 22 commits into from

Conversation

pragmaxim
Copy link

@pragmaxim pragmaxim commented Sep 20, 2024

Demonstration of the future node's multi group transfer and how it could simplify transfers on Lending example.
Done some perf testing too :

  1. Distributing alphs among users completed in 174 milliseconds // this initial mutli-group transfer is very fast
  2. Check user0, user1, user2 balances completed in 742 milliseconds
  3. user0 lends to user1 and user2 completed in 831 milliseconds // but further lending multi-group transfers are slow
  4. user1 lends to user2 completed in 739 milliseconds
  5. Check user0, user1, user2 balances completed in 733 milliseconds
  6. user1 returns to user0 completed in 438 milliseconds
  7. user2 returns to user0 and user1 completed in 799 milliseconds
  8. Check user0, user1, user2 balances completed in 706 milliseconds

The reason of the latter multi-group transfers taking longer time than the first one is that this is devnet where block is internally mined for incoming transactions.

Also please take into consideration that this is my laptop with many apps running, not a benchmark.

@@ -118,7 +118,7 @@ export abstract class SignerProviderSimple extends SignerProvider {
return signResult
}

protected abstract getPublicKey(address: string): Promise<string>
abstract getPublicKey(address: string): Promise<string>
Copy link
Author

@pragmaxim pragmaxim Sep 26, 2024

Choose a reason for hiding this comment

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

Please let me know if the SignerProviderSimple can have this method public. Not important much, it would be easier to have a single method for build+sign+submit with just a PrivateKeyWallet

@pragmaxim
Copy link
Author

pragmaxim commented Sep 26, 2024

Guys openapi tests and tests are failing because the update-schema:alephium script is pointing to alephium/ repo where this endpoint does not exist yet, they pass locally though.

@pragmaxim pragmaxim marked this pull request as ready for review September 26, 2024 07:15
@pragmaxim pragmaxim requested review from nop33, h0ngcha0 and Lbqds and removed request for nop33 September 26, 2024 09:05
@pragmaxim pragmaxim changed the title Multi Group Transfer [WIP] Multi Group Transfer Oct 7, 2024
@pragmaxim pragmaxim changed the title [WIP] Multi Group Transfer Multi Group Transfer Oct 7, 2024
@pragmaxim
Copy link
Author

pragmaxim commented Oct 7, 2024

@h0ngcha0 the lending and transactions multi-group tests started failing after merging the new features in dev-alephium/master on error :

Failed in validating tx `foo` due to NonExistInput: `bar` 

Tried to troubleshoot but it will be a longer search, please let me know if you can think of the reason 🙏

test/lending.test.ts Outdated Show resolved Hide resolved
@h0ngcha0
Copy link
Member

h0ngcha0 commented Oct 7, 2024

@h0ngcha0 the lending and transactions multi-group tests started failing after merging the new features in dev-alephium/master on error :

Failed in validating tx `foo` due to NonExistInput: `bar` 

Tried to troubleshoot but it will be a longer search, please let me know if you can think of the reason 🙏

I think there is a race condition here due to

 return await Promise.all(
   buildTxResults.map(async (tx) => {
     return await signer.signAndSubmitUnsignedTx({
       signerAddress: params.signerAddress,
       unsignedTx: tx.unsignedTx
     })
   })
 )

devnet mine one tx into block at a time, so if the 2nd tx gets in before the 1st one, it will report NonExistInput error. If we do something like:

    const results: SignTransferTxResult[] = []
    for (const tx of buildTxResults) {
      const result = await signer.signAndSubmitUnsignedTx({
        signerAddress: params.signerAddress,
        unsignedTx: tx.unsignedTx
      })
      results.push(result)
    }
    return results

it should work.

# Conflicts:
#	.project.json
#	artifacts/add/Add.ral.json
#	artifacts/add/AddMain.ral.json
#	artifacts/add/DestroyAdd.ral.json
#	artifacts/greeter/Greeter.ral.json
#	artifacts/greeter/GreeterMain.ral.json
#	artifacts/nft/DeprecatedNFTTest1.ral.json
#	artifacts/nft/DeprecatedNFTTest2.ral.json
#	artifacts/nft/DeprecatedNFTTest3.ral.json
#	artifacts/nft/DeprecatedNFTTest4.ral.json
#	artifacts/nft/DeprecatedNFTTest5.ral.json
#	artifacts/nft/DeprecatedNFTTest6.ral.json
#	artifacts/nft/DeprecatedNFTTest7.ral.json
#	artifacts/nft/MintNFTTest.ral.json
#	artifacts/nft/NFTCollectionTest.ral.json
#	artifacts/nft/NFTCollectionWithRoyaltyTest.ral.json
#	artifacts/nft/NFTTest.ral.json
#	artifacts/nft/NFTTestStd.ral.json
#	artifacts/nft/WithdrawNFTCollectionTest.ral.json
#	artifacts/nft/WrongNFTTest.ral.json
#	artifacts/sub/Sub.ral.json
#	artifacts/test/Assert.ral.json
#	artifacts/test/CallScript0.ral.json
#	artifacts/test/CallScript1.ral.json
#	artifacts/test/Debug.ral.json
#	artifacts/test/InsertIntoMap.ral.json
#	artifacts/test/MapTest.ral.json
#	artifacts/test/MapTestWrapper.ral.json
#	artifacts/test/MetaData.ral.json
#	artifacts/test/MultiDeposit.ral.json
#	artifacts/test/MultiWithdraw.ral.json
#	artifacts/test/OwnerOnly.ral.json
#	artifacts/test/RemoveFromMap.ral.json
#	artifacts/test/TemplateArrayVar.ral.json
#	artifacts/test/TestAssert.ral.json
#	artifacts/test/Transact.ral.json
#	artifacts/test/UpdateMapValue.ral.json
#	artifacts/test/UpdateUserAccount.ral.json
#	artifacts/test/UserAccount.ral.json
#	artifacts/test/Warnings.ral.json
#	artifacts/token/FakeTokenTest.ral.json
#	artifacts/token/TokenTest.ral.json
#	artifacts/token/TokenTestStd.ral.json
#	docker/docker-compose.yml
#	packages/web3-test/src/test-wallet.ts
#	test/transaction.test.ts
Copy link
Member

@Lbqds Lbqds left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@h0ngcha0 h0ngcha0 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

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.

3 participants