Hello Secret Community,
Last week we saw some network performance issues as a result of increased activity. In this post, we’ll outline:
1. Why these issues arose
2. What has been done
3. Why does this matter
4. What can we do to fix this
Why Did This Happen?
The reason for the impact on network performance is multi-layered. First, the network itself has some scalability issues that must be addressed long term - this has been known for some time, and the fixes required involve improving cosmwasm performance in the TEE. It’s a significant amount of work to do this, so while it’s in the roadmap, it has to compete with more pressing issues. As a result, the major changes required will not be feasible within the next six months, at least.
The second reason is that some legacy contracts are inherently inefficient in their use of gas. As an example, Shade multi-hop transactions of more than three hops tend to be computationally intense enough to impact block time and cause validators to miss blocks due to no fault of the validator. With respect to the relevant Shade contracts, the team told us the biggest issue is with the older StableSwap contract.
What’s Been Done?
Secret Labs worked with Shade to refactor the currently deployed contracts to make them more efficient. This sounds like a big step forward, until you take into account that making significant changes to a live production product is a challenging task. Sure, ETH 2.0 did it, and did it well, but it took them years longer than the original plan, because everything had to be carefully evaluated. You could summarize the situation by saying that both Secret Network and Shade Protocol have some tech debt, and neither is in a position to allocate resources to cleaning up tech debt at this exact moment, in the face of higher priorities with more upside.
Why Do We Care?
The challenge we face as an ecosystem is that if nothing is done, it is almost certain that increased usage of these legacy contracts without properly setting max gas limit will result in saturation of the network’s capacity, and ultimately could cause the network to perform poorly. This can lead to several undesirable outcomes:
- Causing deposit / withdraw issues for SCRT on major exchanges
- blocking SCRT holders from using the network
- loss of confidence in Secret Network by token buyers
- loss of ecosystem projects due to network unreliability
No one in the Secret ecosystem would choose these outcomes.
What Can We Do Today?
A research project was undertaken by Alex Saturn while at SNF to determine the optimal level of max gas that would permit the network to run smoothly while not impacting legacy contracts too heavily - proposing the best compromise. The number provided was around 5M per block.
We’ve also discussed at length with the Shade team how some of their older contracts work, and how many hops are required for certain types of transactions and users.
The tl;dr is that there is no ideal solution, but the highest priority is to keep the network running for longevity and sustainability.
It should be made clear that the proposed max gas of 4-5M is a theoretical number - it’s not possible to ascertain exactly what the impact will be without empirical evidence and traditionally, this parameter is changed on chain as needed.
Longer term, we will all need to undertake some work to improve performance. We don’t have a timeline for this today, but Secret Labs is committed to doing this over time.
Discuss!
This is an open thread for discussion by validators, users, and developers on their observations, possible next steps, open questions, and other comments. Please be respectful and constructive - our goal is to get Secret Network working at maximum capacity and allow for growth for all ecosystem builders and contributors.
Special note to all dapps building on secret: please let us know what gas usage you expect for your application deployment or usage during this discussion phase.