0x: Shut down of the Exchange v2.0 contract and migration to patched version, Dev update

Paradigm
Paradigm
Published in
18 min readJul 18, 2019

Biweekly update 4th July — 18th July

Greetings to 0x fans and all crypto friends! This is our second biweekly update on 0x protocol and we are pleased to note that these weeks the team was immensely active as usual. They have made a number of improvements across the protocol and its associated tooling that makes 0x easier and better to work with. The 0x team published the monthly development post that digs into all the technical updates from the 0x Core Team: 0x Mesh upgrades, ZRX staking contract designs, contract-fillable liquidity documentation. Also, last week the 0x team announced that they had become aware of a potential exploit on the 0x v2 exchange contract. To protect users’ assets, they shutdown the exchange contract. A review of the exchanges transaction history confirms that no users have fallen victim to this exploit, so props to the 0x team for acting quickly to mitigate the issue. On behalf of the 0x core team, Will Warren sincerely apologies. As for upcoming events, Clay Robbins will be talking about “The Future of Automated Finance” on the main stage at BuildETH 2019 in San Francisco on July 19th. Additionally, Tom Schmidt of 0x will lead a workshop showing you “How to Launch a Decentralized Exchange in Minutes”. Last week the team announced the addition of Theo Gonella to the 0x Core. He will be working with the Protocol Engineering team as a Product Manager. Timur Badretdinov put together an article on Trade Execution Coordinator by 0x covering the motivation (spoiler: it’s the frontrunning), current solutions, and the long-term view. The 0x community is quite active and it constantly grows. And last but not least, 0x relayers Radar Relay, Ethfinex, and Paradex now have the lowest slippage for $1,000 buys on ETH/DAI! Keep on powering decentralization! Stay tuned for 0x biweekly updates in the coming weeks!

Development

Github metrics:

Developer activity (from Coinlib.io):

Shut down of 0x Exchange v2.0 contract and migration to patched version:

Final Update (July 13th): The ox team has patched and re-deployed the entire 0x smart contract pipeline from scratch, updated their developer tools and packages, 0x Instant, and 0x Launch Kit. As previously mentioned, they have confirmed that the vulnerability found in the 0x v2.0 Exchange contract was not exploited and no user funds have been lost. Please expect a formal post-mortem blog post in the next couple of days.

They sincerely thank all of the teams in the ecosystem for their understanding, patience, and cooperation throughout this process. For any teams still requiring assistance in migrating to the newly deployed contracts, please reach out to any member of the 0x Core Team on their Discord server.

Update (July 12th — 11:51 PM PT): Please find the patched contract addresses below. Developer tools and packages was updated to reflect these changes on July 13th.

ERC20Proxy: 0x95e6f48254609a6ee006f7d493c8e5fb97094cef

ERC721Proxy: 0xefc70a1b18c432bdc64b596838b4d138f6bc6cad

MAP: 0xef701d5389ae74503d633396c4d654eabedc9d78

Exchange: 0x080bf510fcbf18b91105470639e9561022937712

APOwner: 0xdffe798c7172dd6deb32baee68af322e8f495ce0

Forwarder: 0x76481caa104b5f6bccb540dae4cefaf1c398ebea

OrderValidator: 0xa09329c6003c9a5402102e226417738ee22cf1f2

Update (July 12th — 09:43 PM PT): After analyzing historical trade logs, the team has confirmed that the vulnerability found in the 0x v2.0 Exchange contract was not exploited and no user funds have been lost.

On July 12th the team was made aware of a potential exploit in the 0x v2.0 Exchange contract by a third-party security researcher samczsun. This vulnerability would allow an attacker to fill certain orders with invalid signatures. This vulnerability does not affect the ZRX token contract; your digital assets are safe.

