From 14b125849be85eae60efafce46d057d3373beade Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 14:33:06 +0200 Subject: [PATCH 01/12] update gas report for baseline --- gas-report.txt | 16 ++++++++-------- lib/claim.ts | 9 ++++++++- scripts/profile.ts | 14 ++++++++++++++ tests-integration/claim_external.test.ts | 2 ++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index b20933e..02e3c94 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -24,15 +24,15 @@ Resources: │ Transfer ETH (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 25 │ 0 │ 181 │ 8184 │ │ Transfer STRK (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 25 │ 0 │ 181 │ 8184 │ │ Gifting WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 334 │ 14506 │ -│ Claiming WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13662 │ -│ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15316 │ +│ Claiming WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13663 │ +│ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ │ Gifting WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 63 │ 0 │ 460 │ 20478 │ -│ Claiming WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13860 │ -│ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15316 │ +│ Claiming WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13861 │ +│ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ │ Gifting FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 63 │ 0 │ 460 │ 20477 │ -│ Claiming FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13662 │ -│ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15316 │ +│ Claiming FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13663 │ +│ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ │ Gifting FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 334 │ 14507 │ -│ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13860 │ -│ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15316 │ +│ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13861 │ +│ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ └───────────────────────────────────────┴─────────┴───────┴───────┴────────┴──────────┴──────────┴─────────────┴───────┘ diff --git a/lib/claim.ts b/lib/claim.ts index 513d263..e839acb 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -106,10 +106,17 @@ export async function claimExternal(args: { receiver: string; dustReceiver?: string; claimPrivateKey: string; + useTxV3?: boolean; overrides?: { claimAccountAddress?: string; factoryAddress?: string; account?: Account }; details?: UniversalDetails; }): Promise { - const account = args.overrides?.account || deployer; + let account = args.overrides?.account || deployer; + // Ugly tmp fix + if (args.useTxV3) { + const devnetAddress = "0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691"; + const devnetPrivateKey = "0x71d7bb07b9a64f6f78ac4c816aff4da9"; + account = new Account(manager, devnetAddress, devnetPrivateKey, undefined, RPC.ETransactionVersion.V3); + } const signature = await signExternalClaim({ claim: args.claim, receiver: args.receiver, diff --git a/scripts/profile.ts b/scripts/profile.ts index f08c778..7bb0b9e 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -1,4 +1,5 @@ import { + calculateClaimAddress, claimExternal, claimInternal, defaultDepositTestSetup, @@ -67,10 +68,23 @@ for (const { giftTokenContract, unit } of tokens) { await claimInternal({ claim, receiver, claimPrivateKey }), ); + // TODO Claim external doesn't align on using txv3 + await profiler.profile( `Claiming external ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, await claimExternal({ claim: claimExternalOj, receiver, claimPrivateKey: claimPrivateKeyExternal }), ); + + // await profiler.profile( + // `Claiming dust ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, + // await claimExternal({ claim: claimExternalOj, receiver, claimPrivateKey: claimPrivateKeyExternal }), + // ); + + const tokenContract = await manager.tokens.feeTokenContract(useTxV3); + const claimAddress = calculateClaimAddress(claim); + const balance = await tokenContract.balance_of(claimAddress); + console.log(balance); + console.log("Claimed"); } } diff --git a/tests-integration/claim_external.test.ts b/tests-integration/claim_external.test.ts index 3d42fbb..52c2b66 100644 --- a/tests-integration/claim_external.test.ts +++ b/tests-integration/claim_external.test.ts @@ -15,6 +15,7 @@ import { describe("Claim External", function () { for (const useTxV3 of [false, true]) { + // TODO DUH we don't use useTxV3 in the test correctly :ROFL: it(`gift_token == fee_token flow using txV3: ${useTxV3} (no dust receiver)`, async function () { const { factory } = await setupGiftProtocol(); const { claim, claimPrivateKey } = await defaultDepositTestSetup({ factory }); @@ -29,6 +30,7 @@ describe("Claim External", function () { await manager.tokens.tokenBalance(claimAddress, claim.fee_token).should.eventually.equal(claim.fee_amount); }); + // TODO DUH we don't use useTxV3 in the test correctly :ROFL: it(`gift_token == fee_token flow using txV3: ${useTxV3} (w/ dust receiver)`, async function () { const { factory } = await setupGiftProtocol(); const { claim, claimPrivateKey } = await defaultDepositTestSetup({ factory }); From d98ec5a6f54f7e03b0206312b2a6d066f5ec5dd1 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 14:38:01 +0200 Subject: [PATCH 02/12] format + useTxV3 --- gas-report.txt | 4 ++-- scripts/profile.ts | 4 +--- tests-integration/claim_external.test.ts | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index 02e3c94..0058f97 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -9,13 +9,13 @@ Summary: │ Claiming external WEI (FeeToken: WEI) │ '1.512.000.000.256' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ │ Gifting WEI (FeeToken: FRI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming WEI (FeeToken: FRI) │ '1.368.000.000.320' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Claiming external WEI (FeeToken: FRI) │ '1.512.000.000.256' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ +│ Claiming external WEI (FeeToken: FRI) │ '1.512.000.000.320' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Gifting FRI (FeeToken: WEI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming FRI (FeeToken: WEI) │ '1.368.000.000.320' │ 0.0054 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Claiming external FRI (FeeToken: WEI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Gifting FRI (FeeToken: FRI) │ '1.548.000.000.416' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 4 │ 416 │ 'BLOB' │ │ Claiming FRI (FeeToken: FRI) │ '1.368.000.000.192' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ -│ Claiming external FRI (FeeToken: FRI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Claiming external FRI (FeeToken: FRI) │ '1.512.000.000.256' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ └───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘ Resources: ┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐ diff --git a/scripts/profile.ts b/scripts/profile.ts index 7bb0b9e..3dfc1dd 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -68,11 +68,9 @@ for (const { giftTokenContract, unit } of tokens) { await claimInternal({ claim, receiver, claimPrivateKey }), ); - // TODO Claim external doesn't align on using txv3 - await profiler.profile( `Claiming external ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, - await claimExternal({ claim: claimExternalOj, receiver, claimPrivateKey: claimPrivateKeyExternal }), + await claimExternal({ claim: claimExternalOj, receiver, useTxV3, claimPrivateKey: claimPrivateKeyExternal }), ); // await profiler.profile( diff --git a/tests-integration/claim_external.test.ts b/tests-integration/claim_external.test.ts index 52c2b66..721cb3e 100644 --- a/tests-integration/claim_external.test.ts +++ b/tests-integration/claim_external.test.ts @@ -22,7 +22,7 @@ describe("Claim External", function () { const receiver = randomReceiver(); const claimAddress = calculateClaimAddress(claim); - await claimExternal({ claim, receiver, claimPrivateKey }); + await claimExternal({ claim, receiver, useTxV3, claimPrivateKey }); const finalBalance = await manager.tokens.tokenBalance(claimAddress, claim.gift_token); expect(finalBalance).to.equal(claim.fee_amount); @@ -39,7 +39,7 @@ describe("Claim External", function () { const claimAddress = calculateClaimAddress(claim); const balanceBefore = await manager.tokens.tokenBalance(claimAddress, claim.gift_token); - await claimExternal({ claim, receiver, claimPrivateKey, dustReceiver }); + await claimExternal({ claim, receiver, claimPrivateKey, useTxV3, dustReceiver }); await manager.tokens.tokenBalance(receiver, claim.gift_token).should.eventually.equal(claim.gift_amount); await manager.tokens From 2ff001177ff2f8a82ec85116667310695e1659cc Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:07:29 +0200 Subject: [PATCH 03/12] get dust + claim external using txv3 --- gas-report.txt | 8 ++++++++ scripts/profile.ts | 24 ++++++++++++------------ tests-integration/claim_external.test.ts | 2 -- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index 0058f97..92802df 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -7,15 +7,19 @@ Summary: │ Gifting WEI (FeeToken: WEI) │ '1.548.000.000.288' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 3 │ 288 │ 'BLOB' │ │ Claiming WEI (FeeToken: WEI) │ '1.368.000.000.192' │ 0.0054 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Claiming external WEI (FeeToken: WEI) │ '1.512.000.000.256' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ +│ Get dust WEI (FeeToken: WEI) │ '1.440.000.000.192' │ 0.0057 │ 1440000000000 │ 40 │ 37 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Gifting WEI (FeeToken: FRI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming WEI (FeeToken: FRI) │ '1.368.000.000.320' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Claiming external WEI (FeeToken: FRI) │ '1.512.000.000.320' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust WEI (FeeToken: FRI) │ '1.548.000.000.320' │ 0.0061 │ 1548000000000 │ 43 │ 40 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Gifting FRI (FeeToken: WEI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming FRI (FeeToken: WEI) │ '1.368.000.000.320' │ 0.0054 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Claiming external FRI (FeeToken: WEI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust FRI (FeeToken: WEI) │ '1.548.000.000.192' │ 0.0061 │ 1548000000000 │ 43 │ 40 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Gifting FRI (FeeToken: FRI) │ '1.548.000.000.416' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 4 │ 416 │ 'BLOB' │ │ Claiming FRI (FeeToken: FRI) │ '1.368.000.000.192' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Claiming external FRI (FeeToken: FRI) │ '1.512.000.000.256' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ +│ Get dust FRI (FeeToken: FRI) │ '1.440.000.000.320' │ 0.0057 │ 1440000000000 │ 40 │ 37 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ └───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘ Resources: ┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐ @@ -26,13 +30,17 @@ Resources: │ Gifting WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 334 │ 14506 │ │ Claiming WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13663 │ │ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ +│ Get dust WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 61 │ 0 │ 436 │ 14637 │ │ Gifting WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 63 │ 0 │ 460 │ 20478 │ │ Claiming WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13861 │ │ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ +│ Get dust WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 62 │ 0 │ 470 │ 15852 │ │ Gifting FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 63 │ 0 │ 460 │ 20477 │ │ Claiming FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 475 │ 13663 │ │ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ +│ Get dust FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 62 │ 0 │ 470 │ 15852 │ │ Gifting FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 334 │ 14507 │ │ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 75 │ 0 │ 509 │ 13861 │ │ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 64 │ 4 │ 451 │ 15317 │ +│ Get dust FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 61 │ 0 │ 436 │ 14637 │ └───────────────────────────────────────┴─────────┴───────┴───────┴────────┴──────────┴──────────┴─────────────┴───────┘ diff --git a/scripts/profile.ts b/scripts/profile.ts index 3dfc1dd..380f074 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -1,5 +1,5 @@ import { - calculateClaimAddress, + buildCallDataClaim, claimExternal, claimInternal, defaultDepositTestSetup, @@ -7,6 +7,7 @@ import { manager, randomReceiver, setupGiftProtocol, + } from "../lib"; import { newProfiler } from "../lib/gas"; @@ -42,7 +43,7 @@ for (const { giftTokenContract, unit } of tokens) { const receiver = "0x42"; const { factory } = await setupGiftProtocol(); - // Make a gift + // Profiling deposit const { response, claim, claimPrivateKey } = await defaultDepositTestSetup({ factory, useTxV3, @@ -63,26 +64,25 @@ for (const { giftTokenContract, unit } of tokens) { await profiler.profile(`Gifting ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, response); + // Profiling claim internal await profiler.profile( `Claiming ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, await claimInternal({ claim, receiver, claimPrivateKey }), ); + // Profiling claim external await profiler.profile( `Claiming external ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, await claimExternal({ claim: claimExternalOj, receiver, useTxV3, claimPrivateKey: claimPrivateKeyExternal }), ); - // await profiler.profile( - // `Claiming dust ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, - // await claimExternal({ claim: claimExternalOj, receiver, claimPrivateKey: claimPrivateKeyExternal }), - // ); - - const tokenContract = await manager.tokens.feeTokenContract(useTxV3); - const claimAddress = calculateClaimAddress(claim); - const balance = await tokenContract.balance_of(claimAddress); - console.log(balance); - console.log("Claimed"); + // Profiling getting the dust + factory.connect(deployer); + // TODO useTxV3 not used... + await profiler.profile( + `Get dust ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, + await factory.get_dust(buildCallDataClaim(claim), deployer.address), + ); } } diff --git a/tests-integration/claim_external.test.ts b/tests-integration/claim_external.test.ts index 721cb3e..d6f9082 100644 --- a/tests-integration/claim_external.test.ts +++ b/tests-integration/claim_external.test.ts @@ -15,7 +15,6 @@ import { describe("Claim External", function () { for (const useTxV3 of [false, true]) { - // TODO DUH we don't use useTxV3 in the test correctly :ROFL: it(`gift_token == fee_token flow using txV3: ${useTxV3} (no dust receiver)`, async function () { const { factory } = await setupGiftProtocol(); const { claim, claimPrivateKey } = await defaultDepositTestSetup({ factory }); @@ -30,7 +29,6 @@ describe("Claim External", function () { await manager.tokens.tokenBalance(claimAddress, claim.fee_token).should.eventually.equal(claim.fee_amount); }); - // TODO DUH we don't use useTxV3 in the test correctly :ROFL: it(`gift_token == fee_token flow using txV3: ${useTxV3} (w/ dust receiver)`, async function () { const { factory } = await setupGiftProtocol(); const { claim, claimPrivateKey } = await defaultDepositTestSetup({ factory }); From a07d41e400e2250ab09794df3f9f8130838c5c31 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:08:05 +0200 Subject: [PATCH 04/12] format --- scripts/profile.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/profile.ts b/scripts/profile.ts index 380f074..b59a2fb 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -7,7 +7,6 @@ import { manager, randomReceiver, setupGiftProtocol, - } from "../lib"; import { newProfiler } from "../lib/gas"; From abae971d7136ad7be903fa4094894e3ee75371ee Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:14:57 +0200 Subject: [PATCH 05/12] remove useless arg --- lib/claim.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/claim.ts b/lib/claim.ts index e839acb..5e04594 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -107,15 +107,14 @@ export async function claimExternal(args: { dustReceiver?: string; claimPrivateKey: string; useTxV3?: boolean; - overrides?: { claimAccountAddress?: string; factoryAddress?: string; account?: Account }; + overrides?: { claimAccountAddress?: string; factoryAddress?: string;}; details?: UniversalDetails; }): Promise { - let account = args.overrides?.account || deployer; + let account = deployer; // Ugly tmp fix if (args.useTxV3) { - const devnetAddress = "0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691"; const devnetPrivateKey = "0x71d7bb07b9a64f6f78ac4c816aff4da9"; - account = new Account(manager, devnetAddress, devnetPrivateKey, undefined, RPC.ETransactionVersion.V3); + account = new Account(manager, account.address, devnetPrivateKey, undefined, RPC.ETransactionVersion.V3); } const signature = await signExternalClaim({ claim: args.claim, From 8ba369bb5e35ba6004d935c19a42a3184be4a335 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:18:31 +0200 Subject: [PATCH 06/12] use setDefaultTransactionVersionV3 --- lib/claim.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/claim.ts b/lib/claim.ts index 5e04594..be00ac3 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -16,6 +16,7 @@ import { deployer, ethAddress, manager, + setDefaultTransactionVersionV3, strkAddress, } from "."; @@ -113,8 +114,7 @@ export async function claimExternal(args: { let account = deployer; // Ugly tmp fix if (args.useTxV3) { - const devnetPrivateKey = "0x71d7bb07b9a64f6f78ac4c816aff4da9"; - account = new Account(manager, account.address, devnetPrivateKey, undefined, RPC.ETransactionVersion.V3); + account = setDefaultTransactionVersionV3(deployer); } const signature = await signExternalClaim({ claim: args.claim, From c8c09f0af8d1e3086a558a748677074ea792000f Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:22:04 +0200 Subject: [PATCH 07/12] update get dust to use tx version --- gas-report.txt | 4 ++-- lib/claim.ts | 1 - scripts/profile.ts | 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index 92802df..bbeedb7 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -11,7 +11,7 @@ Summary: │ Gifting WEI (FeeToken: FRI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming WEI (FeeToken: FRI) │ '1.368.000.000.320' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Claiming external WEI (FeeToken: FRI) │ '1.512.000.000.320' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Get dust WEI (FeeToken: FRI) │ '1.548.000.000.320' │ 0.0061 │ 1548000000000 │ 43 │ 40 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust WEI (FeeToken: FRI) │ '1.548.000.000.192' │ 0 │ 1548000000000 │ 43 │ 40 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Gifting FRI (FeeToken: WEI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming FRI (FeeToken: WEI) │ '1.368.000.000.320' │ 0.0054 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Claiming external FRI (FeeToken: WEI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ @@ -19,7 +19,7 @@ Summary: │ Gifting FRI (FeeToken: FRI) │ '1.548.000.000.416' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 4 │ 416 │ 'BLOB' │ │ Claiming FRI (FeeToken: FRI) │ '1.368.000.000.192' │ 0 │ 1368000000000 │ 38 │ 35 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Claiming external FRI (FeeToken: FRI) │ '1.512.000.000.256' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ -│ Get dust FRI (FeeToken: FRI) │ '1.440.000.000.320' │ 0.0057 │ 1440000000000 │ 40 │ 37 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust FRI (FeeToken: FRI) │ '1.440.000.000.192' │ 0 │ 1440000000000 │ 40 │ 37 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ └───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘ Resources: ┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐ diff --git a/lib/claim.ts b/lib/claim.ts index be00ac3..d214631 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -112,7 +112,6 @@ export async function claimExternal(args: { details?: UniversalDetails; }): Promise { let account = deployer; - // Ugly tmp fix if (args.useTxV3) { account = setDefaultTransactionVersionV3(deployer); } diff --git a/scripts/profile.ts b/scripts/profile.ts index b59a2fb..54e1d9f 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -6,6 +6,7 @@ import { deployer, manager, randomReceiver, + setDefaultTransactionVersionV3, setupGiftProtocol, } from "../lib"; import { newProfiler } from "../lib/gas"; @@ -76,8 +77,8 @@ for (const { giftTokenContract, unit } of tokens) { ); // Profiling getting the dust - factory.connect(deployer); - // TODO useTxV3 not used... + const account = useTxV3 ? setDefaultTransactionVersionV3(deployer) : deployer; + factory.connect(account); await profiler.profile( `Get dust ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, await factory.get_dust(buildCallDataClaim(claim), deployer.address), From ab28b5abaf28e586ea7b7f7769fac6df2a805877 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:22:29 +0200 Subject: [PATCH 08/12] format --- lib/claim.ts | 4 ++-- scripts/profile.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/claim.ts b/lib/claim.ts index d214631..333c458 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -108,10 +108,10 @@ export async function claimExternal(args: { dustReceiver?: string; claimPrivateKey: string; useTxV3?: boolean; - overrides?: { claimAccountAddress?: string; factoryAddress?: string;}; + overrides?: { claimAccountAddress?: string; factoryAddress?: string }; details?: UniversalDetails; }): Promise { - let account = deployer; + let account = deployer; if (args.useTxV3) { account = setDefaultTransactionVersionV3(deployer); } diff --git a/scripts/profile.ts b/scripts/profile.ts index 54e1d9f..d43b437 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -77,7 +77,7 @@ for (const { giftTokenContract, unit } of tokens) { ); // Profiling getting the dust - const account = useTxV3 ? setDefaultTransactionVersionV3(deployer) : deployer; + const account = useTxV3 ? setDefaultTransactionVersionV3(deployer) : deployer; factory.connect(account); await profiler.profile( `Get dust ${unit} (FeeToken: ${manager.tokens.unitTokenContract(useTxV3)})`, From 1139cae6f3fa7d72a0c221adf185e33e2f6380a5 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:28:17 +0200 Subject: [PATCH 09/12] remove never used details --- lib/claim.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/claim.ts b/lib/claim.ts index 333c458..fd0d6f9 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -109,7 +109,6 @@ export async function claimExternal(args: { claimPrivateKey: string; useTxV3?: boolean; overrides?: { claimAccountAddress?: string; factoryAddress?: string }; - details?: UniversalDetails; }): Promise { let account = deployer; if (args.useTxV3) { @@ -122,17 +121,13 @@ export async function claimExternal(args: { forceClaimAddress: args.overrides?.claimAccountAddress, dustReceiver: args.dustReceiver, }); - return await account.execute( - [ - { - contractAddress: args.overrides?.factoryAddress || args.claim.factory, - calldata: [buildCallDataClaim(args.claim), args.receiver, args.dustReceiver || "0x0", signature], - entrypoint: "claim_external", - }, - ], - undefined, - { ...args.details }, - ); + return await account.execute([ + { + contractAddress: args.overrides?.factoryAddress || args.claim.factory, + calldata: [buildCallDataClaim(args.claim), args.receiver, args.dustReceiver || "0x0", signature], + entrypoint: "claim_external", + }, + ]); } export async function claimInternal(args: { From 78440f42b165a9631abd31caf5f68578dfd8344a Mon Sep 17 00:00:00 2001 From: gaetbout Date: Mon, 24 Jun 2024 15:29:54 +0200 Subject: [PATCH 10/12] account ternary operator --- lib/claim.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/claim.ts b/lib/claim.ts index fd0d6f9..7d52f3b 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -110,10 +110,8 @@ export async function claimExternal(args: { useTxV3?: boolean; overrides?: { claimAccountAddress?: string; factoryAddress?: string }; }): Promise { - let account = deployer; - if (args.useTxV3) { - account = setDefaultTransactionVersionV3(deployer); - } + const account = args.useTxV3 ? setDefaultTransactionVersionV3(deployer) : deployer; + const signature = await signExternalClaim({ claim: args.claim, receiver: args.receiver, From eec0a6c59927a12dd5493d67cf657ca6e41cb331 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Fri, 28 Jun 2024 10:54:54 +0200 Subject: [PATCH 11/12] format + update gas report --- gas-report.txt | 32 ++++++++++++++++---------------- lib/claim.ts | 2 +- scripts/profile.ts | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index 2fc476c..c8f9ada 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -6,20 +6,20 @@ Summary: │ Transfer STRK (FeeToken: WEI) │ '828.000.000.320' │ 0.0033 │ 828000000000 │ 23 │ 21 │ 2 │ 1 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Gifting WEI (FeeToken: WEI) │ '1.548.000.000.288' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 3 │ 288 │ 'BLOB' │ │ Claiming WEI (FeeToken: WEI) │ '1.188.000.000.192' │ 0.0047 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ -│ Claiming external WEI (FeeToken: WEI) │ '1.512.000.000.256' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ -│ Get dust WEI (FeeToken: WEI) │ '1.512.000.000.192' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ +│ Claiming external WEI (FeeToken: WEI) │ '1.620.000.000.256' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ +│ Get dust WEI (FeeToken: WEI) │ '1.620.000.000.192' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Gifting WEI (FeeToken: FRI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming WEI (FeeToken: FRI) │ '1.188.000.000.320' │ 0 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Claiming external WEI (FeeToken: FRI) │ '1.512.000.000.320' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Get dust WEI (FeeToken: FRI) │ '1.620.000.000.320' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Claiming external WEI (FeeToken: FRI) │ '1.620.000.000.320' │ 0 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust WEI (FeeToken: FRI) │ '1.728.000.000.320' │ 0.0069 │ 1728000000000 │ 48 │ 45 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ │ Gifting FRI (FeeToken: WEI) │ '2.196.000.000.480' │ 0.0087 │ 2196000000000 │ 61 │ 52 │ 7 │ 3 │ 'steps' │ 5 │ 480 │ 'BLOB' │ │ Claiming FRI (FeeToken: WEI) │ '1.188.000.000.320' │ 0.0047 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Claiming external FRI (FeeToken: WEI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ -│ Get dust FRI (FeeToken: WEI) │ '1.620.000.000.192' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ +│ Claiming external FRI (FeeToken: WEI) │ '1.620.000.000.320' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust FRI (FeeToken: WEI) │ '1.728.000.000.192' │ 0.0069 │ 1728000000000 │ 48 │ 45 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Gifting FRI (FeeToken: FRI) │ '1.548.000.000.416' │ 0.0061 │ 1548000000000 │ 43 │ 37 │ 5 │ 2 │ 'steps' │ 4 │ 416 │ 'BLOB' │ │ Claiming FRI (FeeToken: FRI) │ '1.188.000.000.192' │ 0 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ -│ Claiming external FRI (FeeToken: FRI) │ '1.512.000.000.256' │ 0 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ -│ Get dust FRI (FeeToken: FRI) │ '1.512.000.000.320' │ 0.006 │ 1512000000000 │ 42 │ 39 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Claiming external FRI (FeeToken: FRI) │ '1.620.000.000.256' │ 0 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ +│ Get dust FRI (FeeToken: FRI) │ '1.620.000.000.320' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ └───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘ Resources: ┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐ @@ -29,18 +29,18 @@ Resources: │ Transfer STRK (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 25 │ 0 │ 181 │ 8184 │ │ Gifting WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 48 │ 0 │ 339 │ 14624 │ │ Claiming WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 373 │ 11715 │ -│ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 427 │ 15434 │ -│ Get dust WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 433 │ 15372 │ +│ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │ +│ Get dust WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 480 │ 16585 │ │ Gifting WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 64 │ 0 │ 465 │ 20607 │ │ Claiming WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11913 │ -│ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 427 │ 15434 │ -│ Get dust WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 50 │ 0 │ 467 │ 16544 │ +│ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │ +│ Get dust WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 50 │ 0 │ 514 │ 17757 │ │ Gifting FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 64 │ 0 │ 465 │ 20606 │ │ Claiming FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 373 │ 11715 │ -│ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 427 │ 15434 │ -│ Get dust FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 50 │ 0 │ 467 │ 16544 │ +│ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │ +│ Get dust FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 50 │ 0 │ 514 │ 17757 │ │ Gifting FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 48 │ 0 │ 339 │ 14625 │ │ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11913 │ -│ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 427 │ 15434 │ -│ Get dust FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 433 │ 15372 │ +│ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │ +│ Get dust FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 480 │ 16585 │ └───────────────────────────────────────┴─────────┴───────┴───────┴────────┴──────────┴──────────┴─────────────┴───────┘ diff --git a/lib/claim.ts b/lib/claim.ts index e93dd82..bcce5e3 100644 --- a/lib/claim.ts +++ b/lib/claim.ts @@ -129,7 +129,7 @@ export async function claimExternal(args: { signature, ]); const response = await account.execute( - executeActionOnAccount("claim_external", calculateEscrowAddress(args.gift), claimExternalCallData) + executeActionOnAccount("claim_external", calculateEscrowAddress(args.gift), claimExternalCallData), ); return manager.waitForTransaction(response.transaction_hash); } diff --git a/scripts/profile.ts b/scripts/profile.ts index a14cfdd..8f2204a 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -1,9 +1,9 @@ import { + claimDust, claimExternal, claimInternal, defaultDepositTestSetup, deployer, - claimDust, manager, randomReceiver, setDefaultTransactionVersionV3, From b66de94510d6a51022e5a15be7710de5dd3c7052 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Fri, 28 Jun 2024 11:49:00 +0200 Subject: [PATCH 12/12] get dust for multiple claims --- gas-report.txt | 8 ++++++++ scripts/profile.ts | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/gas-report.txt b/gas-report.txt index c8f9ada..a9c1f55 100644 --- a/gas-report.txt +++ b/gas-report.txt @@ -20,6 +20,10 @@ Summary: │ Claiming FRI (FeeToken: FRI) │ '1.188.000.000.192' │ 0 │ 1188000000000 │ 33 │ 30 │ 2 │ 2 │ 'steps' │ 3 │ 192 │ 'BLOB' │ │ Claiming external FRI (FeeToken: FRI) │ '1.620.000.000.256' │ 0 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 256 │ 'BLOB' │ │ Get dust FRI (FeeToken: FRI) │ '1.620.000.000.320' │ 0.0064 │ 1620000000000 │ 45 │ 42 │ 2 │ 2 │ 'steps' │ 4 │ 320 │ 'BLOB' │ +│ Get dust 2 (FeeToken: WEI) │ '2.772.000.000.320' │ 0.011 │ 2772000000000 │ 77 │ 71 │ 3 │ 4 │ 'steps' │ 5 │ 320 │ 'BLOB' │ +│ Get dust 3 (FeeToken: WEI) │ '3.960.000.000.384' │ 0.0158 │ 3960000000000 │ 110 │ 101 │ 4 │ 6 │ 'steps' │ 6 │ 384 │ 'BLOB' │ +│ Get dust 4 (FeeToken: WEI) │ '5.112.000.000.448' │ 0.0204 │ 5112000000000 │ 142 │ 130 │ 5 │ 8 │ 'steps' │ 7 │ 448 │ 'BLOB' │ +│ Get dust 5 (FeeToken: WEI) │ '6.264.000.000.512' │ 0.025 │ 6264000000000 │ 174 │ 160 │ 6 │ 9 │ 'steps' │ 8 │ 512 │ 'BLOB' │ └───────────────────────────────────────┴─────────────────────┴─────────┴────────────────┴────────────────┴─────────────────┴───────────┴──────────────┴──────────────────────────────┴───────────────┴────────┴─────────┘ Resources: ┌───────────────────────────────────────┬─────────┬───────┬───────┬────────┬──────────┬──────────┬─────────────┬───────┐ @@ -43,4 +47,8 @@ Resources: │ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11913 │ │ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │ │ Get dust FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 480 │ 16585 │ +│ Get dust 2 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 83 │ 0 │ 856 │ 28376 │ +│ Get dust 3 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 117 │ 0 │ 1232 │ 40167 │ +│ Get dust 4 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 151 │ 0 │ 1608 │ 51958 │ +│ Get dust 5 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 185 │ 0 │ 1984 │ 63749 │ └───────────────────────────────────────┴─────────┴───────┴───────┴────────┴──────────┴──────────┴─────────────┴───────┘ diff --git a/scripts/profile.ts b/scripts/profile.ts index 8f2204a..05d9516 100644 --- a/scripts/profile.ts +++ b/scripts/profile.ts @@ -1,9 +1,13 @@ +import { CallData } from "starknet"; import { + buildGiftCallData, + calculateEscrowAddress, claimDust, claimExternal, claimInternal, defaultDepositTestSetup, deployer, + executeActionOnAccount, manager, randomReceiver, setDefaultTransactionVersionV3, @@ -38,11 +42,11 @@ await profiler.profile( await strkContract.transfer(randomReceiver(), 1), ); +const receiver = "0x42"; +const { factory } = await setupGiftProtocol(); + for (const { giftTokenContract, unit } of tokens) { for (const useTxV3 of [false, true]) { - const receiver = "0x42"; - const { factory } = await setupGiftProtocol(); - // Profiling deposit const { txReceipt, gift, giftPrivateKey } = await defaultDepositTestSetup({ factory, @@ -86,5 +90,29 @@ for (const { giftTokenContract, unit } of tokens) { } } +const limits = [2, 3, 4, 5]; +for (const limit of limits) { + const claimDustCalls = []; + for (let i = 0; i < limit; i++) { + const { gift, giftPrivateKey } = await defaultDepositTestSetup({ + factory, + overrides: { + giftTokenAddress: ethContract.address, + }, + }); + + await claimInternal({ gift, receiver, giftPrivateKey: giftPrivateKey }); + const claimDustCallData = CallData.compile([buildGiftCallData(gift), receiver]); + const call = executeActionOnAccount("claim_dust", calculateEscrowAddress(gift), claimDustCallData); + + claimDustCalls.push(call); + } + + await profiler.profile( + `Get dust ${limit} (FeeToken: ${manager.tokens.unitTokenContract(false)})`, + await deployer.execute(claimDustCalls), + ); +} + profiler.printSummary(); profiler.updateOrCheckReport();