Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #51 from ara-klaytn/L1finalisation
Browse files Browse the repository at this point in the history
Prevents sending data if error occured in all chain
  • Loading branch information
praveen-kaia authored Jan 17, 2024
2 parents ff87d65 + 8902772 commit 9601dc8
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 136 deletions.
24 changes: 11 additions & 13 deletions aptos-tx-latency-measurement/sendtx_aptos.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,25 +227,23 @@ async function sendTx() {
data.txFee = txfee;
data.txFeeInUSD = APTOStoUSD * data.txFee;
// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
try {
await uploadChoice(data);
} catch (err) {
await sendSlackMsg(`failed to upload aptos, ${err.toString()}`);
console.log(
`failed to ${process.env.UPLOAD_METHOD === "AWS" ? "s3" : "gcs"}.upload!! Printing instead!`,
err.toString()
);
console.log(JSON.stringify(data));
}
} catch (err) {

const now = new Date();
const now = new Date();
await sendSlackMsg(`${now}, failed to execute aptos, ${err.toString()}`);
console.log("failed to execute.", err.toString());
data.error = err.toString();
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try {
await uploadChoice(data);
} catch (err) {
const now = new Date();
await sendSlackMsg(`${now}, failed to upload aptos, ${err.toString()}`);
console.log(
`failed to ${process.env.UPLOAD_METHOD === "AWS" ? "s3" : "gcs"}.upload!! Printing instead!`,
err.toString()
);
console.log(JSON.stringify(data));
}
}

async function main() {
Expand Down
22 changes: 10 additions & 12 deletions arbitrium-tx-latency-measurement/sendtx_arbitrium.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,16 @@ async function sendTx() {
ARBtoUSD = response.data["arbitrum"].usd;
});
data.txFeeInUSD = data.txFee * ARBtoUSD;