After verifying the vulnerability internally at 0x and out of an abundance of caution, the team has used the AssetProxyOwner contract to shut down the v2.0 Exchange and all AssetProxy contracts to prevent this vulnerability from being exploited. The contracts were shut down at approximately 7:45 PM PT. To the best of their knowledge, no one has exploited this vulnerability and no user funds have been lost. Unfortunately, this also means the currently deployed 0x contracts cannot process trades and are unable to be used.

A patched version of the Exchange contract — that the team is confident fixes this vulnerability — and new AssetProxy contracts are being deployed to the Ethereum mainnet and they expect them to be ready to use later.

Exploit Description

The team is doing their best to verify that other smart contracts are not vulnerable to this exploit before disclosing it publicly in a formal post-mortem.

Update (July 13th): @samczsun has provided a detailed explanation of the vulnerability here.

Immediate Next Steps

Teams will need to point to the patched and newly deployed Exchange and AssetProxy contracts as well as clear their orderbooks of outstanding orders. Users will need to reset their allowances for the new 0x AssetProxy contracts.

On behalf of the 0x core team, Will Warren sincerely apologies. Since the beginning, they’ve set an extremely high bar for code quality, test hygiene, and all independent security auditors that they work with. They understand the existence of a potentially critical bug deserves serious reflection. They hope to discuss this issue with the broader community in the next few days to ensure all smart contract security practices for 0x protocol are transparent, rigorous, and community-vetted.

The team also wants to extend their sincerest gratitude to samczsun. They continue to offer a generous bug bounty to white hat hackers and community members that identify potential vulnerabilities.

Check out also Will Warren Twitter thread.

Development Update #20:

0x v3.0

The 0x protocol team has been hard at work implementing a number of ZEIPs that are going to be bundled and rolled out as part of their proposed 0x v3.0 release later this year. Listed below is a sampling of new features to come:

  • Staking contracts initial version (ZEIP-31)
  • A new matching strategy that allows a spread to be taken in terms of both assets of a trade (ZEIP-40)
  • A new matching strategy which allows an arbitrary number of orders containing the same asset pairs to be atomically matched together (ZEIP-41)
  • Support for signatures that utilize ERC-1271 (ZEIP-33)
  • The StaticCallProxy, a new asset proxy for validating an order bundle during settlement through an arbitrary, read-only callback (ZEIP-39)

Mesh Updates

In addition to protocol upgrades, the team has been hard at work on 0x Mesh, their p2p network for propagating orders. They’re gearing up for a limited beta release next weeks and if you’re interested in participating, let them know in the #mesh channel on Discord. You can expect to find a number of features and improvements in this release, including:

  • Added a `mesh_getOrders` JSON RPC method for fetching all orders stored within a Mesh node
  • Added an explicit heartbeat subscription so clients can know when their connection to Mesh is silently dropped
  • Added support for orders involving MultiAssetData
  • Added support for various Ethereum testnets: Ropsten, Rinkeby and Kovan
  • Built out an ELK (Elasticsearch, Logstash, Kibana) stack for aggregating logs from Beta testers

Launch Kit Updates

Since the team has introduced the full version of 0x Launch Kit, they’ve seen a lot of usage and some interesting implementations out in the wild. Over 400 people have used the Launch Kit Wizard, or cloned the frontend or backend repo to build their own custom 0x relayer. Teams like VeriSafe and 0xchange have used Launch Kit to start their own decentralized exchanges with just a few hours of work. The team has continued to make improvements and fixes to the implementation, including more configuration and quicker installation. It is now possible to set the asset pairs, tokens and various styling properties using a configuration file. For more information check out the release page.

They’ve also released a few videos that walk through the process of using Launch Kit to create your own token exchange in minutes. Don’t forget to subscribe to 0x Youtube channel for notifications on future videos!

Contract-fillable Liquidity

These weeks, the team announced that dYdX had integrated 0x-based liquidity into their product, enabling greater liquidity and better asset pricing. They achieved this using a technique they are calling “contract-fillable liquidity”, or the ability for a smart contract to consume liquidity and make trades on behalf of a user. If you are developing a dapp or protocol on top of Ethereum, check out the short guide they put together to get started.

