Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ischasny committed Aug 15, 2024
1 parent a55430e commit 9fdb351
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
12 changes: 0 additions & 12 deletions core/node/fee_model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,6 @@ fn compute_batch_fee_model_input_v2(
l1_pubdata_price + pubdata_overhead_wei
};

tracing::debug!(
"Calculated gas prices L2: {} Pubdata: {}, L1 gas: {}, L1 pubdata: {}, L1 overhead: {}, max gas: {}, c_ohead: {}, p_ohead: {}",
fair_l2_gas_price,
fair_pubdata_price,
l1_gas_price,
l1_pubdata_price,
l1_batch_overhead_wei,
max_gas_per_batch,
compute_overhead_part,
pubdata_overhead_part
);

PubdataIndependentBatchFeeModelInput {
l1_gas_price,
fair_l2_gas_price,
Expand Down
33 changes: 31 additions & 2 deletions core/tests/ts-integration/src/test-master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,35 @@ import { claimEtherBack } from './context-owner';
import { RetryProvider } from './retry-provider';
import { Reporter } from './reporter';
import { bigIntReviver } from './helpers';
import { TransactionLike, TransactionRequest } from 'zksync-ethers/build/types';
import { getBigInt } from 'ethers';

export class BumpUpFeeWallet extends zksync.Wallet {
constructor(privateKey: string | ethers.SigningKey, providerL2?: zksync.Provider, providerL1?: ethers.Provider) {
super(privateKey, providerL2, providerL1);
}

override async populateTransaction(tx: TransactionRequest): Promise<TransactionLike> {
const baseToken = await this._providerL2().getBaseTokenContractAddress();
const isETHBasedChain = zksync.utils.isAddressEq(baseToken, zksync.utils.ETH_ADDRESS_IN_CONTRACTS);
// this is how much percent up we bumping up the fee to account for token price fluctuations
const adjustment = 30;

return super.populateTransaction(tx).then((result) => {
if (isETHBasedChain) {
return result;
} else {
}
if (result.maxFeePerGas) {
result.maxFeePerGas = (BigInt(100 + adjustment) * getBigInt(result.maxFeePerGas)) / BigInt(100);
}
if (result.gasPrice) {
result.gasPrice = (BigInt(100 + adjustment) * getBigInt(result.gasPrice)) / BigInt(100);
}
return result;
});
}
}

/**
* Test master is a singleton class (per suite) that is capable of providing wallets to the suite.
Expand Down Expand Up @@ -71,7 +100,7 @@ export class TestMaster {
this.l2Provider.pollingInterval = 5000;
}

this.mainWallet = new zksync.Wallet(suiteWalletPK, this.l2Provider, this.l1Provider);
this.mainWallet = new BumpUpFeeWallet(suiteWalletPK, this.l2Provider, this.l1Provider);
}

/**
Expand Down Expand Up @@ -112,7 +141,7 @@ export class TestMaster {
*/
newEmptyAccount(): zksync.Wallet {
const randomPK = ethers.Wallet.createRandom().privateKey;
const newWallet = new zksync.Wallet(randomPK, this.l2Provider, this.l1Provider);
const newWallet = new BumpUpFeeWallet(randomPK, this.l2Provider, this.l1Provider);
this.subAccounts.push(newWallet);
return newWallet;
}
Expand Down

0 comments on commit 9fdb351

Please sign in to comment.