Immutable vs Upgradeable Smart Contracts: A Debate

David Wyly
10 min readFeb 25, 2023

--

Blockchain technology has revolutionized the way we think about security and trust in transactions. Smart contracts, the self-executing contracts with the terms of the agreement directly written into the code, have been a crucial part of this revolution. By using the principles of decentralization and immutability, smart contracts can ensure that transactions are transparent and secure without the need for a middleman.

But traditional smart contracts are not without their limitations. One major (perceived) drawback is their lack of flexibility and upgradability, which can be a major headache when changes to the contract code are needed.

This is where upgradeable smart contracts come in, providing a “solution” that allows for modifications after deployment. But with this increased flexibility comes a set of significant risks, including the potential erosion of trust and stability.

As a blockchain enthusiast, I believe that it’s essential to find the right balance between flexibility and trust in smart contracts. While upgradeable smart contracts have their benefits, in the end, I caution against their implementation, and prefer the security and transparency provided by traditional smart contracts.

By exploring the advantages and disadvantages of each approach, we can gain a better understanding of how we can provide additional flexibility without necessarily embracing upgradeable smart contracts. Join me as we delve into this important debate.

Immutable Smart Contracts

In the world of blockchain technology, the concept of immutability is essential to maintaining transparency and security in transactions. Immutable smart contracts are an example of this as once the terms of the agreement are executed, neither party can change them.

Let’s use the example of buying a concert ticket online to better understand how this works: A smart contract can include the terms and conditions of the ticket sale, such as the price, date, and location of the concert, as well as any restrictions or limitations on the ticket. Once you agree to the terms, the contract is executed, and the ticket seller receives payment for the ticket. When you present the ticket on the day of the concert, the smart contract automatically confirms its validity and grants you access to the event.

The beauty of this process is that the transaction is entirely transparent and secure, and the contract is immutable — meaning that neither party can change the terms of the agreement after it has been executed. While immutability ensures that the contract is transparent and secure, it also creates a lack of flexibility and upgradability. This can be a problem when changes to the contract code are necessary because deploying a new contract can be time-consuming and costly.

Despite their lack of flexibility, traditional smart contracts remain a reliable solution for secure and transparent blockchain-based transactions because their immutable nature ensures that the contract is secure and trustworthy, and the terms of the agreement cannot be changed after execution. The code is typically audited to ensure that it is free from vulnerabilities or bugs, making the transaction more trustworthy.

Upgradeable Smart Contracts

As blockchain technology evolves and matures, traditional smart contracts have been criticized by some for their lack of flexibility and upgradability. In response, a new type of contract has emerged: the upgradeable smart contract.

An upgradeable smart contract system can be created by separating the contract code into two parts: the implementation contract and the proxy contract. The implementation contract contains the actual contract code. The proxy contract serves as a “gateway” to the implementation contract and contains a reference to the implementation contract’s address. When a user interacts with the proxy contract, the proxy contract delegates the request to the implementation contract, effectively “upgrading” the contract’s functionality without having to redeploy the entire contract.

On the surface, the concept of an upgradeable smart contract may seem like an appealing solution to the lack of flexibility and upgradability in traditional smart contracts. However, the reality is that upgradeable smart contracts introduce a set of significant risks that need to be carefully considered. In the next section, we’ll explore some of these risks in detail.

Immutability is a Feature, Not a Bug

Remember, inflexibility and immutability is a critical feature of blockchain technology that ensures the security and trustworthiness of smart contracts. The inability to change the code of a deployed contract after execution is not a bug, but rather a feature that provides numerous benefits to the system and its users. In fact, immutability is essential for several reasons:

  • Security: The most significant advantage of immutable contracts is their security. Once a contract has been deployed, its code is set in stone, and there is no way to alter it. This guarantees that the contract’s behavior is predictable, and there is less room for malicious actors to exploit vulnerabilities or introduce backdoors to the contract.
  • Transparency: Immutability also ensures that the contract’s behavior is transparent to all parties involved. Because the contract code cannot be altered, all parties can inspect the code to understand precisely what the contract does and how it does it. This level of transparency provides a significant level of trust in the system, which is crucial for any blockchain-based transaction.
  • Auditability: Audits play a crucial role in ensuring that smart contracts are secure and trustworthy. Because traditional contracts are immutable, auditors can review the code and ensure that it is free of vulnerabilities or other issues before deployment. With an audit from a reputable company, there is a higher likelihood that the contract is secure and trustworthy.
  • Stability: Immutability provides a level of stability to the system that is critical for long-term usage. Because the code of a contract cannot be altered, users can be confident that the contract’s behavior will remain the same over time. This means that users can build on top of the contract and create more complex systems without worrying about the underlying contract’s behavior changing.