In addition to this guide, the team is working on a library to help aid in contract fillable liquidity integrations, here is a sneak peek.

0x Ecosystem Developer Meeting — July 02, 2019

Slides.

AGENDA:

» Meeting format updates 00:58

» New YouTube resources 02:08

» 0x protocol v3.0 updates

- StaticCallProxy: ZEIP-39 03:19

- ERC20BuyerAssetProxy: ZEIP-47 05:15

- Order Matching: ZEIP-40 & ZEIP-41 10:08

- New Signature Types: ZEIP-33 11:56

- Stake-based Liquidity Incentives: ZEIP-31 19:29

- V3.0 Remaining Tasks 23:39

» New Launch Kit v0.0.4 released 25:31

Ecosystem Topics & Questions

» 0x Mesh update 27:27

» Ecosystem Questions 31:40

Ecosystem Spotlight Session

» Oc2 DEX 38:48

» Merchcoins 42:51

All ZEIPs referenced can be found at here. If you have feedback on any of the ZEIPs discussed, please comment directly in the ZEIP issue itself or on our research forum at https://forum.0x.org.

For the upcoming ecosystem developer meeting schedule, please visit https://link.0x.org/DevMtg-Schedule

For in-depth technical discussions on protocol upgrades and development updates, as well as for future developer meeting agendas, join the team at: https://forum.0x.org

For technical updates from the 0x Core Team, join their developer mailing list: https://link.0x.org/Dev-updates

0x‏ @0xProject on Twitter 14h:

0x relayers @RadarRelay, @Ethfinex, and @ParadexIO now have the lowest slippage for $1,000 buys on ETH/DAI!

Thanks @DEX_AG for the comparison data.

Social encounters

Upcoming events:

July 19th: One-day Ethereum developer conference in San Francisco. Clay Robbins will be talking about “The Future of Automated Finance” on the main stage at BuildETH 2019.

July 30th: 0x Ecosystem Developer Meeting

Sync the Public Calendar to keep up to date on future sessions. The team also posts a recording on their YouTube channel.

July 19th: Tom Schmidt of 0x will lead a workshop at BuildETH 2019 in San Francisco showing you “How to Launch a Decentralized Exchange in Minutes”.

Finance

Token holders and the number of transactions dynamics (from Etherscan.io):

There is a slight increase in the number of token holders these weeks.

Information from Coinmarketcap.com:

Roadmap

0x Roadmap 2019

Part 1: ZEIPs

0x v2.0 is designed for iterative upgrades

0x v2.0 is battle-tested, designed for iteration, and there are already a number of ZEIPs queued up. Members of the 0x core team are excited to move quickly. However, they are now working with a live system that has access to a great deal of digital assets. It is critical that they put a more formal structure around the ZEIP process to ensure the community can help drive decision making, communicate needs, and provide oversight.

ZEIPs

0x Improvement Proposals (ZEIPs) were introduced as a concept almost six months before 0x v1.0 was launched on the Ethereum mainnet. To date, ZEIPs have primarily been used by the core team to propose and document potential upgrades to 0x protocol’s system of smart contracts. There has not been any formal process for vetting and prioritizing these proposals; it is time to change that.

In the next few months, the 0x core team will put forth some of the first ZEIPs, work with the community to improve the ZEIP process, and undoubtedly learn a ton along the way.

ZEIP-23: support multiple assets on each side of a trade

Figure 1: use 0x protocol to trade arbitrary bundles of assets. As shown above, one could trade six Gods Unchained cards for five DAI + three Decentraland LAND parcels, all in a single atomic transaction.

