Skip to content

Commit

Permalink
Merge pull request #1 from praveen-klaytn/dev
Browse files Browse the repository at this point in the history
Updated Kaia changes
  • Loading branch information
praveen-kaia authored Jun 25, 2024
2 parents f27b416 + d988ddd commit 0cbdd35
Show file tree
Hide file tree
Showing 14 changed files with 262 additions and 284 deletions.
52 changes: 24 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)

# NO LONGER MAINTAINED

Since the launch of Kaia Blockchain this repository has been parked in favour of the new open-source projects in [Kaia's Github](https://github.com/kaia-blockchain). Contributors have now moved there continuing with massive open-source contributions to our blockchain ecosystem. A big thank you to everyone who has contributed to this repository. For more information about Klaytn's chain merge with Finschia blockchain please refer to the launching of Kaia blockchain - [kaia.io](http://kaia.io/).

--------


# Transaction Latency Measurement

### 1) Introduction
Using this repo, you can measure transaction latency on differenct blockchain platforms(ex: Solana mainnet-beta, Avalanche C-chain, Polygon PoS, and Klaytn). Transaction latency is measured by sending a simple value transfer transaction through public RPC url provided by each chain. Each subdirectory is for each different blockchain platform. Codes for other chains will be updated.
Using this repo, you can measure transaction latency on differenct blockchain platforms(ex: Solana mainnet-beta, Avalanche C-chain, Polygon PoS, and Kaia). Transaction latency is measured by sending a simple value transfer transaction through public RPC url provided by each chain. Each subdirectory is for each different blockchain platform. Codes for other chains will be updated.

### 2) Prerequisite
This project uses NodeJS v16.14.2.

### 3) Getting Started
1. Open terminal
2. Clone the repo by running `https://github.com/klaytn/tx-latency-measurement.git`
2. Clone the repo by running `https://github.com/kaiachain/tx-latency-measurement.git`
3. `cd tx-latency-measurement/{BlockchainName}-tx-latency-measurement` by selecting which blockchain you want to measure.
4. Run `npm install` to install node packages.
5. Copy and paste `.env.template` file. Then rename it to `.env` and update variables with your Private key, url of blockchain explorer, and public rpc url.
You should also decide whether to upload to GCS/S3, and provide appropriate credentials.
6. Run `node sendtx_{BlockchainName}.js`.

### 4) Simple Test with Testnet (Klaytn)
### 4) Simple Test with Testnet (Kaia)
1. Open terminal
2. Clone the repo by running `https://github.com/klaytn/tx-latency-measurement.git`
2. Clone the repo by running `https://github.com/kaiachain/tx-latency-measurement.git`
3. Run `npm install` to install node packages.
```
cd tx-latency-measurement/klaytn-tx-latency-measurement
cd tx-latency-measurement/kaia-tx-latency-measurement
npm install
```
3. Copy and paste `.env.template` file. Then rename it to `.env`.
Expand All @@ -39,19 +30,19 @@ cp .env.template .env
4. Update `.env` and make sure PRIVATE_KEY and S3_BUCKET is empty as below:
```
PRIVATE_KEY=
CAVER_URL=https://public-node-api.klaytnapi.com/v1/baobab
CAVER_URL=https://public-en.kairos.node.kaia.io
S3_BUCKET=
```
5. Run `node sendtx_klaytn.js`. Then the output will give you new Private Key and Address.
5. Run `node sendtx_kaia.js`. Then the output will give you new Private Key and Address.
```shell
starting tx latency measurement... start time = 1661338618926
Private key is not defined. Use this new private key({NEW_PRIVATE_KEY}).
Get test KLAY from the faucet: https://baobab.wallet.klaytn.foundation/faucet
Your Klaytn address = {NEW_ADDRESS}
Get test KAIA from the faucet: https://baobab.wallet.klaytn.foundation/faucet
Your Kaia address = {NEW_ADDRESS}
```
- With `NEW_ADDRESS`, get test KLAY from faucet page.
- With `NEW_ADDRESS`, get test KAIA from faucet page.
- Update PRIVATE_KEY in .env file with this `NEW_PRIVATE_KEY`.
6. Run `node sendtx_klaytn.js`. You can see the result as below:
6. Run `node sendtx_kaia.js`. You can see the result as below:
```
starting tx latency measurement... start time = 1661339036754
failed to s3.upload! Printing instead! undefined bucket name
Expand All @@ -64,39 +55,44 @@ failed to s3.upload! Printing instead! undefined bucket name

2. Build a docker image in a folder you would like to measure.
```bash
> docker build -t klaytn-tx-latency-measurement:latest .
> docker build -t kaia-tx-latency-measurement:latest .
```

3. Run a container out of the image
```bash
> docker run klaytn-tx-latency-measurement:latest
> docker run kaia-tx-latency-measurement:latest
```

*Note: You need to provide credentials JSON inside a directory if you wish to upload to GCS*

### 6) List of Blockchain Platforms
(unchecked: to be updated)
- [x] Klaytn
- [x] Kaia
- [x] Polygon PoS
- [x] Avalanche C-chain
- [x] Solana
- [x] Near Protocol
- [x] EOS
- [] EOS
- [x] Fantom
- [x] Polkadot
- [ ] Cosmos
- [x] BNB
- [x] Hedera
- [x] Elrond
- [] Hedera
- [] Elrond
- [x] Harmony
- [x] Aptos
- [x] Arbitrium
- [x] Sui
- [x] Optimism


### 7) When you'd like to contribute this repository (ex: to add another chain)
1. Please find out ways to collect data like other chains in this repo. You might be able to use javascript sdk for other chains.
2. What should be included in your code
1. Use same structure(ex: [sendtx_klaytn.js](https://github.com/klaytn/tx-latency-measurement/blob/dev/klaytn-tx-latency-measurement/sendtx_klaytn.js) & [.env.template](https://github.com/klaytn/tx-latency-measurement/blob/dev/klaytn-tx-latency-measurement/.env.template)) and functions(ex: uploadToS3, uploadToGCS, uploadChoice, makeParquetFile, loadConfig, sendSlackMsg in [sendtx_klaytn.js](https://github.com/klaytn/tx-latency-measurement/blob/dev/klaytn-tx-latency-measurement/sendtx_klaytn.js))
1. Use same structure(ex: [sendtx_kaia.js](https://github.com/kaiachain/tx-latency-measurement/blob/dev/kaia-tx-latency-measurement/sendtx_kaia.js) & [.env.template](https://github.com/kaiachain/tx-latency-measurement/blob/dev/kaia-tx-latency-measurement/.env.template)) and functions(ex: uploadToS3, uploadToGCS, uploadChoice, makeParquetFile, loadConfig, sendSlackMsg in [sendtx_kaia.js](https://github.com/kaiachain/tx-latency-measurement/blob/dev/kaia-tx-latency-measurement/sendtx_kaia.js))
2. In sendTx function, check if balance of the account is enough to send transaction and set `chainId`.
3. Measure pingtime using simple rpc api (like getBlockNumber())
4. Measure `resourceUsedOfLatestBlock` & `numOfTxInLatestBlock` from the latest block info.
4. Measure `resourceUsedOfLatestBlock` & `numOfTxInLatestBlock` from the latest block info.
5. Configure the transaction and sign it with private key.
6. Measure the time it took for the signed transaction to be confirmed and receive a receipt. Enter the `txHash`, `start time`, `end time`, and `latency`(time in between) into the data.
7. Calculate `txFeeInUSD` using CoinGecko API, then record `txFee`(in Native Coin) and `txFeeInUSD` into data.
Expand Down
2 changes: 1 addition & 1 deletion aptos-tx-latency-measurement/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:16

WORKDIR /usr/src/klaytn
WORKDIR /usr/src/aptos

COPY . .

Expand Down
2 changes: 1 addition & 1 deletion arbitrium-tx-latency-measurement/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:18

WORKDIR /usr/src/klaytn
WORKDIR /usr/src/arbitrium

COPY . .

Expand Down
Loading

0 comments on commit 0cbdd35

Please sign in to comment.