So despite the numerous benefits of immutable smart contracts, there is a temptation to create upgradeable smart contracts to eliminate inflexibility. However, the reality is that upgradeable smart contracts introduce a host of new issues that can compromise the security and trustworthiness of the contract. In the next section, we will explore the risks associated with upgradeable smart contracts and why immutability is still the gold standard for secure and trustworthy blockchain-based transactions.

Why Upgradeable Smart Contracts Pose Risks

Immutable smart contracts are a cornerstone of blockchain technology, providing the transparency, security, and trustworthiness that make blockchain-based transactions possible. In contrast, upgradeable smart contracts, while tempting, introduce a range of issues that compromise these essential features of blockchain technology.

Here are some of the problems that arise with upgradeable smart contracts:

  • Centralization of power: Upgradeable smart contracts require a central authority to update the contract’s code. This centralization of power is in direct opposition to the principles of decentralization that underpin blockchain technology. The central authority can alter the contract’s behavior without the knowledge or consent of other parties, which undermines the trust in the system.
  • Complexity: Upgradeable smart contracts are significantly more complex than traditional contracts. They require additional layers of code to manage the contract’s upgrades, which can introduce additional vulnerabilities or bugs that can be exploited by malicious actors.
  • Security risks: Upgradeable smart contracts introduce additional security risks to the system. Because the code can be altered after deployment, it is more difficult to audit and ensure that it is free from vulnerabilities or other issues. This means that users cannot trust the contract’s behavior, which undermines the entire point of blockchain-based transactions.
  • Interoperability difficulties: Decentralized applications (dApps) rely on smart contracts to operate. If an upgradeable smart contract is updated, it can break compatibility with front-end systems that rely on the previous version of the contract, potentially leading to the failure of the entire system. This creates an additional risk and can be especially problematic in cases where the dApp is used to manage sensitive data or assets.
  • Lack of transparency: Upgradeable smart contracts introduce an element of opacity into the system. Because the contract’s behavior can be altered after deployment, users cannot be sure how the contract will behave in the future. This lack of transparency makes it difficult to assess the risks of participating in a blockchain-based transaction.
  • Legal issues: In blockchain-based transactions, the phrase ‘code is law’ is often used to describe the idea that smart contract code is the final authority in executing agreements. This concept underscores the importance of ensuring that smart contract code is reliable and secure, and any alteration to the code may undermine the trust in the system. Moreover, in some jurisdictions, smart contracts are recognized as legal contracts, and any changes to the terms and conditions of a contract after execution may raise legal and regulatory challenges.

That’s a long list of concerns for upgradeable contracts. So to summarize, while immutable contracts are not technically as flexible as upgradeable contracts, they offer a strong, dependable foundation for blockchain-based transactions. By making sure that the contract’s terms and conditions cannot be tampered with after execution, immutable smart contracts provide transparency, security, and trust. These elements are absolutely fundamental for the widespread adoption and success of blockchain technology.

Balancing Flexibility and Trust

Of course, there are trade-offs to consider. The lack of flexibility in immutable smart contracts can be a significant hindrance, limiting their suitability for use cases that require frequent updates or changes.

Admittedly, there are some valid arguments in favor of upgradeable smart contracts. For example, they can enable quicker development and deployment of new features, as well as faster bug fixes and security patches. This can be a huge advantage in industries where speed-to-market is essential.

But let’s not overlook the potential risks. Even with upgradeable smart contracts, there are limits to the kinds of changes that can be made without compromising the contract’s security and trustworthiness. Upgrading the contract too frequently can erode trust in the system and lead to a perception of instability, similar to constantly changing the menu at a restaurant.