ZEIP23 introduces a new component to 0x protocol’s pipeline of Ethereum smart contracts — the MultiAssetProxy (MAP) contract — which makes it possible to atomically trade any arbitrary bundle of ERC20/721 tokens. Numerous teams have expressed the need for this feature, and it can support a variety of use cases:

  • Sell 20-card booster packs for your ERC721 trading card game.
  • Buy a cluster of neighboring LAND parcels in decentraland to establish your virtual territory.
  • Open a short position within a categorical prediction market. For example, use Augur or Veil to bet against a specific political party winning the 2020 US presidential election by going long all of the other political parties.

ZEIP23 has reached the end of the ZEIP process; development is complete and the implementation passed a security audit.

ZEIP-24: support for the ERC1155 token standard

Figure 2: the ERC1155 token standard allows an unlimited number of digital asset ledgers (shown as spreadsheets) to be maintained within a single Ethereum smart contract (grey rectangle), eliminating the need to deploy numerous ERC20 contracts.

ZEIP24 adds support for the ERC1155 token standard, which allows a single smart contract to maintain user balances across a collection of internal ledgers. The design is ideal for use cases that require large-scale creation of tokens such as gaming, loan origination, and prediction market platforms. Instead of deploying a vast number of distinct ERC20 tokens that each maintain a single ledger, an ERC1155 token can collect all of these ledgers into a single smart contract. Projects that have committed to using the ERC1155 token standard include Gnosis, Horizon Games, and Enjin.

ZEIP-X: Trade Execution Coordinator (TEC)

Figure 3: a TEC is a system that receives multiple incoming streams of smart contract-consumable orders, that filters out order collisions, and outputs a single order stream to be fed into the 0x contracts (see: multiplexer).

Today the two most common relayer models are the open orderbook and order matching models. The team releases a ZEIP and specification for a TEC, an extension contract that enforces a strict set of rules around trade execution and that combines some of the best attributes of existing relayer models. The TEC will prevent front-running/trade collisions and allow for free off-chain order cancellations without sacrificing the ability for third-party smart contracts — such as dYdX — to consume 0x liquidity. The are targeting a launch in late Q2 2019 for the first version of the TEC which will likely be somewhat centralized in nature, but will hopefully prove out the concept, leading to more decentralized designs and research interest in the future. You can learn more about the TEC concept here.

0x Protocol v3.0

The team is targeting the next major version bump for 0x protocol to occur in Q3 of 2019. The move to 0x v3.0 will involve replacing the Exchange contract which contains the bulk of the system’s logic for trade settlement. The transition from 0x v1.0 to v2.0 involved migration to a completely new system of smart contracts; it was a disruptive process that halted trading. Traders were required to reset their token allowances and relayers were forced to shut down their v1.0 order books and spin up empty v2.0 order books. The process took months to play out and a number of traders dropped off. In contrast, the transition from v2.0 to v3.0 will require zero disruption to markets; users won’t have to do anything to take advantage of the upgrade and relayers will be able to smoothly transition their order books with zero downtime. Relayers will not even need to clear their order books; both 0x v2.0 and v3.0 orders can exist on the same orderbook. The experience for traders should be seamless.

The bump to v3.0 is an opportunity to integrate multiple ZEIPs. Areas of focus will likely include more flexible order matching, extending 0x protocol’s ability to leverage meta transactions, and generalized callbacks that unlock a richer experience for smart contract devs. Finally, the update will provide 0x with an opportunity to revisit ZRX token mechanics and how they may be used to incentivize liquidity. The role of the ZRX token as a means of paying relayer fees has been a frequent focus of conversation both externally and on the core team. One of the most compelling properties of tokens is that they have potential to serve as rocket fuel for network effects.

Part 2: Scalability R&D

Layer one and layer two

In short, layer two is where the transactions will happen most of the time, and layer one is always there to guarantee that everything is done correctly. Layer one doesn’t get involved unless it has to. In many ways it acts as a court to resolve conflicts in layer two.

Layer two trade offs

