Blockchain Contract Deployment Using Stored Code Initialization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing blockchain systems face challenges in efficiently deploying smart contracts, particularly in Ethereum, due to high resource overheads and storage requirements, and lack sufficient security measures during deployment.
Innovation Solution
A two-stage deployment method is introduced, where initial contract code is first stored in the blockchain without setting immutable variable values, and a transaction is sent to call a system contract with an identifier and immutable variable value, ensuring only system contracts can execute initialization functions, thereby reducing user overheads and storage needs while enhancing security.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Quantity of substance
If traditional contract deployment method is used, then contract can be deployed in blockchain, but communication overheads and storage resources are high
Solution Approach 1:
The contract deployment process is divided into two distinct stages: (1) Code storage stage where the contract code is stored in the blockchain with immutable variables not replaced with specific values, and (2) Contract deployment stage where a transaction calls the system contract with the code identifier and immutable variable values. This segmentation allows the heavy code to be stored once and reused, reducing communication overheads and storage resources during subsequent deployments.
Solution Approach 2:
The contract code is stored in the blockchain in advance during the code storage stage, with the immutable variables left as placeholders rather than being replaced with specific values. This preliminary action allows the code to be prepared and stored efficiently, and then during the deployment stage, only the necessary parameters (code identifier and immutable variable values) need to be transmitted, significantly reducing communication overheads.
2Ease of operation
If traditional contract deployment method is used, then contract can be deployed in blockchain, but user overheads are high
Solution Approach 1:
The deployment process is segmented into code storage (performed once) and contract deployment (subsequent operations). During the code storage stage, the system stores the contract code with placeholder values for immutable variables. During the deployment stage, users only need to provide the code identifier and the actual immutable variable values, rather than transmitting the entire contract code. This segmentation significantly reduces user overheads while maintaining deployment efficiency.
Solution Approach 2:
Instead of transmitting the complete contract code every time a user wants to deploy a contract, the system uses a code identifier to reference and copy the existing stored code. This copying mechanism allows users to deploy contracts with minimal overhead by only providing the necessary parameters (code identifier and immutable variable values) rather than the entire codebase.
3Reliability
If permission control protocol is implemented, then security of contract deployment is ensured, but deployment process becomes more complex
Solution Approach 1:
A system contract is introduced as an intermediary between the user and the blockchain. The system contract handles all permission control logic and security checks. When a user wants to deploy a contract, they call the system contract with the code identifier and immutable variable values. The system contract verifies permissions and executes the deployment, abstracting away the complexity of permission control from the user and simplifying the deployment process while ensuring security.
Data Source
AI summary
Methods for deploying a contract in a blockchain and blockchain nodes are provided. In an implementation, a method includes: receiving a first transaction for deploying a first contract, where the first transaction invokes a second contract. An incoming parameter for the second contract includes a code identifier of first code and the value of an immutable variable in the first code, the code identifier and the first code are pre-stored in the blockchain, the first code includes a first function for initialize a contract, and the second contract includes a call to the first function. Before executing the first function based on the call in the second contract, obtaining the first function in the first code based on the code identifier when determining that the second contract is a system contract, and storing state data of the first contract in the blockchain by executing the first function.