try {
await uploadChoice(data);
} catch (err) {
await sendSlackMsg(`failed to upload arbitrium, ${err.toString()}`);

console.log(
`failed to ${process.env.UPLOAD_METHOD === "AWS" ? "s3" : "gcs"}.upload!! Printing instead!`,
err.toString()
);
}
// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
} catch (err) {
const now = new Date();
Expand All @@ -267,17 +276,6 @@ async function sendTx() {
data.error = err.toString();
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try {
await uploadChoice(data);
} catch (err) {
const now = new Date();
await sendSlackMsg(`${now}, failed to upload arbitrium, ${err.toString()}`);

console.log(
`failed to ${process.env.UPLOAD_METHOD === "AWS" ? "s3" : "gcs"}.upload!! Printing instead!`,
err.toString()
);
}
}

async function l1Checker() {
Expand Down
16 changes: 8 additions & 8 deletions avalanche-tx-latency-measurement/sendtx_avalanche.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,20 @@ const sendAvax = async (amount, to, maxFeePerGas = undefined, maxPriorityFeePerG
data.txFee = ethers.utils.formatEther(signature.effectiveGasPrice) * signature.gasUsed;
data.txFeeInUSD = data.txFee * AVAXtoUSD;
// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
try{
await uploadChoice(data)
} catch(err){
await sendSlackMsg(`failed to upload avalanche, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
} catch(err){
const now = new Date();
await sendSlackMsg(`${now}, failed to execute avalanche, ${err.toString()}`);
await sendSlackMsg(`${now}, failed to execute avalanche, ${err.toString()}`);
console.log("failed to execute.", err.toString())
data.error = err.toString()
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try{
await uploadChoice(data)
} catch(err){
await sendSlackMsg(`failed to upload avalanche, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
};

async function main(){
Expand Down
16 changes: 8 additions & 8 deletions bnb-tx-latency-measurement/sendtx_bnb.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,21 @@ async function sendTx(){
});
data.txFeeInUSD = data.txFee * BNBtoUSD
// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)

try{
await uploadChoice(data)
} catch(err){
await sendSlackMsg(`failed to upload bnb, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
} catch(err){
const now = new Date();
await sendSlackMsg(`${now}, failed to execute bnb, ${err.toString()}`);
console.log("failed to execute.", err.toString())
data.error = err.toString()
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try{
await uploadChoice(data)
} catch(err){
await sendSlackMsg(`failed to upload bnb, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}

}

async function main(){
Expand Down
15 changes: 7 additions & 8 deletions elrond-tx-latency-measurement/sendtx_elrond.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,20 @@ async function sendTx(){
});
data.txFeeInUSD = data.txFee * EGLDtoUSD
// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)

try{
await uploadToS3(data)
} catch(err){
await sendSlackMsg(`failed to upload elrond, ${err.toString()}`);
console.log('failed to s3.upload! Printing instead!', err.toString())
console.log(JSON.stringify(data))
}
} catch(err){
const now = new Date();
await sendSlackMsg(`${now}, failed to execute elrond, ${err.toString()}`);
console.log("failed to execute.", err.toString())
data.error = err.toString()
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try{
await uploadToS3(data)
} catch(err){
await sendSlackMsg(`failed to upload elrond, ${err.toString()}`);
console.log('failed to s3.upload! Printing instead!', err.toString())
console.log(JSON.stringify(data))
}
}

async function main(){
Expand Down
14 changes: 7 additions & 7 deletions eos-tx-latency-measurement/sendtx_eos.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,20 @@ async function sendTx(){

data.txFeeInUSD = data.txFee * EOStoUSD
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
try{
await uploadChoice(data)
} catch(err){
await sendSlackMsg(`failed to upload eos, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
} catch(err){
const now = new Date();
await sendSlackMsg(`${now}, failed to execute eos, ${err.toString()}`);
console.log("failed to execute.", err.toString())
data.error = err.toString()
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try{
await uploadChoice(data)
} catch(err){
await sendSlackMsg(`failed to upload eos, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
}

async function main(){
Expand Down
23 changes: 10 additions & 13 deletions fantom-tx-latency-measurement/sendtx_fantom.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ async function sendTx(){
pingTime:0
}

var transactionError = false

try{
const signer = web3.eth.accounts.privateKeyToAccount(
Expand Down Expand Up @@ -233,25 +232,23 @@ async function sendTx(){
data.txFeeInUSD = data.txFee * FTMtoUSD

// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
try {
await uploadChoice(data);
} catch (err) {
await sendSlackMsg(`failed to upload sui, ${err.toString()}`);
console.log(
`failed to ${process.env.UPLOAD_METHOD === "AWS" ? "s3" : "gcs"}.upload!! Printing instead!`,
err.toString()
);
console.log(JSON.stringify(data));
}
} catch(err){
transactionError = true
const now = new Date();
await sendSlackMsg(`${now}, failed to execute fantom, ${err.toString()}`);
console.log("failed to execute.", err.toString())
data.error = err.toString()
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try{
if (!transactionError){
await uploadChoice(data)
} else {
console.log("not uploading fantom data due to transaction error")
}
} catch(err){
await sendSlackMsg(`failed to upload fantom, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
}

async function main(){
Expand Down
20 changes: 10 additions & 10 deletions harmony-tx-latency-measurement/sendtx_harmony.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,23 @@ async function sendTx() {

data.txFeeInUSD = data.txFee * ONEtoUSD;
// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
try {
await uploadChoice(data);
} catch (err) {
await sendSlackMsg(`failed to upload harmony, ${err.toString()}`);
console.log(
`failed to ${process.env.UPLOAD_METHOD === "AWS" ? "s3" : "gcs"}.upload!! Printing instead!`,
err.toString()
);
console.log(JSON.stringify(data));
}
} catch (err) {
const now = new Date();
await sendSlackMsg(`${now}, failed to execute harmony, ${err.toString()}`);
console.log("failed to execute.", err.toString());
data.error = err.toString();
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try {
await uploadChoice(data);
} catch (err) {
await sendSlackMsg(`failed to upload harmony, ${err.toString()}`);
console.log(
`failed to ${process.env.UPLOAD_METHOD === "AWS" ? "s3" : "gcs"}.upload!! Printing instead!`,
err.toString()
);
console.log(JSON.stringify(data));
}
}

async function main() {
Expand Down
14 changes: 7 additions & 7 deletions hedera-tx-latency-measurement/sendtx_hedera.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,20 @@ async function sendTx(){

data.txFeeInUSD = data.txFee * HBARtoUSD
// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
try{
await uploadChoice(data)
} catch(err) {
await sendSlackMsg(`failed to upload hedera, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS' ? 's3' : 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
} catch(err){
const now = new Date();
await sendSlackMsg(`${now}, failed to execute hedera, ${err.toString()}`);
console.log("failed to execute.", err.toString())
data.error = err.toString()
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try{
await uploadChoice(data)
} catch(err) {
await sendSlackMsg(`failed to upload hedera, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS' ? 's3' : 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
}

async function main(){
Expand Down
14 changes: 7 additions & 7 deletions klaytn-tx-latency-measurement/sendtx_klaytn.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,20 @@ async function sendTx() {
data.txFee = caver.utils.convertFromPeb(receipt.gasPrice, 'KLAY') * receipt.gasUsed
data.txFeeInUSD = KLAYtoUSD * data.txFee
// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
try{
await uploadChoice(data)
} catch(err){
await sendSlackMsg(`failed to upload Klaytn, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
} catch (err) {
const now = new Date();
await sendSlackMsg(`${now}, failed to execute Klaytn, ${err.toString()}`);
console.log("failed to execute.", err.toString())
data.error = err.toString()
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try{
await uploadChoice(data)
} catch(err){
await sendSlackMsg(`failed to upload Klaytn, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
}

async function main() {
Expand Down
14 changes: 7 additions & 7 deletions near-tx-latency-measurement/sendtx_near.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,20 @@ async function sendTx() {

data.txFeeInUSD = data.txFee * NEARtoUSD
// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
try{
await uploadChoice(data)
} catch(err){
await sendSlackMsg(`failed to upload Near, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
} catch(err){
const now = new Date();
await sendSlackMsg(`${now}, failed to execute Near, ${err.toString()}`);
console.log("failed to execute.", err.toString())
data.error = err.toString()
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try{
await uploadChoice(data)
} catch(err){
await sendSlackMsg(`failed to upload Near, ${err.toString()}`);
console.log(`failed to ${process.env.UPLOAD_METHOD === 'AWS'? 's3': 'gcs'}.upload!! Printing instead!`, err.toString())
console.log(JSON.stringify(data))
}
}

async function main (){
Expand Down
18 changes: 9 additions & 9 deletions optimism-tx-latency-measurement/sendtx_optimism.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,22 @@ async function sendTx() {
data.txFeeInUSD = data.txFee * OPTtoUSD;

// console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
try {
await uploadChoice(data);
} catch (err) {
await sendSlackMsg(`failed to upload optimism, ${err.toString()}`);
console.log(
`failed to ${process.env.UPLOAD_METHOD === "AWS" ? "s3" : "gcs"}.upload!! Printing instead!`,
err.toString()
);
}
} catch (err) {
const now = new Date();
await sendSlackMsg(`${now}, failed to execute optimism, ${err.toString()}`);
console.log("failed to execute.", err.toString());
data.error = err.toString();
console.log(`${data.executedAt},${data.chainId},${data.txhash},${data.startTime},${data.endTime},${data.latency},${data.txFee},${data.txFeeInUSD},${data.resourceUsedOfLatestBlock},${data.numOfTxInLatestBlock},${data.pingTime},${data.error}`)
}
try {
await uploadChoice(data);
} catch (err) {
await sendSlackMsg(`failed to upload optimism, ${err.toString()}`);
console.log(
`failed to ${process.env.UPLOAD_METHOD === "AWS" ? "s3" : "gcs"}.upload!! Printing instead!`,
err.toString()
);
}
}

async function l1Checker() {
Expand Down
Loading

0 comments on commit 9601dc8

Please sign in to comment.