There are many trade-offs in layer two solutions having to do with where data is stored and how the blockchain is informed of the goings-ons of layer two. There are two guiding principles:

Principle 1: Cryptographic guarantees. It should be impossible to break the guarantees of the system, not merely expensive.

Principle 2: Exponential scaling. Any layer two scaling solution should allow for exponentially more transactions than layer one.

Scaling Decentralized Exchanges

Right now scaling may not seem a big concern in DEXs. While DEXs constitute a significant fraction of all Ethereum transactions, there is still plenty of room for it to grow. The team’s expectation is that usage can go up by about 5x before it becomes problematic.

Remember that it is still very early days for DEXs. They are looking at a 100x increase before centralized crypto exchanges are replaced. With tokenized securities it will be another two orders of magnitude to support the loads of traditional security exchanges. Add another two for mainstream consumer adoption.

Long term, they expect the majority of the trading volume to come from tokenized assets that currently don’t have a marketplace, like prediction markets or game items.

Zero Knowledge Proofs

A zero knowledge proof allows someone to do a computation on some data and prove that they did this computation correctly, without revealing the data.

ZKPs for scaling

Research done between 0x and Starkware shows that STARKs proofs can be verified on Ethereum today without requiring any changes to the protocol. The team is currently working on a proof-of-concept implementation to demonstrate the performance on testnet.

Evolving the 0x stack

ZKPs are a powerful new tool that are well-suited for the DEX use case, but how do they fit into the 0x roadmap? Isn’t this a completely different technology?

Right now 0x has the Standard Relayer API to connect liquidity together between different relayers, market makers, and 0x Instant. This works, but is kind of an old-world way of doing things. Each endpoint must be correctly implemented and each connection must be setup manually. The team is working on a peer-to-peer network transport layer that automates all of these connections, greatly increasing order flow throughout the ecosystem. As an added bonus, they are making the whole thing work in the browser so you can participate in the decentralized liquidity network without having to install a node!

With networked liquidity improved, the next step is to coordinate trades. Trade execution coordinators (TECs) are little services relayers can opt into. These coordinators provide a variety of benefits including protection against front-running, innovative marketplace mechanics, and soft cancels. They can do this while still allowing unrestrained liquidity sharing.

When trades are ready to be settled, they get collected in large batches and processed. The final result of all this is a small proof that shows all of it was done correctly. This proof is submitted to the on-chain contract for verification.

Looking even further ahead

Instead of straying away from the current design, the team hopes to replicate the 0x pipeline on different shards and stateful blockchains, and use cross-chain governance to push out synchronized updates. Each replica of the 0x pipeline, or “embassy,” will support local shard-specific trading activity and, due to the system’s extensibility, it should be able to support most use cases.

The highly scalable ZKP-based sidechain will plug into each of these embassies, allowing users to seamlessly transition from synchronously trading their assets locally with other people on the same shard to synchronously trading on a global network that connects markets together.

Part 3: Networked Liquidity & 0x Mesh, a peer-to-peer communication network for the 0x ecosystem

In March the team introduced 0x Mesh, a peer-to-peer network for sharing orders which will serve as an alternative to the Standard Relayer API. 0x Mesh will massively reduce the effort required to tap into the 0x networked liquidity pool and the technical work associated with maintaining a compliant endpoint. One of the most compelling aspects of 0x protocol is its ability to facilitate networked liquidity: the seamless flow of orders through a network of interconnected marketplaces and dApps. The Radar team has described networked liquidity as a paradigm shift that transforms the term “exchange” from a noun to a verb. The 0x team agrees with this assessment.

While market participants tend to meet in specific locations to facilitate more efficient markets, networked liquidity allows orders to flow outward through a growing number of web3 capillaries, reaching a broader cross-section of users. These interconnections act as a source of network effects that lead to a greater number of opportunities for market makers and better prices for end-users.

