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 #36 from ara-klaytn/L1finalisation
Browse files Browse the repository at this point in the history
Changed path to gcp for L1
  • Loading branch information
praveen-kaia authored Jan 10, 2024
2 parents 8e27eab + 2b42e54 commit 5668faa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 34 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 0 additions & 3 deletions arbitrium-tx-latency-measurement/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ S3_BUCKET=
GCP_PROJECT_ID=
GCP_KEY_FILE_PATH=
GCP_BUCKET=
GCP_PROJECT_ID_L1=
GCP_KEY_FILE_PATH_L1=
GCP_BUCKET_L1=
SLACK_CHANNEL=SLACK_CHANNEL
SLACK_API_URL=https://slack.com/api/chat.postMessage
SLACK_AUTH=xoxb-SLACK_AUTH_TOKEN
Expand Down
22 changes: 11 additions & 11 deletions arbitrium-tx-latency-measurement/sendtx_arbitrium.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ async function uploadToGCS(data) {

async function uploadToGCSL1(data) {
if (
process.env.GCP_PROJECT_ID_L1 === "" ||
process.env.GCP_KEY_FILE_PATH_L1 === "" ||
process.env.GCP_BUCKET_L1 === ""
process.env.GCP_PROJECT_ID === "" ||
process.env.GCP_KEY_FILE_PATH === "" ||
process.env.GCP_BUCKET === ""
) {
throw "undefined parameters";
}

const storage = new Storage({
projectId: process.env.GCP_PROJECT_ID_L1,
keyFilename: process.env.GCP_KEY_FILE_PATH_L1,
projectId: process.env.GCP_PROJECT_ID,
keyFilename: process.env.GCP_KEY_FILE_PATH,
});

const filename = await makeParquetFile(data);
Expand All @@ -141,8 +141,8 @@ async function uploadToGCSL1(data) {
destination: destFileName,
};

await storage.bucket(process.env.GCP_BUCKET_L1).upload(filename, options);
console.log(`${filename} uploaded to ${process.env.GCP_BUCKET_L1}`);
await storage.bucket(process.env.GCP_BUCKET).upload(filename, options);
console.log(`${filename} uploaded to ${process.env.GCP_BUCKET}`);
}

await uploadFile().catch(console.error);
Expand Down Expand Up @@ -254,14 +254,14 @@ async function sendTx() {
// Calculate Transaction Fee and Get Tx Fee in USD
var ARBtoUSD;
await axios.get(`https://api.coingecko.com/api/v3/simple/price?ids=arbitrum&vs_currencies=usd&x_cg_demo_api_key=${process.env.COIN_GECKO_API_KEY}`)
.then(response => {
ARBtoUSD = response.data["arbitrum"].usd;
});
.then(response => {
ARBtoUSD = response.data["arbitrum"].usd;
});
data.txFeeInUSD = data.txFee * ARBtoUSD;

// 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();
const now = new Date();
sendSlackMsg(`${now}, failed to execute arbitrum, ${err.toString()}`);
console.log("failed to execute.", err.toString());
data.error = err.toString();
Expand Down
3 changes: 0 additions & 3 deletions optimism-tx-latency-measurement/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ S3_BUCKET=
GCP_PROJECT_ID=
GCP_KEY_FILE_PATH=
GCP_BUCKET=
GCP_PROJECT_ID_L1=
GCP_KEY_FILE_PATH_L1=
GCP_BUCKET_L1=
SLACK_CHANNEL=SLACK_CHANNEL
SLACK_API_URL=https://slack.com/api/chat.postMessage
SLACK_AUTH=xoxb-SLACK_AUTH_TOKEN
Expand Down
34 changes: 17 additions & 17 deletions optimism-tx-latency-measurement/sendtx_optimism.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ async function uploadToGCS(data) {

async function uploadToGCSL1(data) {
if (
process.env.GCP_PROJECT_ID_L1 === "" ||
process.env.GCP_KEY_FILE_PATH_L1 === "" ||
process.env.GCP_BUCKET_L1 === ""
process.env.GCP_PROJECT_ID === "" ||
process.env.GCP_KEY_FILE_PATH === "" ||
process.env.GCP_BUCKET === ""
) {
throw "undefined parameters";
}

const storage = new Storage({
projectId: process.env.GCP_PROJECT_ID_L1,
keyFilename: process.env.GCP_KEY_FILE_PATH_L1,
projectId: process.env.GCP_PROJECT_ID,
keyFilename: process.env.GCP_KEY_FILE_PATH,
});

const filename = await makeParquetFile(data);
Expand All @@ -141,8 +141,8 @@ async function uploadToGCSL1(data) {
destination: destFileName,
};

await storage.bucket(process.env.GCP_BUCKET_L1).upload(filename, options);
console.log(`${filename} uploaded to ${process.env.GCP_BUCKET_L1}`);
await storage.bucket(process.env.GCP_BUCKET).upload(filename, options);
console.log(`${filename} uploaded to ${process.env.GCP_BUCKET}`);
}

await uploadFile().catch(console.error);
Expand Down Expand Up @@ -241,19 +241,19 @@ async function sendTx() {
Number(web3.utils.fromWei(Number(receipt.effectiveGasPrice), "ether"));
});

const db = await JSONPreset("db.json", { posts: [] });
db.data.posts.push({
l2TxHash: data.txhash,
createdAt: data.executedAt,
status: "pending",
l1CommitTiming: null,
});
db.write();
const db = await JSONPreset("db.json", { posts: [] });
db.data.posts.push({
l2TxHash: data.txhash,
createdAt: data.executedAt,
status: "pending",
l1CommitTiming: null,
});
db.write();

// Calculate Transaction Fee and Get Tx Fee in USD
var OPTtoUSD;

await axios.get(`https://api.coingecko.com/api/v3/simple/price?ids=optimism&vs_currencies=usd&x_cg_demo_api_key=${process.env.COIN_GECKO_API_KEY}`)
await axios.get(`https://api.coingecko.com/api/v3/simple/price?ids=optimism&vs_currencies=usd&x_cg_demo_api_key=${process.env.COIN_GECKO_API_KEY}`)
.then(response => {
OPTtoUSD = response.data["optimism"].usd;
});
Expand All @@ -263,7 +263,7 @@ async function sendTx() {

// 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();
const now = new Date();
sendSlackMsg(`${now}, failed to execute optimism, ${err.toString()}`);
console.log("failed to execute.", err.toString());
data.error = err.toString();
Expand Down

0 comments on commit 5668faa

Please sign in to comment.