Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make canary uniswap test similar to e2e #2767

Merged
merged 7 commits into from
Oct 11, 2023
Merged

Conversation

rahul-kothari
Copy link
Contributor

added the cross-chain test harness in Canary as well, so that e2e tests and Canary tests look the same. This has some advantages:

  1. In the mid-term, I know we were planning to throw away canary tests and have e2e run as canary tests. This makes it easier for cross-chain tests to be replaced in canary tests.
  2. Cross-chain tests can now for sure be run on the sandbox. This serves as a green flag that we don't do anything wonky in e2e that isn't available in the sandbox
  3. e2e cross-chain tests can now be used in docs via #include_code with minimal copy-paste. Without the canary version of the cross-chain test harness, I would have to hardcode a lot in the docs. This makes it easily maintainable.

@rahul-kothari rahul-kothari changed the title make canary uniswap test similar to e2e chore: make canary uniswap test similar to e2e Oct 10, 2023
const wethL1BeforeBalance = await wethContract.read.balanceOf([ownerEthAddress.toString()]);
// 1. Approve weth to be bridged
await wethContract.write.approve([wethTokenPortalAddress.toString(), wethAmountToBridge], {} as any);
it('should uniswap trade on L1 from L2 funds privately (swaps WETH -> DAI)', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything from this line onwards is an exact copy-paste of end-to-end/uniswap_trade_on_l1_from_l2.test.ts!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comment later. There should be a way such that we can simply rerun the same ones instead of needing to copy them around like this.

* shared between cross chain tests.
*/
export class CrossChainTestHarness {
static async new(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to modify the CrossChainTestHarness.new() a bit to make it workable on sandbox. Otherwise it is mostly a copy paste!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot we alter the CrossChainTestHarness such that the same can be used both places without having these two that are almost just copied.

The cheatcodes are not used for example, there is probably other stuff that could also be purged such that it can be used both places.

createDebugLogger,
createPXEClient,
getL1ContractAddresses,
sleep as delay,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

const wethAmountToBridge = parseEther('1');
const uniswapFeeTier = 3000n;
const minimumOutputAmount = 0n;
const deadlineForDepositingSwappedDai = BigInt(2 ** 32 - 1); // max uint32 - 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just max uint32 not - 1, recall that max uint32 = 2**32 -1.

* shared between cross chain tests.
*/
export class CrossChainTestHarness {
static async new(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot we alter the CrossChainTestHarness such that the same can be used both places without having these two that are almost just copied.

The cheatcodes are not used for example, there is probably other stuff that could also be purged such that it can be used both places.

const wethL1BeforeBalance = await wethContract.read.balanceOf([ownerEthAddress.toString()]);
// 1. Approve weth to be bridged
await wethContract.write.approve([wethTokenPortalAddress.toString(), wethAmountToBridge], {} as any);
it('should uniswap trade on L1 from L2 funds privately (swaps WETH -> DAI)', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comment later. There should be a way such that we can simply rerun the same ones instead of needing to copy them around like this.

@rahul-kothari rahul-kothari force-pushed the rk/canary_similar branch 2 times, most recently from 0cd6197 to 4af81f3 Compare October 11, 2023 12:15
@socket-security
Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@libp2p/mplex 9.0.4 None +0 179 kB npm-service-account-libp2p

Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits. Really nice stuff 👍

logger('DAI balance after swap : ' + daiL2BalanceAfterSwap.toString());
}, 140_000);
});
uniswapL1L2TestSuite(setupRPC, () => Promise.resolve(), EXPECTED_FORKED_BLOCK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👑💩

@@ -356,11 +322,4 @@ export class CrossChainTestHarness {
const unshieldReceipt = await unshieldTx.wait();
expect(unshieldReceipt.status).toBe(TxStatus.MINED);
}

async stop() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you not still keep the stop, just without the aztecNode now?

Copy link
Contributor Author

@rahul-kothari rahul-kothari Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no teardown() from e2e setup is enough! teardown() has access to the node and kills it

@rahul-kothari rahul-kothari enabled auto-merge (squash) October 11, 2023 13:23
@@ -71,7 +72,7 @@ export function getConfigEnvVars(): ArchiverConfig {
rollupAddress: ROLLUP_CONTRACT_ADDRESS ? EthAddress.fromString(ROLLUP_CONTRACT_ADDRESS) : EthAddress.ZERO,
registryAddress: REGISTRY_CONTRACT_ADDRESS ? EthAddress.fromString(REGISTRY_CONTRACT_ADDRESS) : EthAddress.ZERO,
inboxAddress: INBOX_CONTRACT_ADDRESS ? EthAddress.fromString(INBOX_CONTRACT_ADDRESS) : EthAddress.ZERO,
outboxAddress: EthAddress.ZERO,
outboxAddress: OUTBOX_CONTRACT_ADDRESS ? EthAddress.fromString(OUTBOX_CONTRACT_ADDRESS) : EthAddress.ZERO,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot

@@ -26,9 +26,9 @@ export class CrossChainTestHarness {
const ethAccount = EthAddress.fromString((await walletClient.getAddresses())[0]);
const owner = wallet.getCompleteAddress();
const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier?

@rahul-kothari rahul-kothari merged commit 93d458b into master Oct 11, 2023
@rahul-kothari rahul-kothari deleted the rk/canary_similar branch October 11, 2023 14:05
@AztecBot
Copy link
Collaborator

Benchmark results

All benchmarks are run on txs on the Benchmarking contract on the repository. Each tx consists of a batch call to create_note and increment_balance, which guarantees that each tx has a private call, a nested private call, a public call, and a nested public call, as well as an emitted private note, an unencrypted log, and public storage read and write.

L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.

Metric 8 txs 32 txs 128 txs
l1_rollup_calldata_size_in_bytes 45444 179588 716132
l1_rollup_calldata_gas 222996 868184 3449456
l1_rollup_execution_gas 842083 3595292 22204825
l2_block_processing_time_in_ms 1091 4176 15124
note_successful_decrypting_time_in_ms 340 1056 3573
note_trial_decrypting_time_in_ms 42 107 136
l2_block_building_time_in_ms 8986 37382 150507
l2_block_rollup_simulation_time_in_ms 6725 27816 106372
l2_block_public_tx_process_time_in_ms 2218 9434 43478

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 16 txs.

Metric 10 blocks 20 blocks 30 blocks
node_history_sync_time_in_ms 31315 76095 137120
note_history_successful_decrypting_time_in_ms 4774 13206 20023
note_history_trial_decrypting_time_in_ms 146 255 262
node_database_size_in_bytes 1191378 1902330 2755457
pxe_database_size_in_bytes 54187 108338 162578

Circuits stats

Stats on running time and I/O sizes collected for every circuit run across all benchmarks.

Circuit circuit_simulation_time_in_ms circuit_input_size_in_bytes circuit_output_size_in_bytes
private-kernel-init 55.67791411042945 56577 14745
private-kernel-ordering 30.117331288343557 20137 8089
base-rollup 871 631604 810
root-rollup 38.24390243902439 4072 1097
private-kernel-inner 51.95524691358025 72288 14745
public-kernel-private-input 51.574074074074076 37359 14745
public-kernel-non-first-iteration 31.22530864197531 37401 14745
merge-rollup 1.0348837209302326 2592 873

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants