Posted on :: ::

Glass Chess: Why Are Smart Contracts an Infinite Game?

The other day I was talking with a friend (also a dev, by the way), and he told me that, because of the number of pieces and squares on a chessboard, the possible combinations for a single game tend to infinity. Of course, I didn't believe him at the time, and we argued about it for quite a while. Later I looked it up, and he was right: that number of possible combinations, known as the Shannon Number, is $10^{120}$.

That is much bigger than the number of atoms in the whole observable universe.

That same afternoon, while I was building a smart contract on Stellar, I started thinking: How many possible attack combinations exist against a contract? For obvious reasons, this changes between languages and with the architecture of the contract itself. But to understand it better, we are going to use this analogy and try to find where the real source of possibilities is: the attackers' paradise.

The truth is that the code is only the board; the real battle is in the logic of the moves. Top-level audits use the following process to try to verify that the code works:

"Turning a Contract into Math" (Formal Verification)

Imagine you have the function close_position(). Instead of testing it with random values, you turn it into a Logical Equation.

  • Define Invariants: These are truths that must never change. Example: "The sum of all user balances must always be less than or equal to the total money in the contract".

  • Convert to Symbolic Logic: The code is translated into formulas. If the code says $x = a + b$, the tool builds a proof that there is no value of $a$ and $b$ that makes $x$ behave in an unexpected way (like an overflow).

  • The "Solver": We use tools like Z3 or Certora. It's like a computer that tries to "beat" your equation by looking for a single case where the logic fails. If it can't find one, the contract is "Mathematically Verified".

This is great and, of course, it's something that MUST be done to secure a contract. However, the problem is that this process is excellent at checking the "determinism" of the code, but it can't always predict the complexity of the logic and the state behind it.

In chess, the Shannon number estimates $10^{120}$ positions. In blockchains like Ethereum, the number is orders of magnitude higher and, technically, it tends to infinity.

To explain the logic and state part better:

In Chess: You have 32 pieces and 64 squares.

In a Smart Contract (SC):

  • State Variables: Every time a user interacts, the "board" changes (balances, prices, timestamps).
  • Function Combinations: You can call depositar, then abrir_posicion, then flash_loan, then retirar. Here, the order of the factors does change the result.
  • External Interactions: Your contract doesn't play alone. It is playing 100 simultaneous chess games against other contracts (Lego pieces), and whatever happens in the game next to it (a price change on Uniswap) affects your pieces directly.

So, to answer the original question: There is no number. If a contract has 20 functions and can interact with 10 other protocols, the possible state combinations are far beyond the atoms in the known universe.

Can "perfectly" audited contracts be hacked?

Yes. Absolutely yes. Audit reports usually include a disclaimer that says:

"This does not guarantee that the contract is 100% secure".

The "Bug" that isn't in the code

The best firms check that the code is secure. But sometimes the hacker doesn't attack the code; they attack the economic assumption.

Real case: Euler Finance ($200M)

They had been audited by top firms. The bug was a function that let users "donate" their funds to the protocol, which accidentally made it possible to create an insolvent debt position. The code was legal, but the financial logic was suicide.

What about Stellar Smart Contracts (Soroban)?

Stellar/Soroban uses Rust, which is like playing chess with a referee who won't let you make illegal moves (memory errors or wrong data types).

  • Combinations in Soroban: Even though Rust limits the "silly" errors, the business logic still has infinite combinations.

  • Stellar's Advantage: Soroban is designed to be more predictable. Ethereum is like a board where pieces can turn into other pieces in the middle of the game. Stellar is more rigid, which reduces the "crazy moves", but the risk of a bad financial move is still there.

And this possibility of a "bad financial move" weighs a lot. In traditional programming, a bug can mean an app crashes; in Web3, on the other hand, a bug is a "Checkmate" where the prize is your users' funds. This inevitably takes us to the last question:

Is decentralization really secure, or is Web3 a lie?

Leaving the whales aside (a topic for another time), the short and direct answer is: decentralization is not a lie, but it isn't the magical world that overhyped marketing sometimes sells either. It's a different paradigm with a completely different risk profile.

To understand this, I'll bring the two concepts we've been talking about down to earth: infrastructure security and business logic security.

1. Infrastructure Security (Where decentralization shines)

This is where decentralization keeps its promise. By removing the centralized middleman (the bank), we gain censorship resistance, immutability and transparency. At this level, the "board" (the blockchain) is incredibly robust and objectively more secure than traditional "black box" systems.

2. Business Logic Security (The real point of failure)

This is where the disappointment lives. Web3 moved the risk from trusting an institution to trusting code.

  • From "Trust Me" to "Trust the Code": The problem is that code is extremely hard to verify 100%.

  • Immutability is a double-edged sword: The same feature that makes the blockchain secure is what makes bugs catastrophic. In traditional software you ship a patch; in Web3, if there's a bug, the funds are already gone and there is no "undo".


Conclusion

Web3 is not a lie, but it is an immature technology paradigm that has been oversold. It's as if, in the early days of aviation, someone sold tickets to the Moon promising it was as safe as a train. Flight technology was real, but the safety promise was a fantasy for that moment.

In practice, the promise of a "trustless" network is, for now, out of reach: we end up trusting auditors, oracle developers and security teams. We haven't removed trust; we have only redistributed it.

Even so, Web3 is a revolution, with very high risk and an extremely steep learning curve. The "lie" is not in the technology but in the narrative that presents it as a simple solution, when in reality it demands a level of technical rigor that we are only beginning to understand.