New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Create your Own EVM Blockchain Utilizing Advanced Subnets - Gabriel Cardona

Ethereum DenverSun, Oct 9, 2022, 12:00 AM

Transcript

thanks everyone um very happy to be here and uh thank you for showing up so early uh for this talk um we're gonna try and get through some live coding today and a quick overview of how aztec connect works uh so yeah the agenda today um go through the eve denver bound bounties um an overview of aztec connect discuss some of the ideas uh for the hackathon that you can work on a bit more detail on how the actual [Music] layer one layer two interface works and then we're gonna attempt to do some live coding and code up a uni-swap bridge um to interact with layer one uni swap from inside aztec using aztec connect i want to make it interactive so if you guys want to ask questions just stop me and i'll do my best to kind of answer them so we can learn something today so for those of you who don't know aztec is a private roll-up on ethereum and we bring 10 times gas savings and privacy uh to ethereum we launched about a year ago with private payments and we're about to launch aztec connect which is our interface to all of layer 1 d5 um we're thrilled to be sponsoring the hackathon um we have two tracks uh for kind of our bounties um both of them are available for in real life participants and virtual attendees um on the left-hand side we've got privacy-enabled dapps so using our sdk to build uh kind of new interfaces things like zk money dow payments private kind of batch payments to contributors and on the right-hand side uh building aztec connect bridge contracts and so using the interface we're going to discuss today to interact with any l1 smart contract from inside aztec so um let's go into a bit more detail about what aztec connect is um it's a private bridge to ethereum and it operates as a layer 2 sitting just below ethereum we're a bit different to some of the other l2s because we're focused on users moving their funds to aztec but the protocols stay on l1 and we interact with them through a process called d5 pooling giving privacy and gas savings to users so some of the highlights we get about 10 to 100 times gas savings depending on which interaction you're doing compared to an l1 standard ethereum d5 transaction it depends on the complexity of the actual smart contracts but um on average we're seeing about 10 to 100 times gas savings the main benefit the protocols enjoy is that we use layer 1 liquidity so we're not moving protocols to l2 we're moving the users and we're interacting with the protocols on our one directly um this means you can call kind of the 50 billion dollars of liquidity on uni swap directly from inside aztec and there's great kind of interoperability between uh protocols that use kind of uh multi multiple d5 protocols so for example if your d5 protocol uses curve and balancer to do swaps like element you don't need to move all those protocols to l2 you can just interact with our one directly in terms of some of the [Music] kind of user stats we're targeting around 8 000 gas for private transactions um plus a share of the l1 d5 transaction cost if you have 100 users doing a uni-swap transaction kind of socialize that gas cost 140 000 gas across 100 users so you get kind of end to end unison transactions for about 12 000 gas which is pretty great the roll-up can support around a thousand transactions per block and we can interact with up to 32 different smart contracts per roll-up at the moment we're targeting roll-ups every 10 minutes so for eve denver um there's a few things that we've kind of seen through our discord and people have been building or asking us to build i think the most exciting ones are kind of private governance and private kind of voting um if protocol uses like on-chain governance you can use aztec connect to vote privately and with 10 to 30 times gas savings uh how this actually works is the aztec roll up votes on behalf of all the users who it has tokens for and that's something we're really keen to see bridges built for maybe a compound governor bravo integration and a front end that kind of manages proposals and lets people vote using aztec and on the left-hand side you can also use azdek connect to purchase nfts privately um so users supply eth to a bridge contract on aztec and you can purchase nfts on openc and it just looks unchained like the roll-up has bought an nft and you don't know which user has bought it which is kind of a cool problem when people are kind of doxing their dgen trading accounts purchasing nfts and linking the two together also we're happy to kind of um hack on bridge contracts that are just uh to popular d5 protocols um through our grants program we have about 20 um bridges in progress but there's a lot of protocols that aren't being built right now um so if you want to build a connector um to aztec just just come see us at the booth and um chat to us and we can uh figure out the best way to integrate it okay so in terms of the uh interface and how aztec connect works all the interfaces are written in solidity it's just a layer one smart contract um the maps d5 protocol to a function interface that the roll-up contract can understand and we we model d5 or any l1 smart contract as an asynchronous token swap where you can pass in two input assets and receive back two output assets and there's two kind of like models for the swap one happens atomically so in a roll-up block you could call out to uni swap with ether and expect back die in the same block and there's also an asynchronous flow which could be useful for limit orders or kind of we actually use it for the element bridge where users kind of initiate a d5 transaction in block one and in block 100 it settles and users on aztec get their funds back a certain amount of time later um so both of those are possible with the bridge and we think that this interface really lets you interact with most of d5 so we're excited to see what everyone builds with it as a quick example for uni swap um actually before i dive into this do they don't have any questions on on the interface and what's possible with it yep uh so the question was how do we aggregate people together um yeah so maybe i can do this with the unisop example um users create kind of trade intents or transactions using the aztec sdk um and instead of kind of sending it to another user on aztec you end up sending it to a bridge address so you can aggregate all transactions which are going to the same bridge address and have the same kind of function parameters so for a unisop example you can aggregate all each die swaps that have the same slippage and it's up to kind of the front end and the sdk to kind of set that slippage to get the best batching um it's also up to the user to decide do they want to kind of wait uh a certain amount of time to have higher gas savings um or do they want to pay just the full cost of their one if they want to go instantly and kind of avoid batching the roll-up itself does the batching and it just happens automatically so if you send a transaction as a user um you kind of always have a chance of being batched but it depends on how obscure your kind of default interaction is the common protocols will kind of try and set the fees so that um the batch is like sane compared to l1 traffic so if we see a protocol has i don't know 500 daily deposits a day on r1 we may set the batch to be an hour and 20 transactions to get kind of reasonable gas savings for the user does that make sense cool anyone else um okay cool um so for uni swap um the way this flow works uh imagine i've got some shielded ether on aztec um and i decide i want to swap it on uni swap i send a private transaction using the aztec sdk to an aztec node um the input to that transaction is an amount of my shielded eth and i'm expecting back some zkdie so the aztec node then based on the fees decides to create a roll-up proof and it will aggregate transactions together um which have similar kind of trade intents or similar are going to similar bridge contracts and it creates a roll-up proof uh for those transactions kind of summing up the aggregate value but keeping the user's identities hidden throughout the process and then that roll-up proof is sent to l1 um it's effectively uh has inside it uh kind of instructions that allows the aztec rollup contract on l1 which owns all of the users funds to make a trade with uni swap directly through your bridge contract um so that trade is kind of on behalf of all the users who did that particular interaction um and because it's a zero knowledge proof um we have kind of iron clad cryptography guarantees that um when the trade happens um it's kind of it's guaranteed that all the users um it's the correct record of events there's no kind of optimistic roll-up uh delays here um once the proof is valid on l1 we have the authority to actually transact on behalf of all those users so then the roll-up sends a transact transaction out to uni-swap receives back an amount of die and this is sent back to the roll-up contract and it's distributed pro rata to all the users on aztec so if you put in one ether and i put in 90 um i'd get 10 of the proceeds and you'd get 90 of the proceeds and that happens trustee by the aztec nodes they're incentivized to do that and yeah the most important part of this is that user identities are hidden throughout so the privacy set for this transaction is anyone who's ever deposited eth to the aztec network you could have been at the moment one of about 40 000 people who've deposited uh east aztec and uh kind of that's just growing every day so the more defined interactions we have uh the privacy set just grows um for this it's not a privacy set per batch it's kind of a global privacy set for the whole system okay so let's move on to some coding um there's a aztec connect bridges repo which is at this address i'll give people some time to clone this down and then we can go through the setup and start coding up uh unisa bridge oh sorry um it's fully collateralized in the roll-up contract so when you shield eth you deposit each to the aztec roll-up contract on l1 and you're given um an encrypted uh utxo note that represents the amount you shielded so it's not a different token it's just uh you're given like an encrypted representation of that token that you can spend with aztec proofs um but the roll-up contract holds all the tokens for the duration at the time they're inside aztec uh yeah so so the question was would i get my tokens back in a one-to-one ratio yeah you can always shield back um or unshield your assets in a one-to-one ratio um the only time that there wouldn't be a one-to-one ratio is if there was a hack and the roll-up lost some of its tokens any other questions uh it's a good question so um [Music] uh the question was to maximize the uh anonymity set um at the bridge layer is it uh useful to use a kind of standardized amount um so when you do a bridge interaction um the kind of privacy set it's public how much is being transacted so um let's say i decided to kind of uh swap six nine six nine eight on uni swap um that's likely gonna be um identifying if at a later date i unshield um kind of that amount of eth oh okay we may not have time to do coding then um but uh yeah so it is useful to um kind of restrict the privacy set um so restrict the amounts to increase the privacy set but only very large amounts or kind of very high precision amounts can actually be identifying and the identifier bill like action is actually when you leave aztek not whilst you're inside aztec so if you kind of shielded funds to aztec did a load of d5 interactions but never left you'd never be at kind of risk of kind of breaching your privacy cool um has everyone managed to clone the repo i may just uh kind of do a quick example of how to actually uh do this with uni swap but we've only got five minutes so uh people are interested we can [Music] kind of come by the booth we're at booth m2 which is two floors down and we can go into a bit more detail cool um so this is a uh version of the aztec connect bridges repo um we structured it so it uses foundry um which is a kind of uh rust version of uh solidity tools um we use it because when you're kind of interacting with lots of l1 protocols it's much easier to fork from mainnet with this and you get really good stack traces so i've made a new folder here called uniswap and i've kind of set up a sample convert call with a few input assets and i haven't implemented any of the code here yet except the input asset swap when we have a token and we also expect out a token so you can see here it's just like normal coding and solidity we can call the uniswap interface um to swap exact tokens for tokens the roll-up contract will provide the total input value which is the value that all the users have sent the aggregate total of all the users who supplied input asset a and we can use that uh to kind of do a unison transaction and to kind of return funds back to the roll up uh we just set the output value a uh of the convert function to the amount we returned back and we approved those those tokens for kind of uh being claimed by the roll-up by just approving the se20 token transfer for the roll-up um if i run some of the tests here one second um this test is going to fail so far but you'll be able to see kind of uh the core trace of um what's happening and and kind of it may help people understand kind of the the execution flow so in our tests we simulate um a roll-up being processed um then the roll-up contract calls out to our proxy contract which will call out to your bridge um and then try and do the interaction in our case the interaction's failing because uh we're not returning the correct time of tokens um but uh we can go through this later and fix it because i think i'm out of time uh does anyone have any questions for now i think we won't get so much more live coding i would happily take some questions hey yeah definitely so we're working on a private smart contract language called noir the main difference between that and kind of some of the other languages is we'll have private state variables private logic so you'll use noir not necessarily to recreate all d5 protocols in the early days but doing stuff like identity management multi-sigs and kind of anything where you actually need private logic and private state variables and we're building it because i guess yes solidity doesn't have private primitives um so the focus of noir is um yeah just anything where privacy is like a core um core principle of your your dap we have it live right now um as a kind of an alpha language but it's not actually in the roll-up yet so the next kind of 8-12 months or us focusing on putting noir in the roll-up we call that aztec three so if you come back next year i'll give a talk and explain how it works thanks thanks for listening everyone

Automatic transcript — names and jargon may be misspelled.