Perhaps we need to find a middle ground between flexibility and trust in smart contracts. We could design contracts that are flexible enough to accommodate anticipated changes without sacrificing immutability. But how?

Modular Smart Contracts

One solution to balance flexibility and trust in smart contracts is to incorporate a modular design approach. Just like how LEGO bricks can be combined in various ways to create different structures, smart contract modules can be designed to work together like building blocks. This approach allows for flexibility and modularity, without requiring frequent changes to the contract’s core logic or data structures.

By using modular smart contracts, developers can create independent smart contracts that are designed to perform specific functions such as payment processing, identity verification, or data storage. Each module can be tested, audited, and verified for security and reliability before being integrated into the larger system. This allows for greater flexibility and modularity while maintaining the core logic and data structures of the base contract.

For example, let’s consider a decentralized ride-sharing app. To build such an app, developers can use a payment processing module to handle transactions between drivers and riders, a reputation module to keep track of driver ratings and reviews, and a geolocation module to track the location of drivers and riders. Each module can be tested and verified independently before being used by the larger system. And if one of those modules needs to be upgraded, you can do so without having to redeploy the base contract.

To implement a modular approach, developers need to carefully plan and design the system, identifying the core functionalities and selecting the necessary modules that can work together seamlessly. Each module should be designed with interoperability in mind to ensure that it can communicate and work with other modules.

Exploring the Modular Paradigm

A modular smart contract design approach offers numerous benefits over traditional monolithic contracts. Here are some key advantages:

  • Easier auditing and debugging: Breaking the contract down into smaller, independent modules makes it easier to identify and isolate any issues that arise. This simplifies the auditing and debugging process, which can lead to faster turnaround times for bug fixes and security patches.
  • More efficient use of resources: With modular contracts, developers can focus on specific areas and avoid duplicating work. This creates a more efficient use of resources, much like having a team of specialists instead of a one-size-fits-all solution.
  • Increased security: Testing and verifying each module independently helps to ensure that they are secure and reliable before integration into the larger system. This can reduce the risk of vulnerabilities and exploits that could compromise the security of the entire contract.
  • Better scalability: A modular approach can be more scalable than a monolithic contract since some modules can be swapped out as needed. This is especially important in industries that are rapidly evolving, where new functionalities may need to be added or existing ones updated frequently.

However, there are some drawbacks to consider as well:

  • Increased complexity: A modular approach can add complexity to the system, particularly in terms of managing the interactions between modules. This can make it more difficult to develop, test, and maintain the contract over time.
  • Higher coordination costs: A modular contract consists of multiple independent modules, which can require additional communication and coordination efforts among the development team and stakeholders.
  • Risk of centralization: A modular approach requires the base contract’s parameters to be updatable, which introduces a degree of centralization. This can create concerns around trust and security, particularly if a single party controls the updating process.
  • Potentially limited reusability: While modules can be designed to be interoperable, there may be limitations on their reusability. Modules that are tightly coupled to a specific contract or industry may not be easily transferable to other use cases, which could limit their overall usefulness.

Closing Thoughts

When it comes to smart contracts, there’s a spectrum of immutability that ranges from perfect immutability in traditional contracts to no immutability in upgradeable contracts. Modular smart contracts fall somewhere in the middle and offer a good compromise between flexibility and immutability.

Personally, I’m a big proponent of immutability over upgradeability. While upgradeable contracts can provide more flexibility and faster development, they come with serious risks that should not be discounted. For me, immutability is essential to higher levels of security, trust, interoperability, and decentralization that are at the core of the crypto philosophy.

What’s your take on this? Do you agree, or do you have a different opinion? I’d love to hear your thoughts and experiences in the comments. And if you found this discussion helpful, please share it with others to raise awareness about some of the issues inherent in upgradeable smart contracts. Let’s keep the conversation going!

David Wyly is the CEO of Decentra, Inc (which includes brands such as the All For One crypto mobile app), Director of Engineering for Dappd, LLC, a Blockchain Consultant and Principal Software Engineer, and serves on the Blockchain and Digital Innovation Task Force for the State of Utah.

--

--

No responses yet