Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions yarn-project/bot/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { PrivateTokenContract } from '@aztec/noir-contracts.js/PrivateToken';
import { TokenContract } from '@aztec/noir-contracts.js/Token';
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
import { GasSettings } from '@aztec/stdlib/gas';
import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
import { deriveSigningKey } from '@aztec/stdlib/keys';
import { EmbeddedWallet } from '@aztec/wallets/embedded';
Expand All @@ -49,7 +48,11 @@ export class BotFactory {
private readonly store: BotStore,
private readonly aztecNode: AztecNode,
private readonly aztecNodeAdmin?: AztecNodeAdmin,
) {}
) {
// Set fee padding on the wallet so that all transactions during setup
// (token deploy, minting, etc.) use the configured padding, not the default.
this.wallet.setMinFeePadding(config.minFeePadding);
}

/**
* Initializes a new bot by setting up the sender account, registering the recipient,
Expand Down Expand Up @@ -218,13 +221,11 @@ export class BotFactory {

const paymentMethod = new FeeJuicePaymentMethodWithClaim(accountManager.address, claim);
const deployMethod = await accountManager.getDeployMethod();
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1 + this.config.minFeePadding);
const gasSettings = GasSettings.default({ maxFeesPerGas });

await this.withNoMinTxsPerBlock(async () => {
const { txHash } = await deployMethod.send({
from: AztecAddress.ZERO,
fee: { gasSettings, paymentMethod },
fee: { paymentMethod },
wait: NO_WAIT,
});
this.log.info(`Sent tx for account deployment with hash ${txHash.toString()}`);
Expand Down
21 changes: 13 additions & 8 deletions yarn-project/end-to-end/src/e2e_bot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ describe('e2e_bot', () => {

afterAll(() => teardown());

let privateKeyIndex = 10;
const getPrivateKey = () => new SecretValue(bufferToHex(getPrivateKeyFromIndex(privateKeyIndex++)!));

describe('transaction-bot', () => {
let bot: Bot;
beforeAll(async () => {
Expand Down Expand Up @@ -131,10 +134,12 @@ describe('e2e_bot', () => {

l1RpcUrls,
feePaymentMethod: 'fee_juice',
// TODO: this should be taken from the `setup` call above
l1Mnemonic: new SecretValue('test test test test test test test test test test test junk'),
// Use a dedicated L1 account (index 7) for bridging. The default mnemonic account (index 0)
// is shared with the sequencer which sends L1 block proposals, causing nonce races on the
// approve/deposit calls in bridgeL1FeeJuice.
l1PrivateKey: new SecretValue(bufferToHex(getPrivateKeyFromIndex(7)!)),
flushSetupTransactions: true,
// Increase fee headroom to handle fee volatility from rapid block building in tests
// Fee headroom to handle fee volatility from rapid block building in tests.
minFeePadding: 9,
};

Expand Down Expand Up @@ -171,10 +176,10 @@ describe('e2e_bot', () => {

l1RpcUrls,
feePaymentMethod: 'fee_juice',
// TODO: this should be taken from the `setup` call above
l1Mnemonic: new SecretValue('test test test test test test test test test test test junk'),
// Dedicated L1 account to avoid nonce races with the sequencer.
l1PrivateKey: new SecretValue(bufferToHex(getPrivateKeyFromIndex(7)!)),
flushSetupTransactions: true,
// Increase fee headroom to handle fee volatility from rapid block building in tests
// Fee headroom to handle fee volatility from rapid block building in tests.
minFeePadding: 9,
};

Expand Down Expand Up @@ -235,7 +240,7 @@ describe('e2e_bot', () => {
followChain: 'PROPOSED',
botMode: 'transfer',
senderPrivateKey: new SecretValue(Fr.random()),
l1PrivateKey: new SecretValue(bufferToHex(getPrivateKeyFromIndex(8)!)),
l1PrivateKey: getPrivateKey(),
l1RpcUrls,
flushSetupTransactions: true,
};
Expand All @@ -258,7 +263,7 @@ describe('e2e_bot', () => {
followChain: 'PROPOSED',
botMode: 'crosschain',
l1RpcUrls,
l1PrivateKey: new SecretValue(bufferToHex(getPrivateKeyFromIndex(9)!)),
l1PrivateKey: getPrivateKey(),
flushSetupTransactions: true,
l1ToL2SeedCount: 2,
};
Expand Down
8 changes: 7 additions & 1 deletion yarn-project/stdlib/src/gas/gas_fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ export class GasFees {
return this.clone();
} else if (typeof scalar === 'bigint') {
return new GasFees(this.feePerDaGas * scalar, this.feePerL2Gas * scalar);
} else if (Number.isInteger(scalar)) {
const s = BigInt(scalar);
return new GasFees(this.feePerDaGas * s, this.feePerL2Gas * s);
} else {
return new GasFees(Number(this.feePerDaGas) * scalar, Number(this.feePerL2Gas) * scalar);
return new GasFees(
BigInt(Math.ceil(Number(this.feePerDaGas) * scalar)),
BigInt(Math.ceil(Number(this.feePerL2Gas) * scalar)),
);
}
}

Expand Down
Loading