"USDC: Upgrading a $1.4bn Token" - Pete Kim, Joao Reginatto & Nemil Dalal
ETHGlobal·Sat, Oct 9, 2021, 12:00 AM
Speaker
Pete Kim, Joao Reginatto & Nemil Dalal present challenges they had to overcome with the recent USDC upgrade.
Transcript
uh from the usdc team uh from coinbase and we've actually got uh pete uh and uh namil um and joelle joining us uh nimil and joelle are going to give a brief introduction to usdc and then pete will give an overview of their recent upgrade to usdc uh version two um so welcome to the call guys i'll i'll let you take it from here cool thanks so much josh it's super exciting to talk to you all let me just really quickly share my screen sorry would you mind sharing your screen thanks so thanks everyone it's super exciting to talk to you really quickly i'm a product manager at coinbase i'm here with my counterpart at circle um joao reginato and uh also pete kim who's on the lead engineer coinbase on usdc we're super excited to talk to you about stablecoins but also about like what it takes to upgrade a token that has a lot of market value so there's a number of years 20 tokens out there and in a lot of ways a number of them have upgradeable capabilities and we thought it'd be really helpful to show what our journey was to be able to move from our ucc version one kind of the way we thought about future development and how we got to ufcc version two um but before we do that i thought it'd be really quickly just to recap some of the growth so uscc was launched um several years ago and over the course of for a long time you know it was uh about a 100 million 200 300 400 million dollar market cap and then slowly with the growth of the ethereum ecosystem especially with d5 liquidity uh mining we had just a tremendous amount of growth so ufcc is the second largest stable coin in the world um and it's almost at about 2.7 billion in market market cap right now our core differentiator and the thing that we focus on the most is to make it the most trusted fiat bank stablecoin and you'll see that not just in terms of uh the discussions that we have today in terms of what it means for our smart contracts what it means for our deployment and the super user keys that we hold but also um how we think about auditability putting monies in a bank account making sure that third parties are re reviewing it and if we go to the next slide like the core thing for us has always been that we should always want to be able to provide if someone comes to us gives us a dollar we can provide one usdc and vice versa is that you can give us one your cc and we can provide you back one dollar in fiat and so that's just really really critical in that trust for a stable coin this is a really basic uh key composition that we offer and the idea is that then a lot of d5 protocols and other uh teams can build on top another core differentiator for ucc versus other uh other types of stablecoin is a consortium so initially it started with circle and coinbase would work with a number of different partners and the goal over time is that we continue growing this similar to let's say a visa with a number of different members all look an issue uh and hold uh and participate in uscc and so i think this multi-ussr model is a big part of it um i think that that idea that we um we had transparent third party audited and that we're one of the fastest growing stable coins do you want to go next sure um yeah i think pete is saying that for some reason he couldn't present the screen anymore but i'll i'll talk over what we what we what we had there and uh and then hand it over to pete ford uh to talk about the upgrade of uscv2 um another thing oh it's back awesome um in the middle you want to pick pick back up from there yes sorry i got kicked out for some reason yeah so um no worries i figured the next slide so i think the core part is that like just a number of different teams are building on top of usdc uh if you go to the next slide you know a lot of the the protocols that we use each and every day um they all use usdc and i think the main plug i would maybe just give here for the group of anyone who's building an ether online um on uscc is if you go to the next slide um is that we have uh coinbase has a uscc bootstrap fund and what we do is this is different from other venture capital funds uh what we do is we put money directly in a protocol and so as a result what that means is that if you have a protocol you're getting started and you want liquidity in your protocol in the early months and weeks it can be very difficult it can be very little uh liquidity so what uh the usdc team has done um has basically been to put money in a variety of different protocols if you can if you want to apply there's a biddly link right there cool and i'll turn it over to you yeah so another thing that we are passionate about in the usc front and obviously myself coming from the circle side and the mill and pete have been working on this on the coinbase side amongst a lot of other team members yeah if you can move to the next slide p is uh is how ussc can be used as a as really a an alternative money infrastructure right for for those of you i don't know how many of you have built more traditional financial services but but if you have you're going to be familiar with uh you know integrating with banking connectivity systems uh banking networks around the world and payments processing around the world that can be extremely difficult time consuming expensive and and quite cumbersome and poor from a technology point of view we are we're passionate about seeing uh people beginning to use uscc as an alternative infrastructure for money whether it is use cases for you know around payments and payouts uh commerce uh you know what we call digital dollar accounts which is you know imagine every app on your phone that has a dollar balance right it doesn't have to be a financial service it can be uber airbnb you know marketplaces and how how you can basically reimagine all of those things built on top of this of this infrastructure um we are very passionate about that on the circle side we have actually you know pretty much bet the company now uh on this and we offer a number of developer tools whether it is on on fiat on and off ramps uh custodying um and various other types of apis and coinbase also has obviously a ton of ton of resources for that so uh make sure you head over um to the resources that those two companies have and uh there should be a ton of more developer tools coming out and in that spirit of making sure that ussc is not only a stable coin not only the raw rails but really a a tremendous amount of tools for developers to build the next generation financial services we we have devised uscv2 uh and i'll hand over to pete to to talk about what we designed there and how we how we how we've done the migration hi um so how was uscc v2 developed uh first it started with proposals lots and lots of pages of text describing the motivation technical design and the rationale it was a lot of writing and frankly um i don't really enjoy it as much as writing code but it you know i took it as practice for writing white papers for my future billion dollar blockchain project so it wasn't so bad anyway three different proposals were created and those were then reviewed by people at both coinbase and circle and after a bit of back and forth uh both coinbase and circle gave the thumbs up and it was time for building the first thing i had to do was uh to uh was modernizing the co-base ufcc was first deployed in 2018 and it was really starting to show its age it was using solidity 0.4 it uses use javascript as opposed to typescript and modern tooling like auto formatter and static code analyzers weren't used it took a long time to update everything but but i managed to discover and fix quite a number of bugs such as uh some tests passing only because some variables were being declared globally and accidentally being reused across multiple tests things like that so uh it was worth it once that was done it was time to develop the fiat token v2 contract which is the name of the uscc contract in our code base uscc was designed to be upgradable we do it by using this proxy contract pattern so basically users can interact with the proxy contract which borrows code from the implementation contract in this case fiat token v1 while keeping state data stored within the proxy contract this is made possible via the use of the delegate call up code so to upgrade to a new version we have to first deploy the new implementation contract and then update the pointer in the proxy contract to point at the new implementation contract that sounds pretty simple right but well in practice it's not actually as simple as it sounds there's one thing that you got to be mindful of that a lot of people are not aware of and that is the source storage slots so solidity assigns storage slots for each state variable within the contract in the order in the order they appear in the code so in this case for example you know alpha maps the storage slot of zero bravo maps a storage slot of one charlie maps two sorry storage slot of two delta maps to three and echo mess to four and that's because uh this contract buzz which is a contract that i'll be deploying you know inherits from foo and bar so it first takes a look at foo and then it maps the source slots and then bar and followed by source uh the variables within the contract itself and and if i'm using the delegate call pattern the the contract state is actually stored within the proxy contract and not the implementation contract itself so later on when you actually update the implementation contract when you replace it with a new one it could potentially lead to the variables pointing at the wrong wrong slots so for example here i added a new variable called foxtrot and what ends up happening is foxtrot will take the source slot of three and it already has a value much well and it will just use that and delta instead of pointing at three it will now point at four and you know 4 used to be an address of type address now but it's string so i don't know what's going to happen it's probably going to take like the unicode value of this binary data and and echo will not point at 5 which doesn't even exist yet so you know get uh it will lose the value the existing value which was 0x cafe dude and in this example this is a different example where i make this new contract uh derive from another contract and in this case the same thing happens the storage slots are now uh you know uh the variables are now pointing at different storage slots and it gets messed up so in order to prevent myself from accidentally messing up the storage slots the first thing i did was to create a unit test that checks that all of the existing all of the existing variables map to the correct storage slots now if you're building a brand new smart contract from scratch you might want to take a look at new patterns like eip2535 diamond standard that makes management of contract storage much more modular but that wasn't something i could use because i was upgrading an existing contract that didn't use that with the test in place i felt much more comfortable to make sweeping changes and i also made sure that all the new code added had 100 test coverage honestly like way more time was spent writing the tests than the contract code itself and the ratio was probably 20 to 1 or more by the way uscc is 100 open source and you can find the code in the url shown here and the code was then reviewed by circle and merged i want to give a huge shout out to eric from circle who really patiently went over and scrutinized every line that i changed in my gigantic pull requests that that updated thousands of lines it was truly a massive collaborative effort between the two companies and really felt good man and then uh once that was done we had our contracts audited by open zeppelin we used open zeppelin mostly because of an existing relationship we had with them but we actually reached out to consistent diligence and trailer bits as well and they're all fantastic you can you really can't go wrong with any of those firms i must say that it wasn't cheap though uh the audit uh was definitely not cheap uh maybe because we are coinbase and maybe they overcharged a little bit i don't know but it wasn't cheap and sometimes it makes me question why i'm writing code when reading code can be far more profitable obviously i'm kidding anyways then comes the the scary part the deployment we decided to perform the upgrade on the 27th of august usdc had then reached 1.4 billion dollar market cap now it's uh close to 3 billion so we could not afford to screw up we had 100 test coverage we tested the deployment multiple times independently you know by you know within circle and and coinbase uh both on a test net and a local mainnet fork so using ganache you can actually fork the mainnet and uh and try simulating how things would go on the mainnet and we did that as well but you know even then i wasn't feeling 100 confident about the upgrade the amount of damage a botched upgrade could do was unimaginable and you know screwing up would surely be a carry ending move for myself and i couldn't afford that and it's 2020 and you know anything is possible right what did i do as an engineer write my code i ended up writing an upgrader contract that performs the upgrade runs some tests and then reverts if issues are found all within a single transaction this ensures that there is zero downtime and if the upgrade is botched it will simply revert and nobody would even notice because it's an atomic operation as you can see it updates the pointer in the proxy contract initializes the new contract and before it does that it also you know copies some of the values from the existing contract and then it runs some some tests by reading the contract state and and it also performs some erc20 operations like you know approve uh and then it checks the allowance that then does the transfer from he also does a transfer call and if all of these checks pass then the upgraded contract will self-destruct and the upgrade will be finalized and all these again uh is are happening within a single atomic transaction so there's zero down time now was this uh necessary um i don't know i think it was probably an overkill but the peace of mind that it gave was definitely worth the extra code that i had to write this is a snippet from the center slack one day before the upgrade we were like honestly scared because like i said earlier this timeline you know in 2020 proved that any disaster is fair game and this is right before the upgrade on the 27th um we started a war room in zoom and we then called the upgraded contract by calling the upgrade function within the upgraded contract and uh and it was done within a minute and as far as i'm aware no animals or people were harmed and more importantly we managed to upgrade a 1.4 billion dollar financial product with zero downtime there's no way you could do that with traditional money or in traditional financial system and that just shows how powerful this technology really is and that's it uh that's it for the talk and uh thanks everyone and i would like to remind you that we are sponsoring hackathon prizes uh total of 8 000 usc in prizes um it's a lot of money so uh all you have to do all you have to do to qualify is to use uscc and whatever you are building and if you want bonus credit would really like to see the use of some v2 features like meta transaction support and uh and the use of l2 uh but those aren't required but would love to see those uh being used uh for more details you can go to uh https column etheronline.
org prizes and you can find urls to the faucets and testnet contracts etc there as well so i would love for you all to participate you know i'm really looking forward to seeing all the cool exciting things that you build with uscc and ethereum and that's it for the talk and i would uh will not take questions great thanks pete that was a great talk um we do have some questions uh from chat um i'll just jump right into them um so one question from a user um you know this upgrade great what are the next features you're excited about for future versions future implementations what's what's on the more distant roadmap yeah so i took the question and the mill and joel can uh just uh happen anytime um but uh you know one thing that i would really like to see uh is um is uscc on change awards uh unfortunately that was actually one of the proposals that i wrote uh you know uh similar to die savings uh die savings rate you know today if you uh have uscc deposited within coinbase um you can actually start earning rewards um and uh we actually had to postpone that project just because the the federal interest rate went down so much that uh there wasn't enough like you know uh interest that that we could then you know pass on to our users as rewards uh but that's something that i i definitely want to uh work on in the future so uh and and i want to make that accessible regardless of how you're using uscc whether it's uh whether you're holding it within a non-custodial wallet like coinbase wallet or metamask or on a different exchange it shouldn't matter you should be able to you know earn the rewards and that's something that we wanted to work on but couldn't because of the uh the current interest rate situation so that's one thing that i want to work on and i i would love to see just um uscc um uh being used in uh applications like like global venmo type of applications um you know obviously uh vemmo is only available within the us and you know other countries like china they use wechat which is is not available outside of china for i mean for uh for payment use cases and you know there are other solutions like line pay et cetera but what what i want to see like what i really want to see is a global version um and something that anyone can download from anywhere around the world and for that to happen uh scalability is really important so uh integrations with various l2 protocols and in side chains and maybe even other chains that's something that we are actively working on today and so i just would plus one what pete said on layer two scaling i mean that's but there's just been a tremendous amount of innovation going on in the space i think one thing we'd say is feel free to reach out to us and share our our twitter handles but feel free to reach out to any of us if you are there two solution or even if you're adapt and you're looking at a layer two solution um would be really valuable for us as we decide which ones we might prioritize and when uh but i think scaling is probably one of the top of mind things for us so another question so one thing that's you know interesting about uh ustc is of course it's you know created by both coinbase um and circle and there's the kind of consortium behind it um what does that look like from an engineering perspective you know what is it like to collaborate across organizations on you know such a big financial product did you explain bitcoin yeah so yeah pete i i'll explain the context and i would love to have you explain the engineering side of it but um i'd say the context has been the vision has always been something like a visa where there's a lot of different banks that are all involved together they have the brand and they have the security of the broader system uh and the adoption right that they have availability everywhere else and that that's basically been our goal and so the great things is that like for example circle has a ton of different features that they're able to provide we have another set of features uh and the basic community can pick and choose amongst all of that and they can still use the same usdc um then i think on the n side it obviously is much more challenging to have a consortium rather than one company it's just a lot more coordination and i think pete can share more in there right yeah and and i'll just want to add a little bit to that like we do want to expand the consortium and we do want to uh make it not just the coinbases or circles thing but like um uh something that the broader ethereum ecosystem could uh could could use and influence uh so with you know if uh there are you know organizations that are interested in joining consortium you should definitely you know reach out to us uh as for the development and the collaboration of uh the uh between the two companies when it comes to engineering it's actually uh it's it's it's very much like an open source project you know um we have a slack channel we just casually talk you know about different ideas and then we create proposals and we review each other's proposals and you know we make pull requests and the pull requests then get you know reviewed by both parties and we also coordinate how we get those new code audited by external auditors but you know it's um it's just like any other uh open source project or any other uh dev project you know so even though uscc itself is sort of centralized uh the way we do the development for it is it's very similar to how a lot of these decentralized applications and protocols are built and actually just to add on what the millen and pete said and and pete mentioned this right ussc is open source i mean as far as the smart contract goes obviously there's a ton of things that circle and coinbase build that is proprietary but the smart contract source code and a lot of satellite things are open source we would actually love to see more more suggestions formed from the ecosystem right i think we have seen a few pull requests here and there from from folks in the ecosystem but we would welcome them a lot more participation great and then one one last question and then we'll move on to the next talk uh but pete one thing you mentioned uh in your segment of the talk is you know the the difficulty of uh you know doing audits paying for audits uh obviously a challenge for coinbase but a much bigger challenge for smaller organizations who you know nonetheless have to you know audit very thoroughly before launching a product i'm curious if you have thoughts on you know how as an ecosystem we can address that problem um you know what teams that maybe aren't as well funded can do um to get all that's done or to release a secure product i see uh yeah you know similar bitcoin if we could uh create some kind of uh i don't know some kind of a marketplace is that the right word uh where you know uh people can uh submit contracts to be audited by the community and in return maybe they they earn some kind of tokens uh that could be kind that could be cool but in addition to that i think we should just invest much more heavily into all the tooling around ethereum development uh there are lots of great tools already like flitter was very useful for us for example um but i think uh we can definitely do better and it's something that i think we collectively should uh come together to collaborate on and uh and with great tooling i think uh will require less and less uh manual audits okay thanks peace thank you dr val thank you
Automatic transcript — names and jargon may be misspelled.