Skip to content

When wallet.json has lots of chains (>= 100), it'll take long time (> 60s) to query validator #3898

Open
@kikakkz

Description

@kikakkz

Description
When we have lots of chains in wallet.json,it'll be very slow to execute the Transfer operation. I add a simple semaphore to limit concurrent requests to a single validator and sometimes it still responds slow, and it always responds fast when I run the same test with localnet.

Steps

  • 1 git clone https://github.com/linera-io/linera-protocol.git
  • 2 cd linera-protocol; git checkout testnet_babbage
  • 3 cargo build --release --features storage-service
  • 4 Copy the script section as test.sh, and modify the linera path to your local PC path
  • 5 chmod a+x test.sh
  • 6 ./test.sh
    • It will create wallet and storage in currently path then request chain from Babbage to test automatically
  • 7 Modify chains count in the script to get different transfer time comsuption

Expected result
For me it should be reasonable to manage 200 chains in an 48 cores / 256GiB machine, and won't get significant delay when transfer.

Actual result

  • If we only have 3 chains in the wallet, it take 1s to transfer.
  • If we have 50 chains in the wallet, it still take 1.8s to transfer.
  • If we have 100 chains in the wallet, it will take more than 2m, and finally fail.
  • If we have 200 chains in the wallet, it will take more than 2m, and finally fail.

Script

#!/bin/bash

kill -9 $(ps | grep linera | awk '{print $1}')

PORT=31980

export PATH=$PWD/../linera-protocol/target/release:$PATH
export LINERA_WALLET=$PWD/wallet.json
STORAGE_DIR=$PWD/client.db
export LINERA_STORAGE=rocksdb:$STORAGE_DIR

rm $LINERA_WALLET $STORAGE_DIR -rf

linera wallet init --faucet https://faucet.testnet-babbage.linera.net --with-new-chain

FROM_CHAIN=$(linera wallet show | grep 'Public Key' | awk '{print $2}')

linera wallet request-chain --faucet https://faucet.testnet-babbage.linera.net --storage $LINERA_STORAGE

TO_CHAIN=$(linera wallet show | grep 'Public Key' | grep -v $FROM_CHAIN | awk '{print $2}')

for i in $(seq 1 200); do
  linera wallet request-chain --faucet https://faucet.testnet-babbage.linera.net --storage $LINERA_STORAGE
done

linera service --port $PORT &

sleep 60

echo "  Transfer from $FROM_CHAIN to $TO_CHAIN ..."

PAYLOAD=$(echo '{
  "query": "mutation {
    transfer(
      chainId: \"'$FROM_CHAIN'\",
      owner: \"0x00\",
      recipient: {
        Account: {
          chain_id: \"'$TO_CHAIN'\",
          owner: \"0x00\"
        }
      },
      amount: \"2.5\"
    )
  }"
}' | tr -d '\000-\037')

time curl -X POST -H 'Content-Type: application/json' -d "$PAYLOAD" http://localhost:$PORT

kill -9 $(ps | grep linera | awk '{print $1}')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions