From 37d14d2af96d6e945d445e9b50474b623ea062d9 Mon Sep 17 00:00:00 2001 From: pingke Date: Fri, 9 Aug 2024 15:34:19 +0800 Subject: [PATCH] fix --- .github/workflows/integration-test.yml | 1 - integration_tests/scripts/ituploader.js | 75 +++++++++++++++++-------- 2 files changed, 51 insertions(+), 25 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 78c2e088..0873bd70 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -31,7 +31,6 @@ jobs: git pull npm install git submodule init && git submodule update - npx hardhat run scripts/deployL2-it.js --network qkc_testnet >> deploy.log echo ES_NODE_CONTRACT_ADDRESS=`cat .caddr` >> "$GITHUB_ENV" - name: Build and Run Bootnode Node diff --git a/integration_tests/scripts/ituploader.js b/integration_tests/scripts/ituploader.js index 5937f9dd..a73bc04e 100644 --- a/integration_tests/scripts/ituploader.js +++ b/integration_tests/scripts/ituploader.js @@ -8,36 +8,63 @@ const privateKey = process.env.ES_NODE_SIGNER_PRIVATE_KEY; const contractAddr = process.env.ES_NODE_CONTRACT_ADDRESS; const RPC = 'http://65.109.20.29:8545'; const contractABI = [ - "function lastKvIdx() public view returns (uint40)" + "function lastKvIdx() public view returns (uint40)" ] const provider = new ethers.JsonRpcProvider(RPC); const contract = new Contract(contractAddr, contractABI, provider); -const MAX_BLOB = 192n; +const MAX_BLOB = 256n; async function UploadBlobsForIntegrationTest() { - // put blobs - console.log(contractAddr) - const es = await EthStorage.create({ - rpc: RPC, - privateKey, - address: contractAddr - }) - while (true) { - const currentIndex = await contract.lastKvIdx(); - const totalCount = MAX_BLOB - currentIndex; - console.log("Current Number:", currentIndex, " Total Number:", totalCount); - if (totalCount <= 0) { - return; - } - const buf = crypto.randomBytes(126976); - const cost = await es.estimateCost(buf.subarray(0,32).toString('hex'), buf); - console.log(cost) - - // write - let status = await es.write(buf.subarray(0,32).toString('hex'), buf); - console.log(status) - } + // put blobs + console.log(contractAddr) + const es = await EthStorage.create({ + rpc: RPC, + privateKey, + address: contractAddr + }) + while (true) { + const currentIndex = await contract.lastKvIdx(); + const totalCount = MAX_BLOB - currentIndex; + console.log("Current Number:", currentIndex, " Total Number:", totalCount); + if (totalCount <= 0) { + break; + } + const buf = crypto.randomBytes(126976); + const cost = await es.estimateCost(buf.subarray(0,32).toString('hex'), buf); + console.log(cost) + + // write + let status = await es.write(buf.subarray(0,32).toString('hex'), buf); + console.log(status) + } + + let latestBlock + try { + latestBlock = await provider.getBlock(); + console.log("latest block number is", latestBlock.number); + } catch (e) { + console.error(`EthStorage: get latest block failed!`, e.message); + return + } + + // wait for blobs finalized + var intervalId = setInterval(async function (){ + try { + let finalizedBlock = await provider.getBlock("finalized"); + console.log( + "finalized block number is", + finalizedBlock.number, + "at", + new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" }) + ); + if (latestBlock.number < finalizedBlock.number) { + clearInterval(intervalId); + } + } catch (e) { + console.error(`EthStorage: get finalized block failed!`, e.message); + } + }, 60000); } UploadBlobsForIntegrationTest();