-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix unfairness on proof size check estimation (#2946)
* update frontier and moonkit pins * add test native transfer 21000 gas * fix typos and update test id * add test estimate for native transfer * revert cargo.lock identation changes * update frontier pin * update moonkit pin * update proof size ranges in PoV tests * Add code metadata to alice address to make it EOA * make rough pov less to make sure test pass as expected * remove invalid test (we cover the same in another test already) * update inline snapshots * increase the pov consumed (by increasing the amount of contracts) * remove unused import --------- Co-authored-by: Gonza Montiel <[email protected]> Co-authored-by: Gonza Montiel <[email protected]> Co-authored-by: Rodrigo Quelhas <[email protected]>
- Loading branch information
1 parent
23fbc7b
commit 55a2bbe
Showing
12 changed files
with
139 additions
and
105 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
75 changes: 75 additions & 0 deletions
75
test/suites/dev/moonbase/test-eth-tx/test-eth-tx-native-transfer.ts
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,75 @@ | ||
import { describeSuite, expect, beforeEach } from "@moonwall/cli"; | ||
import { | ||
ALITH_ADDRESS, | ||
BALTATHAR_ADDRESS, | ||
GLMR, | ||
createViemTransaction, | ||
checkBalance, | ||
} from "@moonwall/util"; | ||
|
||
describeSuite({ | ||
id: "D011300", | ||
title: "Native Token Transfer Test", | ||
foundationMethods: "dev", | ||
testCases: ({ context, it }) => { | ||
let initialAlithBalance: bigint; | ||
let initialBaltatharBalance: bigint; | ||
|
||
beforeEach(async function () { | ||
initialAlithBalance = await checkBalance(context, ALITH_ADDRESS); | ||
initialBaltatharBalance = await checkBalance(context, BALTATHAR_ADDRESS); | ||
}); | ||
|
||
it({ | ||
id: "T01", | ||
title: "Native transfer with fixed gas limit (21000) should succeed", | ||
test: async function () { | ||
const amountToTransfer = 1n * GLMR; | ||
const gasLimit = 21000n; | ||
|
||
// Create and send the transaction with fixed gas limit | ||
const { result } = await context.createBlock( | ||
createViemTransaction(context, { | ||
from: ALITH_ADDRESS, | ||
to: BALTATHAR_ADDRESS, | ||
value: amountToTransfer, | ||
gas: gasLimit, | ||
}) | ||
); | ||
|
||
expect(result?.successful).to.be.true; | ||
|
||
// Check balances after transfer | ||
const alithBalanceAfter = await checkBalance(context, ALITH_ADDRESS); | ||
const baltatharBalanceAfter = await checkBalance(context, BALTATHAR_ADDRESS); | ||
|
||
// Calculate gas cost | ||
const receipt = await context | ||
.viem() | ||
.getTransactionReceipt({ hash: result!.hash as `0x${string}` }); | ||
const gasCost = gasLimit * receipt.effectiveGasPrice; | ||
|
||
// Verify balances | ||
expect(alithBalanceAfter).to.equal(initialAlithBalance - amountToTransfer - gasCost); | ||
expect(baltatharBalanceAfter).to.equal(initialBaltatharBalance + amountToTransfer); | ||
|
||
// Verify gas used matches our fixed gas limit | ||
expect(receipt.gasUsed).to.equal(gasLimit); | ||
}, | ||
}); | ||
|
||
it({ | ||
id: "T02", | ||
title: "should estimate 21000 gas for native transfer", | ||
test: async function () { | ||
const estimatedGas = await context.viem().estimateGas({ | ||
account: ALITH_ADDRESS, | ||
to: BALTATHAR_ADDRESS, | ||
value: 1n * GLMR, | ||
}); | ||
|
||
expect(estimatedGas).to.equal(21000n); | ||
}, | ||
}); | ||
}, | ||
}); |
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
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
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
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
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