Conversation
06010f3 to
28a33bd
Compare
critesjosh
left a comment
There was a problem hiding this comment.
Overall looking good! Some recommendations to improve the flow and some hiccups that I ran into as I tried to follow along.
also, once this PR (#20113) is merged, merge next into this branch and set up the index.ts file to run as part of the CI.
|
|
||
| use aztec::macros::aztec; | ||
|
|
||
| // docs:start:bridge_setup |
There was a problem hiding this comment.
should this be moved to line 1, so that the mod and imports are included?
| Add the Aztec dependencies: | ||
|
|
||
| ```bash | ||
| yarn add @aztec/aztec.js@#include_version_without_prefix @aztec/accounts@#include_version_without_prefix @aztec/stdlib@#include_version_without_prefix @aztec/wallets@#include_version_without_prefix tsx |
There was a problem hiding this comment.
the TS script also imports from @aztec/ethereum, @aztec/foundation, and @aztec/viem which aren't listed
docs/docs-developers/docs/tutorials/js_tutorials/aave_bridge.md
Outdated
Show resolved
Hide resolved
| Token["🪙 Token"] | ||
| end | ||
|
|
||
| Token -->|"1. Burn"| Bridge |
There was a problem hiding this comment.
I think the numbering is messed up here. I don't think we start with burning tokens.
There was a problem hiding this comment.
Oh i see, this is the flow, assuming you already have tokens on Aztec. It'd be worth clarifying that
docs/docs-developers/docs/tutorials/js_tutorials/aave_bridge.md
Outdated
Show resolved
Hide resolved
|
|
||
| The public variants are straightforward. `claim_public` consumes an L1→L2 message and mints tokens. `exit_to_l1_public` burns tokens and sends an L2→L1 message: | ||
|
|
||
| #include_code claim_public /docs/examples/contracts/aave_bridge/src/main.nr rust |
There was a problem hiding this comment.
make it more clear that these functions should be inserted into the body of the contract (if the reader is following along and building the contract)
|
|
||
| #include_code claim_public /docs/examples/contracts/aave_bridge/src/main.nr rust | ||
|
|
||
| #include_code exit_to_l1_public /docs/examples/contracts/aave_bridge/src/main.nr rust |
There was a problem hiding this comment.
claude says this is the issue (and it does indeed fix it):
The token contract uses path = "../../../../aztec-nr/aztec" (within the aztec-packages monorepo), but our contract pulls aztec from a different git URL (aztec-nr repo). This creates a diamond dependency — two different copies of PrivateCall/PublicCall types that the compiler treats as distinct.
The fix is to source our aztec dependency from aztec-packages (same as the token contract resolves to), not from the separate aztec-nr repo.
There was a problem hiding this comment.
wdyt about using the defi wonderland token?
There was a problem hiding this comment.
I think if we integrate it it should be in a downstream pr ! there are separate considerations to make if using that token
| ### Compile | ||
|
|
||
| ```bash | ||
| aztec compile |
There was a problem hiding this comment.
aztec new also sets up a test dir, so either we need to tell readers to delete it, or set some up. Claude update the test file to this
use aztec::protocol::address::{AztecAddress, EthAddress};
use aztec::protocol::traits::FromField;
use aztec::test::helpers::test_environment::TestEnvironment;
use aave_bridge::AaveBridge;
#[test]
unconstrained fn test_constructor() {
let mut env = TestEnvironment::new();
let deployer = env.create_light_account();
let token = AztecAddress::from_field(1);
let portal = EthAddress::from_field(2);
let initializer = AaveBridge::interface().constructor(token, portal);
let _contract_address =
env.deploy("@aave_bridge/AaveBridge").with_public_initializer(deployer, initializer);
}|
|
||
| ::: | ||
|
|
||
| Create the mock contracts in `contracts/`: |
There was a problem hiding this comment.
Make it clear what the exact names of these files should be
f1a1a62 to
292a4ab
Compare
6bed2cb to
3e75121
Compare
67b9da7 to
6be716f
Compare
5704f6b to
70bee50
Compare
70bee50 to
18c1708
Compare
critesjosh
left a comment
There was a problem hiding this comment.
i went through it and ended up with working code with help from claude. there are comments about several of the issues that i had to work through. it worked some magic on index.ts to make type errors go away, you can see the project that I ended up with here: critesjosh/hardhat-aztec-example#2
| subgraph Ethereum["Ethereum (L1)"] | ||
| Portal["🌉 AavePortal"] | ||
| Aave["🏦 Aave Pool"] | ||
| ERC20["💰 ERC20 Token"] |
|
|
||
| ## Prerequisites | ||
|
|
||
| - [Aztec local network running at version #include_aztec_version](../../../getting_started_on_local_network.md) (includes Aztec CLI and Node.js v18+) |
There was a problem hiding this comment.
| - [Aztec local network running at version #include_aztec_version](../../../getting_started_on_local_network.md) (includes Aztec CLI and Node.js v18+) | |
| - [Aztec local network running at version #include_aztec_version](../../../getting_started_on_local_network.md) (includes Aztec CLI and Node.js v24) |
node 24?
| User->>Bridge: exit_to_l1_public(amount) | ||
| Bridge->>Outbox: message_portal(content) | ||
| Bridge->>Token: burn_public(user, amount) | ||
| Note over Outbox: Wait for block proof |
There was a problem hiding this comment.
Do we have a time estimate we could share on this, or a heuristic so readers can get a sense for how long it might take?
|
|
||
| :::note | ||
|
|
||
| This template is a community-maintained starter. If the repository is unavailable, you can set up a Hardhat project manually and add the `@aztec/*` Solidity remappings from the [cross-chain messaging docs](../../foundational-topics/ethereum-aztec-messaging/index.md). |
There was a problem hiding this comment.
add a note that they might just need to update the tag on @aztec/l1-contracts in this referenced repo's package.json
e.g.
"@aztec/l1-contracts": "git+https://github.com/AztecProtocol/l1-contracts.git#v5.0.0-nightly.20260311",
| MockAavePool.sol | ||
| AavePortal.sol | ||
| contracts/aztec/ # Noir contracts | ||
| aave_bridge/ |
There was a problem hiding this comment.
there is a test folder as well
├── aave_bridge_test
│ ├── Nargo.toml
│ └── src
│ └── lib.nr
| import {IERC20} from "@oz/token/ERC20/IERC20.sol"; | ||
| import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol"; | ||
|
|
||
| import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; |
There was a problem hiding this comment.
I was also struggling with the remappings here. Claude worked around it by importing directly from the npm packages
import {IRegistry} from "@aztec/l1-contracts/src/governance/interfaces/IRegistry.sol";
import {IInbox} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol";
import {IOutbox} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IOutbox.sol";
import {IRollup} from "@aztec/l1-contracts/src/core/interfaces/IRollup.sol";
import {DataStructures} from "@aztec/l1-contracts/src/core/libraries/DataStructures.sol";
import {Hash} from "@aztec/l1-contracts/src/core/libraries/crypto/Hash.sol";
import {Epoch} from "@aztec/l1-contracts/src/core/libraries/TimeLib.sol";
| // docs:end:fund_user | ||
|
|
||
| // docs:start:mine_blocks | ||
| // On the local sandbox, L2 blocks are only produced when transactions are submitted. |
There was a problem hiding this comment.
| // On the local sandbox, L2 blocks are only produced when transactions are submitted. | |
| // On the local network, L2 blocks are only produced when transactions are submitted. |
| import { EmbeddedWallet } from "@aztec/wallets/embedded"; | ||
| import { decodeEventLog, pad, toFunctionSelector } from "@aztec/viem"; | ||
| import { foundry } from "@aztec/viem/chains"; | ||
| import AavePortal from "../../../target/solidity/aave_bridge/AavePortal.sol/AavePortal.json" with { type: "json" }; |
There was a problem hiding this comment.
following along, this is actually the relative path
| import AavePortal from "../../../target/solidity/aave_bridge/AavePortal.sol/AavePortal.json" with { type: "json" }; | |
| import AavePortal from "../target/solidity/aave_bridge/AavePortal.sol/AavePortal.json" with { type: "json" }; |
| Add the Aztec dependencies: | ||
|
|
||
| ```bash | ||
| yarn add @aztec/aztec.js@#include_version_without_prefix @aztec/accounts@#include_version_without_prefix @aztec/wallets@#include_version_without_prefix @aztec/stdlib@#include_version_without_prefix @aztec/foundation@#include_version_without_prefix @aztec/ethereum@#include_version_without_prefix @aztec/noir-contracts.js@#include_version_without_prefix @aztec/viem@#include_version_without_prefix tsx |
There was a problem hiding this comment.
i dont think this gets the right version. @aztec/viem@#include_version_without_prefix, @aztec/viem only has version 2.38.2
| yarn add @aztec/aztec.js@#include_version_without_prefix @aztec/accounts@#include_version_without_prefix @aztec/wallets@#include_version_without_prefix @aztec/stdlib@#include_version_without_prefix @aztec/foundation@#include_version_without_prefix @aztec/ethereum@#include_version_without_prefix @aztec/noir-contracts.js@#include_version_without_prefix @aztec/viem@#include_version_without_prefix tsx | |
| yarn add @aztec/aztec.js@#include_version_without_prefix @aztec/accounts@#include_version_without_prefix @aztec/wallets@#include_version_without_prefix @aztec/stdlib@#include_version_without_prefix @aztec/foundation@#include_version_without_prefix @aztec/ethereum@#include_version_without_prefix @aztec/noir-contracts.js@#include_version_without_prefix @aztec/viem@2.38.2 tsx |
| import MockAToken from "../../../target/solidity/aave_bridge/MockAToken.sol/MockAToken.json" with { type: "json" }; | ||
| import MockAavePool from "../../../target/solidity/aave_bridge/MockAavePool.sol/MockAavePool.json" with { type: "json" }; | ||
| import { TokenContract } from "@aztec/noir-contracts.js/Token"; | ||
| import { AaveBridgeContract } from "./artifacts/AaveBridge.js"; |
There was a problem hiding this comment.
also had to update this path to import { AaveBridgeContract } from "../contracts/aztec/artifacts/AaveBridge.js";


title