Sundae Status

This is a copy / paste of a discord conversation between Cobie and SundaeSwap on the Discord server for the benefit of the Reddit community. I shall provide my own summary at the end in the next day or two once I’m back from travelling.

Cobie:

hii, so i read the post but was confused about a couple of things:

1) the max TPS is unclear, do you have an estimate? Saw somewhere 0.15tx/sec, how far off is it?
2) confused about how many scoopers can operate in parallel, if any? dont even know what a scooper is but i think i understand it sort of isomorphically.
3) when the fix for their staking reward calculation problem is deployed in jan/feb, is there estimates on the TPS changes? is it actually of much impact? only know of it through the cosmos change from 2018
4) does ada basically just need hydra for stuff like AMMs to be reasonably competitive, or is the dialled down “parameters” stuff have sufficient room in it? whats the trade-off for juicing those parameters — eg why would IOG not do it now?

Pi from Sundae:

1)

0.15tx/s is our expected TPS with current parameters and current network load. It’s based on a load test we conducted back in December. Real world throughput may vary, but it’s in the right ballpark. This is the throughput for our DEX, not for Cardano as a whole. For comparison, this works out to 12960 transactions per day, and Uniswap v3 does 28,000 per day on average, last I checked. Uniswap is a billion dollar business, so the fact that we can approach that seems pretty good to us 🙂 Obviously not where we want to be long term. What we’re most worried about is the initial load, since we’ve built up an incredible amount of excitement for our project. On the testnet, we saw 130,000 orders in the first week; but once that excitement burns off, we’re fairly confident about the steady state.

To understand where those numbers come from, let me explain some background.

  • Cardano is structured so that state is inherently sharded (across transaction outputs), rather than global.
  • In the long term, this has the potential to be far more scalable (rather than retro-fitting sharding after the fact, like a number of L2’s are trying to do.)
  • As a consequence, however, any concurrent access to shared state leads to contention.
  • This is true of Ethereum too, fwiw, and Ethereum solves it by introducing nondeterminism.
  • That is, When you sign a transaction, you’re agreeing to whatever the outcome of the transaction is by the time it executes.
  • That means if the state changes, ethereum doesn’t need to come back and ask you to re-sign the transaction, but it also means that smart contracts have more power to operate on your behalf, and don’t always make the decision you would have made.
  • Cardano transactions are more determinstic: you sign your signature to the exact state change (inputs and outputs).
  • The hypothesis is that this, overall, leads to more security (since you get to see the outcome of every transaction you sign)
  • But it does mean that if you design a protocol with shared global state, the user experience can suffer: you have a “sign and submit” race, where everyone tries to interact with the liquidity pool.
  • To solve this, each protocol will need to solve this in some way, and either structure their protocol without shared state, or manage access to the shared state
  • Since we’re building a liquidity pool, and capital efficiency comes from the aggregation of funds, global state is fairly unavoidable in our case
  • Our solution, since we love a theme, is to introduce the concept of “scoops”
  • You list your order on chain as one transaction: “I will trade 100 ADA for at least 150 LQ tokens”
  • A “scooper” (think: AAVE Liquidator) collects these and builds the transaction that executes a number of orders in a single transaction
  • They have no access to the funds, and the transaction they can construct is entirely determinsitic; but, since they’re an automated process, they can deal with re-signing the transaction and resubmitting if the state changes before the transaction is adopted.
  • This also has the benefit that orders on our platform are cancelable, and act as limit orders.

So, given current network settings (which have been set very conservatively, for a global network run on commodity hardware), the numbers in your tweets are more or less what we expect. At peak, on mainnet, we can fit 4 “scoops” per block, 3 user orders per scoop, and roughly 20 seconds per block, we might see speeds up to 0.6 user orders per second. Compared to uniswap’s 0.32 per day, that seems decent. (Again, not saying we’re better than uniswap, yet, since I’m sure their max throughput is much higher, but it shows that we can withstand reasonable demand for a fairly big layer 1 DEX)

2) Any number of scoopers can operate in parallel. That being said, because the bottleneck is the conservatively set parameters, it doesn’t increase throughput, but instead resiliency.

3) With the settings currently on the testnet (a 12.5% increase over mainnet), we regularly saw 0.5 tx/s, with a peak throughput of 1.6 tx/s. IOG is expecting to be able to raise it significantly above that, but as always, they are taking a “measure twice, cut once” approach.

There are six limits we’re contending with: Block size (72kb), Block CPU limit (10e9 “steps”), Block Memory limit (11.25e6 “allocation units”), and the same limits for memory.

Right now, per-transaction we’re bottlenecked by memory. And becasue of a large initial memory cost per transaction, each additional order actually takes very few limits. For example, the 12.5% difference from mainnet to testnet takes us from 3 to 8 operations per scoop, and with some other modest increases we can easily get up to ~15-18 operations per scoop.

Similarly, we’re bottlenecked on block size: currently, every script needs to be included in every transaction that runs that script. This means that our scoops are regularly 13kb, meaning we can fit so few in a block. In reality, if we were able to register the script on-chain once, and re-use that every time (much like how Ethereum smart contracts work), we could fit many more scoops per block. This has a huge effect, because those scoops can be distributed to the same pool, or spread across multiple pools, so it makes progress on pools quicker, and the throughput is much higher. Luckily, this is exactly what IOG plans to implement (in addition to many other improvements), in the first quarter of this year.

4) I don’t think ADA needs hydra for AMMs; It honestly feels to me like the parameters + the optimizations they have coming are multiple orders of magnitude improvement. I wouldn’t be building a business on this blockchain if I didn’t. The reason IOG has to be so careful is two fold:

  • Being proof of stake, not proof of work, the security of the protocol is more dependent on how quickly blocks can propagate across the network. If that propagation time were to increase dramatically, for long periods of time (days to weeks), people could start to bias the verifiable random function that elects people to create blocks. Given the total market capitalization of ADA, and their ambitions for a global, low-power blockchain, they’re understandably cautious
  • Once they raise them, they can’t lower them. Imagine they raise the memory units to 15m, and I lock up some funds in a script that uses 14m units. If they lower those back down to 10m because of some unforseen effect, then my funds are locked forever.

IMO they’re probably being a tad too slow / cautious, but I’m not the one who has to make decisions for 40.1 billion dollars, so I don’t envy them 😅 In actuality, they probably just underestimated how quickly projects would start to deliver, or how much community excitement there would be; Remember that it took a few years for DeFi to really kick off on Ethereum, and Solana launched smart contracts in April of 2020, but didn’t have big DEX’s until late summer 2021. We’re around 4 months out from Cardano smart contract launch heh

Finally, all that being said, I think any defi ecosystem that wants to compete with CeFi and offer tens of thousands of transactions per second is going to need to compartmentalize state; global consensus is a fundamentally expensive thing. and IMO, Cardano’s design is a better foundation for doing that than some other chains.

Published by ReddSpark

Follow me on Twitter: https://twitter.com/Redd_Spark or YouTube https://www.youtube.com/@ReddSpark

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: