Smart Contract Gas Cost Estimation via Static Analysis

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

The Ethereum blockchain's Turing completeness makes it impossible to determine the Gas cost required to complete a smart contract before its execution, leading to uncertainties in transaction fees.

Innovation Solution

Implementing a smart contracting language that allows for static analysis to estimate the total runtime operations, maximum data writes, and expensive function calls, enabling accurate upper-bound estimates of transaction costs before execution.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If Turing complete smart contract language is used, then functional versatility is improved, but transaction cost predictability deteriorates

Engineering Contradiction:
Improvesmart contract functionalityVSAvoidGas cost estimation
Core Design Contradiction:
Adaptability or versatilityVSMeasurement precision

Solution Approach 1:

The patent performs static analysis of smart contract code before execution to estimate Gas costs in advance. The system analyzes the contract's bytecode, identifies operational patterns, and calculates upper-bound Gas estimates without executing the contract, allowing clients to know transaction costs beforehand while maintaining Turing completeness

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces a static analysis intermediary layer between contract deployment and execution. This intermediary performs preliminary code analysis, generates Gas cost estimates, and provides this information to clients before transaction submission, mediating between the Turing complete language capabilities and cost predictability requirements

Inventive Principle:
Principle #24Intermediary (Mediator)

2Measurement precision

If static analysis is implemented to estimate transaction costs, then cost predictability is improved, but system complexity increases

Engineering Contradiction:
Improvetransaction cost estimationVSAvoidanalysis system complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent uses disposable, lightweight analysis patterns that focus on identifying key operational characteristics in smart contract bytecode without requiring complex, persistent analysis infrastructure. The static analysis generates simple upper-bound estimates using straightforward bytecode scanning and pattern matching, avoiding overly complex analysis mechanisms

Inventive Principle:
Principle #27Cheap short-living objects (Disposable)

Data Source

PatentUS11657391B1System and method for invoking smart contracts
Publication Date: 2023.05.23 HIRO SYST PBC
  • US11657391B1 patent drawing
  • US11657391B1 patent drawing
  • US11657391B1 patent drawing

AI summary

The source code of a smart contract defines a schema with a map name, a key-tuple, and a value-tuple. The key-tuple can be populated with a value associated with a native field name that is associated with the principal that created a transaction.