@aztec/end-to-end 0.86.0-nightly.20250430 → 0.86.0-nightly.20250502
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +60 -0
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +10 -3
- package/package.json +34 -34
- package/src/e2e_fees/bridging_race.notest.ts +74 -0
- package/src/e2e_fees/fees_test.ts +19 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridging_race.notest.d.ts","sourceRoot":"","sources":["../../src/e2e_fees/bridging_race.notest.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { Fr, sleep } from '@aztec/aztec.js';
|
|
3
|
+
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
|
|
4
|
+
import { Fq } from '@aztec/foundation/fields';
|
|
5
|
+
import { jest } from '@jest/globals';
|
|
6
|
+
import { FeesTest } from './fees_test.js';
|
|
7
|
+
jest.setTimeout(300_000);
|
|
8
|
+
// Regression for https://github.com/AztecProtocol/aztec-packages/issues/12366
|
|
9
|
+
// Similar to e2e_fees/account_init but with no automine
|
|
10
|
+
describe('e2e_fees bridging_race', ()=>{
|
|
11
|
+
const ETHEREUM_SLOT_DURATION = 4;
|
|
12
|
+
const AZTEC_SLOT_DURATION = ETHEREUM_SLOT_DURATION * 2;
|
|
13
|
+
const t = new FeesTest('bridging_race', 1, {
|
|
14
|
+
ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
|
|
15
|
+
aztecSlotDuration: AZTEC_SLOT_DURATION,
|
|
16
|
+
minTxsPerBlock: 0
|
|
17
|
+
});
|
|
18
|
+
beforeAll(async ()=>{
|
|
19
|
+
await t.applyInitialAccountsSnapshot();
|
|
20
|
+
await t.applyPublicDeployAccountsSnapshot();
|
|
21
|
+
await t.applySetupFeeJuiceSnapshot();
|
|
22
|
+
({ pxe, logger } = await t.setup());
|
|
23
|
+
});
|
|
24
|
+
afterAll(async ()=>{
|
|
25
|
+
await t.teardown();
|
|
26
|
+
});
|
|
27
|
+
let logger;
|
|
28
|
+
let pxe;
|
|
29
|
+
let bobsAddress;
|
|
30
|
+
beforeEach(async ()=>{
|
|
31
|
+
const bobsSecretKey = Fr.random();
|
|
32
|
+
const bobsPrivateSigningKey = Fq.random();
|
|
33
|
+
const bobsAccountManager = await getSchnorrAccount(pxe, bobsSecretKey, bobsPrivateSigningKey, Fr.random());
|
|
34
|
+
const bobsCompleteAddress = await bobsAccountManager.getCompleteAddress();
|
|
35
|
+
bobsAddress = bobsCompleteAddress.address;
|
|
36
|
+
await bobsAccountManager.getWallet();
|
|
37
|
+
await bobsAccountManager.register();
|
|
38
|
+
});
|
|
39
|
+
it('Alice bridges funds to Bob', async ()=>{
|
|
40
|
+
// Tweak the token manager so the bridging happens immediately before the end of the current L2 slot
|
|
41
|
+
// This caused the message to be "not in state" when tried to be used
|
|
42
|
+
const l1TokenManager = t.feeJuiceBridgeTestHarness.l1TokenManager;
|
|
43
|
+
const origApprove = l1TokenManager.approve.bind(l1TokenManager);
|
|
44
|
+
l1TokenManager.approve = async (amount, address, addressName = '')=>{
|
|
45
|
+
await origApprove(amount, address, addressName);
|
|
46
|
+
const sleepTime = (Number(t.chainMonitor.l2BlockTimestamp) + AZTEC_SLOT_DURATION) * 1000 - Date.now() - 500;
|
|
47
|
+
logger.info(`Sleeping for ${sleepTime}ms until near end of L2 slot before sending L1 fee juice to L2 inbox`);
|
|
48
|
+
await sleep(sleepTime);
|
|
49
|
+
};
|
|
50
|
+
// Waiting for the archiver to sync the message _before_ waiting for the mandatory 2 L2 blocks to pass fixed it
|
|
51
|
+
// This was added everywhere we wait for two blocks, which is spread across three different places in the codebase
|
|
52
|
+
// Yes, we need to REFACTOR it at some point
|
|
53
|
+
const amount = FEE_FUNDING_FOR_TESTER_ACCOUNT;
|
|
54
|
+
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, bobsAddress);
|
|
55
|
+
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
56
|
+
await t.feeJuiceContract.methods.claim(bobsAddress, amount, secret, index).send().wait();
|
|
57
|
+
const [balance] = await t.getGasBalanceFn(bobsAddress);
|
|
58
|
+
expect(balance).toEqual(amount);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fees_test.d.ts","sourceRoot":"","sources":["../../src/e2e_fees/fees_test.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EACL,KAAK,qBAAqB,EAK3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,aAAa,IAAI,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGxE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhD,OAAO,EAEL,KAAK,iBAAiB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CAAC;IACpD,eAAe,EAAG,UAAU,CAAC;IAC7B,wBAAwB,EAAG,UAAU,CAAC;IACtC,yBAAyB,EAAG,UAAU,CAAC;IACvC,YAAY,EAAG,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/D,SAAgB,qBAAqB,SAAgB;IACrD,SAAgB,mBAAmB,SAAgB;IACnD,SAAgB,0BAA0B,SAAgB;gBAGxD,QAAQ,EAAE,MAAM,EACR,gBAAgB,SAAI,EAC5B,YAAY,GAAE,OAAO,CAAC,YAAY,GAAG,qBAAqB,CAAM;IAc5D,KAAK;IAUL,QAAQ;IAKd,oBAAoB,CAAC,CAAC,EAAE,OAAO;IAIzB,kBAAkB;IAOlB,eAAe;;;;IAoBf,qBAAqB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;IAMjE,sFAAsF;IAChF,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY;IASjD,kBAAkB;IAOzB,4BAA4B;IAyB5B,iCAAiC;IAMjC,0BAA0B;IAuB1B,8BAA8B;IAuBvB,qBAAqB;IA4ErB,8BAA8B;IAqB9B,yBAAyB;IAWzB,gCAAgC;IAUhC,sBAAsB;CAgCpC"}
|
|
@@ -223,15 +223,22 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
223
223
|
return await rollup.getSequencerRewards(this.coinbase);
|
|
224
224
|
};
|
|
225
225
|
this.getProverFee = async (blockNumber)=>{
|
|
226
|
+
const block = await this.pxe.getBlock(blockNumber);
|
|
226
227
|
const publicClient = getPublicClient({
|
|
227
228
|
l1RpcUrls: context.aztecNodeConfig.l1RpcUrls,
|
|
228
229
|
l1ChainId: context.aztecNodeConfig.l1ChainId
|
|
229
230
|
});
|
|
230
231
|
const rollup = new RollupContract(publicClient, data.rollupAddress);
|
|
231
|
-
|
|
232
|
-
|
|
232
|
+
// @todo @lherskind As we deal with #13601
|
|
233
|
+
// Right now the value is from `FeeLib.sol`
|
|
234
|
+
const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
|
|
235
|
+
// We round up
|
|
236
|
+
const mulDiv = (a, b, c)=>a * b / c + (a * b % c > 0n ? 1n : 0n);
|
|
237
|
+
const { baseFee } = await rollup.getL1FeesAt(block.header.globalVariables.timestamp.toBigInt());
|
|
238
|
+
const proverCost = mulDiv(mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, await rollup.getEpochDuration()), 1n, await rollup.getManaTarget()) + await rollup.getProvingCostPerMana();
|
|
239
|
+
const price = await rollup.getFeeAssetPerEth();
|
|
233
240
|
const mana = block.header.totalManaUsed.toBigInt();
|
|
234
|
-
return mana *
|
|
241
|
+
return mulDiv(mana * proverCost, price, 10n ** 9n);
|
|
235
242
|
};
|
|
236
243
|
});
|
|
237
244
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/end-to-end",
|
|
3
|
-
"version": "0.86.0-nightly.
|
|
3
|
+
"version": "0.86.0-nightly.20250502",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"inherits": [
|
|
@@ -25,39 +25,39 @@
|
|
|
25
25
|
"formatting": "run -T prettier --check ./src && run -T eslint ./src"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aztec/accounts": "0.86.0-nightly.
|
|
29
|
-
"@aztec/archiver": "0.86.0-nightly.
|
|
30
|
-
"@aztec/aztec": "0.86.0-nightly.
|
|
31
|
-
"@aztec/aztec-node": "0.86.0-nightly.
|
|
32
|
-
"@aztec/aztec.js": "0.86.0-nightly.
|
|
33
|
-
"@aztec/bb-prover": "0.86.0-nightly.
|
|
34
|
-
"@aztec/blob-lib": "0.86.0-nightly.
|
|
35
|
-
"@aztec/blob-sink": "0.86.0-nightly.
|
|
36
|
-
"@aztec/bot": "0.86.0-nightly.
|
|
37
|
-
"@aztec/cli": "0.86.0-nightly.
|
|
38
|
-
"@aztec/constants": "0.86.0-nightly.
|
|
39
|
-
"@aztec/entrypoints": "0.86.0-nightly.
|
|
40
|
-
"@aztec/epoch-cache": "0.86.0-nightly.
|
|
41
|
-
"@aztec/ethereum": "0.86.0-nightly.
|
|
42
|
-
"@aztec/foundation": "0.86.0-nightly.
|
|
43
|
-
"@aztec/kv-store": "0.86.0-nightly.
|
|
44
|
-
"@aztec/l1-artifacts": "0.86.0-nightly.
|
|
45
|
-
"@aztec/merkle-tree": "0.86.0-nightly.
|
|
46
|
-
"@aztec/noir-contracts.js": "0.86.0-nightly.
|
|
47
|
-
"@aztec/noir-noirc_abi": "0.86.0-nightly.
|
|
48
|
-
"@aztec/noir-protocol-circuits-types": "0.86.0-nightly.
|
|
49
|
-
"@aztec/noir-test-contracts.js": "0.86.0-nightly.
|
|
50
|
-
"@aztec/p2p": "0.86.0-nightly.
|
|
51
|
-
"@aztec/protocol-contracts": "0.86.0-nightly.
|
|
52
|
-
"@aztec/prover-client": "0.86.0-nightly.
|
|
53
|
-
"@aztec/prover-node": "0.86.0-nightly.
|
|
54
|
-
"@aztec/pxe": "0.86.0-nightly.
|
|
55
|
-
"@aztec/sequencer-client": "0.86.0-nightly.
|
|
56
|
-
"@aztec/simulator": "0.86.0-nightly.
|
|
57
|
-
"@aztec/stdlib": "0.86.0-nightly.
|
|
58
|
-
"@aztec/telemetry-client": "0.86.0-nightly.
|
|
59
|
-
"@aztec/validator-client": "0.86.0-nightly.
|
|
60
|
-
"@aztec/world-state": "0.86.0-nightly.
|
|
28
|
+
"@aztec/accounts": "0.86.0-nightly.20250502",
|
|
29
|
+
"@aztec/archiver": "0.86.0-nightly.20250502",
|
|
30
|
+
"@aztec/aztec": "0.86.0-nightly.20250502",
|
|
31
|
+
"@aztec/aztec-node": "0.86.0-nightly.20250502",
|
|
32
|
+
"@aztec/aztec.js": "0.86.0-nightly.20250502",
|
|
33
|
+
"@aztec/bb-prover": "0.86.0-nightly.20250502",
|
|
34
|
+
"@aztec/blob-lib": "0.86.0-nightly.20250502",
|
|
35
|
+
"@aztec/blob-sink": "0.86.0-nightly.20250502",
|
|
36
|
+
"@aztec/bot": "0.86.0-nightly.20250502",
|
|
37
|
+
"@aztec/cli": "0.86.0-nightly.20250502",
|
|
38
|
+
"@aztec/constants": "0.86.0-nightly.20250502",
|
|
39
|
+
"@aztec/entrypoints": "0.86.0-nightly.20250502",
|
|
40
|
+
"@aztec/epoch-cache": "0.86.0-nightly.20250502",
|
|
41
|
+
"@aztec/ethereum": "0.86.0-nightly.20250502",
|
|
42
|
+
"@aztec/foundation": "0.86.0-nightly.20250502",
|
|
43
|
+
"@aztec/kv-store": "0.86.0-nightly.20250502",
|
|
44
|
+
"@aztec/l1-artifacts": "0.86.0-nightly.20250502",
|
|
45
|
+
"@aztec/merkle-tree": "0.86.0-nightly.20250502",
|
|
46
|
+
"@aztec/noir-contracts.js": "0.86.0-nightly.20250502",
|
|
47
|
+
"@aztec/noir-noirc_abi": "0.86.0-nightly.20250502",
|
|
48
|
+
"@aztec/noir-protocol-circuits-types": "0.86.0-nightly.20250502",
|
|
49
|
+
"@aztec/noir-test-contracts.js": "0.86.0-nightly.20250502",
|
|
50
|
+
"@aztec/p2p": "0.86.0-nightly.20250502",
|
|
51
|
+
"@aztec/protocol-contracts": "0.86.0-nightly.20250502",
|
|
52
|
+
"@aztec/prover-client": "0.86.0-nightly.20250502",
|
|
53
|
+
"@aztec/prover-node": "0.86.0-nightly.20250502",
|
|
54
|
+
"@aztec/pxe": "0.86.0-nightly.20250502",
|
|
55
|
+
"@aztec/sequencer-client": "0.86.0-nightly.20250502",
|
|
56
|
+
"@aztec/simulator": "0.86.0-nightly.20250502",
|
|
57
|
+
"@aztec/stdlib": "0.86.0-nightly.20250502",
|
|
58
|
+
"@aztec/telemetry-client": "0.86.0-nightly.20250502",
|
|
59
|
+
"@aztec/validator-client": "0.86.0-nightly.20250502",
|
|
60
|
+
"@aztec/world-state": "0.86.0-nightly.20250502",
|
|
61
61
|
"@iarna/toml": "^2.2.5",
|
|
62
62
|
"@jest/globals": "^29.5.0",
|
|
63
63
|
"@noble/curves": "^1.0.0",
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { Fr, type Logger, type PXE, sleep } from '@aztec/aztec.js';
|
|
3
|
+
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
|
|
4
|
+
import { Fq } from '@aztec/foundation/fields';
|
|
5
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
|
|
7
|
+
import { jest } from '@jest/globals';
|
|
8
|
+
import type { Hex } from 'viem';
|
|
9
|
+
|
|
10
|
+
import { FeesTest } from './fees_test.js';
|
|
11
|
+
|
|
12
|
+
jest.setTimeout(300_000);
|
|
13
|
+
|
|
14
|
+
// Regression for https://github.com/AztecProtocol/aztec-packages/issues/12366
|
|
15
|
+
// Similar to e2e_fees/account_init but with no automine
|
|
16
|
+
describe('e2e_fees bridging_race', () => {
|
|
17
|
+
const ETHEREUM_SLOT_DURATION = 4;
|
|
18
|
+
const AZTEC_SLOT_DURATION = ETHEREUM_SLOT_DURATION * 2;
|
|
19
|
+
|
|
20
|
+
const t = new FeesTest('bridging_race', 1, {
|
|
21
|
+
ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
|
|
22
|
+
aztecSlotDuration: AZTEC_SLOT_DURATION,
|
|
23
|
+
minTxsPerBlock: 0,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
beforeAll(async () => {
|
|
27
|
+
await t.applyInitialAccountsSnapshot();
|
|
28
|
+
await t.applyPublicDeployAccountsSnapshot();
|
|
29
|
+
await t.applySetupFeeJuiceSnapshot();
|
|
30
|
+
|
|
31
|
+
({ pxe, logger } = await t.setup());
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterAll(async () => {
|
|
35
|
+
await t.teardown();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
let logger: Logger;
|
|
39
|
+
let pxe: PXE;
|
|
40
|
+
let bobsAddress: AztecAddress;
|
|
41
|
+
|
|
42
|
+
beforeEach(async () => {
|
|
43
|
+
const bobsSecretKey = Fr.random();
|
|
44
|
+
const bobsPrivateSigningKey = Fq.random();
|
|
45
|
+
const bobsAccountManager = await getSchnorrAccount(pxe, bobsSecretKey, bobsPrivateSigningKey, Fr.random());
|
|
46
|
+
const bobsCompleteAddress = await bobsAccountManager.getCompleteAddress();
|
|
47
|
+
bobsAddress = bobsCompleteAddress.address;
|
|
48
|
+
await bobsAccountManager.getWallet();
|
|
49
|
+
await bobsAccountManager.register();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('Alice bridges funds to Bob', async () => {
|
|
53
|
+
// Tweak the token manager so the bridging happens immediately before the end of the current L2 slot
|
|
54
|
+
// This caused the message to be "not in state" when tried to be used
|
|
55
|
+
const l1TokenManager = t.feeJuiceBridgeTestHarness.l1TokenManager;
|
|
56
|
+
const origApprove = l1TokenManager.approve.bind(l1TokenManager);
|
|
57
|
+
l1TokenManager.approve = async (amount: bigint, address: Hex, addressName = '') => {
|
|
58
|
+
await origApprove(amount, address, addressName);
|
|
59
|
+
const sleepTime = (Number(t.chainMonitor.l2BlockTimestamp) + AZTEC_SLOT_DURATION) * 1000 - Date.now() - 500;
|
|
60
|
+
logger.info(`Sleeping for ${sleepTime}ms until near end of L2 slot before sending L1 fee juice to L2 inbox`);
|
|
61
|
+
await sleep(sleepTime);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Waiting for the archiver to sync the message _before_ waiting for the mandatory 2 L2 blocks to pass fixed it
|
|
65
|
+
// This was added everywhere we wait for two blocks, which is spread across three different places in the codebase
|
|
66
|
+
// Yes, we need to REFACTOR it at some point
|
|
67
|
+
const amount = FEE_FUNDING_FOR_TESTER_ACCOUNT;
|
|
68
|
+
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, bobsAddress);
|
|
69
|
+
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
70
|
+
await t.feeJuiceContract.methods.claim(bobsAddress, amount, secret, index).send().wait();
|
|
71
|
+
const [balance] = await t.getGasBalanceFn(bobsAddress);
|
|
72
|
+
expect(balance).toEqual(amount);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -310,17 +310,33 @@ export class FeesTest {
|
|
|
310
310
|
};
|
|
311
311
|
|
|
312
312
|
this.getProverFee = async (blockNumber: number) => {
|
|
313
|
+
const block = await this.pxe.getBlock(blockNumber);
|
|
314
|
+
|
|
313
315
|
const publicClient = getPublicClient({
|
|
314
316
|
l1RpcUrls: context.aztecNodeConfig.l1RpcUrls,
|
|
315
317
|
l1ChainId: context.aztecNodeConfig.l1ChainId,
|
|
316
318
|
});
|
|
317
319
|
const rollup = new RollupContract(publicClient, data.rollupAddress);
|
|
318
320
|
|
|
319
|
-
|
|
321
|
+
// @todo @lherskind As we deal with #13601
|
|
322
|
+
// Right now the value is from `FeeLib.sol`
|
|
323
|
+
const L1_GAS_PER_EPOCH_VERIFIED = 1000000n;
|
|
324
|
+
|
|
325
|
+
// We round up
|
|
326
|
+
const mulDiv = (a: bigint, b: bigint, c: bigint) => (a * b) / c + ((a * b) % c > 0n ? 1n : 0n);
|
|
327
|
+
|
|
328
|
+
const { baseFee } = await rollup.getL1FeesAt(block!.header.globalVariables.timestamp.toBigInt());
|
|
329
|
+
const proverCost =
|
|
330
|
+
mulDiv(
|
|
331
|
+
mulDiv(L1_GAS_PER_EPOCH_VERIFIED, baseFee, await rollup.getEpochDuration()),
|
|
332
|
+
1n,
|
|
333
|
+
await rollup.getManaTarget(),
|
|
334
|
+
) + (await rollup.getProvingCostPerMana());
|
|
335
|
+
|
|
336
|
+
const price = await rollup.getFeeAssetPerEth();
|
|
320
337
|
|
|
321
|
-
const block = await this.pxe.getBlock(blockNumber);
|
|
322
338
|
const mana = block!.header.totalManaUsed.toBigInt();
|
|
323
|
-
return mana *
|
|
339
|
+
return mulDiv(mana * proverCost, price, 10n ** 9n);
|
|
324
340
|
};
|
|
325
341
|
},
|
|
326
342
|
);
|