Ergo’s Hybrid Method for Counting Costs

Ergo Platform

February 9, 2022

Introduction

Checking the validity of smart contracts on a Proof of Work (PoW) blockchain has costs, both in time and resources. If these costs are not controlled, it can lead to a slow network or even denial of service attacks that prevent the network from being used at all. Therefore, cost control is fundamental to a working blockchain.  

Typically, there are two general ways to control costs on a PoW blockchain:

  1. Ahead-Of-Time Costing (AOT Costing) - estimates costs before script execution so that an over-expensive script is not executed at all
  2. Just-In-Time Costing (JIT Costing) - calculates costs during the actual execution of a script

Each of these methods has advantages and disadvantages. The upcoming v.5.0 upgrade of Ergo’s nodes uses a hybrid approach to improve cost control.

Advantages and Disadvantages of AOT Cost

Currently, Ergo uses AOT costing. Work is done on the Ergo blockchain in blocks. Each block takes about 2 minutes and it includes all the transactions for that period of time. Blocks are given a budget and they cannot exceed that budget. 

When a miner creates a block, the cost of the block is estimated ahead of time. If the cost is below the block’s budget and the math/logic adds up, the block is submitted to the blockchain.

However, estimates also have a cost. AOT costing makes sense when those costs are less than actually running the script. It is less expensive to estimate when using simple smart contract languages.

Using AOT costing has one main advantage. Limits are imposed by the network in blocks rather than by transaction. Since estimation costs are low, miners absorb transaction costs for transactions that are rejected. Each accepted transaction then requires a simple fee to be added to the block.

 

It is important to note that AOT costing is not without disadvantages. Estimates are not actual costs and are often inefficient, which wastes network resources, reduces each block’s capacity and by extension, the blockchain’s ability to scale. This is particularly true in cases such as Ergo, where the blockchain supports the use of collections of inputs and outputs, user-defined context extension variables, and other sophisticated features. Additionally, AOT costing does not take advantage of the efficiencies of next-generation smart contract languages that are less expensive to run than to estimate. 

There are other disadvantages to AOT costing, but the above establishes the need for a better model of cost control than AOT costing alone.

Ergo’s New Hybrid Method for Counting Costs

The upcoming Ergo node v.5.0 release will use a hybrid costing algorithm to contain costs and protect the network from denial-of-service, spam and other attacks on network resources. With this new approach, there are two stages to the costing algorithm. 

In the first stage, transaction inputs go through a verifier (one input after another) and each input’s script is reduced to a sigma proposition - a kind of spending condition which can be cryptographically verified. JIT costing is applied during this reduction stage. 

When every input in the transaction has a sigma proposition, then AOT costing (which is both very simple and fast) is used to calculate the costs of all cryptographic operations in the transaction. All costs are then added together to determine the final cost of the transaction itself. Once the final cost of the transaction is obtained it is added to the block cost, which must be within the block budget before it can be added to it.

The same process is repeated for each transaction in the block (in sequence) and the total cost of the block is accrued. Before it can be submitted to the blockchain, each block must be below the cost allowed per block. 

With the deployment of this new two-part costing method, costs can be established more efficiently and accurately with less expense than using AOT costing alone. As a result, the release of Ergo node v.5.0 should effectively increase the number of transactions per block, improve cost estimates, and enhance the performance of the Ergo blockchain.

Share post

Bene V2 is Here: Multi-Asset Fundraising, Expanded Wallet Support, and Enhanced UI

Bene V2 is Here: Multi-Asset Fundraising, Expanded Wallet Support, and Enhanced UI

The ecosystem of decentralized applications (dApps) on Ergo is constantly evolving.

Ergo Platform

November 28, 2025

Ecosystem Update: Duckpools Rolls Out V2 Site Preview

Ecosystem Update: Duckpools Rolls Out V2 Site Preview

The team behind Duckpools, a prominent lending and borrowing protocol on the Ergo blockchain, has released a comprehensive develop.

Ergo Platform

November 26, 2025

Ecosystem Spotlight: USE, a Universal Stablecoin for Ergo

Ecosystem Spotlight: USE, a Universal Stablecoin for Ergo

With the protocol nearing deployment, the Community Liquidity Bootstrapping (CLB) event is set to begin on November 25th, allowing.

Ergo Platform

November 24, 2025

Rosen Bridge Nears Bitcoin Runes Launch

Rosen Bridge Nears Bitcoin Runes Launch

Rosen Bridge has entered the final phase for its Bitcoin Runes integration. You can now set up your Bitcoin-Runes watcher.

Ergo Platform

November 23, 2025

GitCircles and Ergo: Fair Rewards for Open Source Contributions

