-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add raw deployment script & CI * chore: lint * chore: store state before contract deployment 🧪 * chore: stop containers not using compose * chore: add funding for extra address * fix: permissions * chore: renew docker login * chore: add arb_init.ts * fix: fon't stop arb * chore: idempotent contract deployment * chore: stop containers before saving state * chore: don't deploy contracts 🤦♂️ * chore: add `arbitrum-gizmo-shop` docker image 🩻🐳 * fix: set agg key * fix: add arbitry aggkey for L2 contracts 💀 * fix: wrong working directory * chore: better logs from arb_init script --------- Co-authored-by: Assem Hasna <[email protected]>
- Loading branch information
1 parent
faaedad
commit 19fde2b
Showing
8 changed files
with
3,108 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env -S pnpm tsx | ||
// INSTRUCTIONS | ||
// | ||
// This command takes no arguments. | ||
// It will perform the initial arbitrum contract deployment according to the `arbRawDeploymentTxs.json` file | ||
// and will send a transaction every ~260ms to mimic the Arbitrum mainnet block production. | ||
|
||
import fs from 'fs/promises'; | ||
import Web3 from 'web3'; | ||
import { setTimeout as sleep } from 'timers/promises'; | ||
|
||
async function main(): Promise<void> { | ||
let rawTxsFile = | ||
process.env.ARB_RAW_TXS_FILE ?? "../scripts/.artefacts/arbRawDeploymentTxs.json"; | ||
const web3 = new Web3(process.env.ARB_ENDPOINT ?? 'http://127.0.0.1:8547'); | ||
const usdcArbitrumAddress = '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9'; | ||
|
||
const bytecode = await web3.eth.getCode(usdcArbitrumAddress); | ||
|
||
if (bytecode === '0x') { | ||
const abi = await fs.readFile(rawTxsFile, "utf-8"); | ||
const arbRawTxs: JSON = JSON.parse(abi); | ||
|
||
// Loop through each raw transaction data | ||
for (const arbRawTx of Object.values(arbRawTxs)) { | ||
const txHash = await web3.eth.sendSignedTransaction(arbRawTx, (error) => { | ||
if (error) { | ||
console.log(`❌ Arbitrum transaction failure:`, error); | ||
} | ||
}); | ||
console.log(`💌 Transaction sent with hash: ${txHash.transactionHash}`); | ||
} | ||
|
||
console.log("=== 🪂 Arbitrum contracts deployed successfully ==="); | ||
} else { | ||
console.log(`=== Contracts already deployed ===`); | ||
} | ||
|
||
console.log("=== 🧶 Start spamming ==="); | ||
|
||
const whaleKey = '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d'; | ||
const whaleAddress = '0x70997970C51812dc3A010C7d01b50e0d17dc79C8'; | ||
|
||
// NOTE: The naive approach to just have a nonce increment every time seems to work fine | ||
let nonce = await web3.eth.getTransactionCount(whaleAddress); | ||
let livelinessLogCounter = 0; | ||
let spammingTxCounter = 0; | ||
while (true) { | ||
const tx = { to: whaleAddress, data: undefined, gas: 5000000, nonce, value: 1 }; | ||
|
||
const signedTx = await web3.eth.accounts.signTransaction(tx, whaleKey); | ||
|
||
await web3.eth.sendSignedTransaction( | ||
signedTx.rawTransaction as string, | ||
(error) => { | ||
if (error) { | ||
console.error(`Arbitrum transaction failure:`, error); | ||
} | ||
}, | ||
); | ||
nonce++; | ||
spammingTxCounter++; | ||
livelinessLogCounter++; | ||
if (livelinessLogCounter === 120) { // 120 * 250ms = 30s | ||
console.log( | ||
`💌 Total Number of Spamming TXs sent: ${livelinessLogCounter}` | ||
); | ||
livelinessLogCounter = 0; | ||
} | ||
await sleep(250); | ||
} | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exit(-1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "scripts", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"tsx": "^4.7.1", | ||
"web3": "^1.9.0" | ||
} | ||
} |
Oops, something went wrong.