Over the past months, the 0x Core Team has shipped key components needed to facilitate networked liquidity. 0x Instant allows orders to flow to a variety of surfaces including popular Ethereum wallets (MyCrypto), dApps (Augur), and blockchain explorers (Coingecko, EtherScan). 0x Launch Kit provides a simple way for developers to launch a custom digital asset marketplace in a matter of minutes. The one underlying component that all of these products have heavily relied upon is the Standard Relayer API (SRA), which provides guidelines for sharing orders between endpoints. Moving forward, 0x Mesh can connect these products and tools in a more seamless way.

The team is planning to launch a beta version of 0x Mesh with a handful of early participants near the end of Q2 2019. The 0x Mesh beta will be written in Go and will be compiled to WebAssembly when run in the browser. It will use WebRTC as a first-class protocol for inter-node communication (both browser and non-browser based nodes) and will rely on signaling servers to bootstrap connections between peers. The team has developed a novel order eviction algorithm that precludes the need for explicit staking while preventing malicious nodes from filling up the available space on other nodes and evicting the orders of benign users.

Part 4 : Proposal for Stake-based Liquidity Incentives

Key points

  • The team has published a draft for ZEIP-31, which proposes an upgrade to the 0x protocol to utilize new ZRX token economics.
  • Under the proposal, takers pay a small protocol fee on each 0x trade.
  • Market makers (MMs) receive a liquidity reward that is proportional to:
    — the protocol fees generated from their orders.
    — their stake of ZRX tokens.
  • MMs who do not own sufficient ZRX to collect liquidity rewards will be able to form a ZRX staking pool for third-party delegators.
  • Next steps: Community discussion. Implementation details finalized. Gauge sentiment. Smart contracts developed/audited. Tokenholders approve/reject integration into live 0x pipeline via token vote.
  • Timeline: The team aims to include ZEIP-31 in 0x protocol v3.0 in Q3 2019.

Partnerships and team members

0x‏ @0xProject on Twitter on Jul 8:

We are very excited to announce the addition of Theo Gonella to the 0x Core Team. He will be working with our Protocol Engineering team as a Product Manager.

Please join us in giving @motionlessness a warm welcome!

The 0x Core Team is Hiring!

Work at 0x | Open Positions

Rumors

Twitter:

Read this thread >>>

You can’t keep a good DEX down

There’s been some really good progress on @0xProject liquidity in 2019. @RadarRelay bid-ask spread is now below 0.5% for $10k buy/sell trade of $DAI: https://twitter.com/tomhschmidt/status/1150892576846704640 …

Reddit discussions:

Process and roadmap for ZEIP-31.

Government shutdown on 0x (a scenario).

Survey on the use of Decentralized Exchanges.

zrx.imm has been registered to 0x’s ZRX token.

Other:

Trade Execution Coordinator (TEC) Primer: The “how & why” explanation of Trade Execution Coordinator (TEC) by 0x. This primer is structured to be a top-down guide of the TEC, starting with a high-level overview and then going into details.

Social media metrics

Social media activity:

Social media dynamics:

0x community continues to grow. There is a slight increase in the number of subscribers of 0x social media channels these weeks.

Discord chat with about 2,500 members.

And 0x Research forum. Top discussions:

Research on Protocol Fees and Liquidity Incentives

0x Developer Update: V2 Tools Published! (July 26th, 2018)

Research on Selective Delay TEC Process

0x Mesh Architecture Doc

0x V3 Feature Set

Research Note on the Impact of ZEIP-31 on User Behavior

0x V2 Timeline Update

TEC-compatible forwarder contract

Relayer DAO — proposal

0X smart contracts deployed on other Blockchains

There is a slight growth in 0x community over time. The graph above shows the dynamics of changes in the number of 0x Reddit subscribers, Twitter followers and Facebook likes. The information is taken from Coingecko.com.

This is not financial advice.

Subscribe to detailed companies’ updates by Paradigm!

Medium. Twitter. Telegram. Reddit.

--

--