GitCircles and Ergo: Fair Rewards for Open Source Contributions

Open source software powers much of the digital world — from the apps on your phone to the infrastructure of the internet itself.

Ergo Platform

October 12, 2025

Bitcoin Runes + Rosen Bridge: A Practical Path for Multi-Chain Fungible Assets

Bitcoin Runes + Rosen Bridge: A Practical Path for Multi-Chain Fungible Assets

The big idea Bitcoin finally has a clean way to represent fungible tokens.

Ergo Platform

September 30, 2025

ChainCash: Money That Carries Its Own Story

ChainCash: Money That Carries Its Own Story

ChainCash records reserves and signatures for each note on Ergo.

Ergo Platform

September 23, 2025

Braiding Lunarpunk and Solarpunk through Merged Mining

Braiding Lunarpunk and Solarpunk through Merged Mining

The question is simple.

Ergo Platform

September 2, 2025

Machina Finance: Off-Chain Execution, On-Chain Trust

Machina Finance: Off-Chain Execution, On-Chain Trust

Machina Finance is an innovative, bot-driven decentralized exchange (DEX) being developed on the Ergo blockchain.

Ergo Platform

September 1, 2025

Ergo Infrastructure DAO: Decentralizing the Backbone of the Ergo Ecosystem

Ergo Infrastructure DAO: Decentralizing the Backbone of the Ergo Ecosystem

Ergo’s mission has always been rooted in decentralization, not just at the consensus layer, but across the entire stack.

Ergo Platform

August 13, 2025

Mew Finance: A Playful DeFi Toolkit for the Ergo Ecosystem

Mew Finance: A Playful DeFi Toolkit for the Ergo Ecosystem

Mew Finance is a decentralized application suite on the Ergo Blockchain.

Ergo Platform

August 12, 2025

Lithos: Decentralizing Mining with On-Chain Pools

Lithos: Decentralizing Mining with On-Chain Pools

Lithos is a new protocol designed to overhaul how mining pools work by moving them on-chain, giving miners full control, and elimi.

Ergo Platform

July 24, 2025

Sigma 6.0: A Smarter, More Flexible Ergo

Sigma 6.0: A Smarter, More Flexible Ergo

Sigma 6.0 is a major proposed upgrade to the Ergo blockchain.

Ergo Platform

July 23, 2025

Shaping Rosen's Future: A Community Call on Five Key Treasury Proposals

Shaping Rosen's Future: A Community Call on Five Key Treasury Proposals

Rosen co-founder, Armeanio, has submitted five new proposals to the Rosen Treasury.

Ergo Platform

July 9, 2025

Ergo's Extended UTXO and the Rise of Artificial Economic Intelligence

Ergo's Extended UTXO and the Rise of Artificial Economic Intelligence

A Practical Vision for Autonomous Economic Agents Autonomous economic agents on the Ergo blockchain perform useful work in a real.

Ergo Platform

May 12, 2025

ErgoHACK X: Artificial Intelligence on the Ergo Blockchain

ErgoHACK X: Artificial Intelligence on the Ergo Blockchain

Celebrating a Decade of Decentralized Innovation Join the 10th anniversary ErgoHACK and be at the forefront of the AI revolution o.

Ergo Platform

April 10, 2025

Ergohack 9: Innovations in UI/UX and Mining – Meet the Visionary Winners!

Ergohack 9: Innovations in UI/UX and Mining – Meet the Visionary Winners!

The latest annual Ergo hackathon, ErgoHack IX, was a six-day event held at the end of October.

Ergo Platform

December 9, 2024

ErgoHack IX: Next Steps Towards Increased Adoption

ErgoHack IX: Next Steps Towards Increased Adoption

We’ve come a long way since the early days of Bitcoin, and cryptocurrencies have boomed into an industry with thousands and thousa.

Ergo Platform

October 20, 2024

Ergo Vs Other Blockchain Platforms: What’s The Difference?

Ergo Vs Other Blockchain Platforms: What’s The Difference?

Ergo offers a series of unique features that set it apart from other blockchain platforms.

Ergo Platform

August 19, 2024

Earning With The Rosen Bridge

Earning With The Rosen Bridge

Bitcoin has officially bridged to the Ergo ecosystem via Rosen Bridge! This newly built, decentralized infrastructure enables trus.

Ergo Platform

August 8, 2024

How Sigma Chains Will Bring Bitcoin To Ergo

How Sigma Chains Will Bring Bitcoin To Ergo

Ergo’s powerful, flexible, and secure smart contract functionality opens the door to a whole host of new use cases for Bitcoin DeF.

Ergo Platform

July 15, 2024