Artificial intelligence driven blockchain hybrid consensus dynamic hierarchical optimization method and system

By using an AI-driven blockchain hybrid consensus dynamic hierarchical optimization method, the consensus strategy and hierarchical structure are dynamically adjusted, solving the problems of transaction latency, security and privacy protection in digital wallets using blockchain technology. This achieves efficient and secure multi-scenario adaptation and improves transaction processing efficiency and security.

CN121441920BActive Publication Date: 2026-04-14ZHEJIANG RURAL COMMERCIAL DIGITAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-29
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing blockchain technology in digital wallets suffers from problems such as insufficient adaptability of consensus mechanisms, low efficiency of smart contract execution across levels, contradiction between privacy protection and node trustworthiness, and insufficient adaptability to multiple scenarios. These issues result in transaction confirmation delays, inadequate security and privacy protection capabilities, and difficulty in meeting the application needs of complex scenarios.

Method used

We adopt an AI-driven blockchain hybrid consensus dynamic hierarchical optimization method. By dynamically electing super nodes and basic nodes, and combining entropy weight algorithm and ideal solution sorting algorithm, we construct a network matching model to realize the hierarchical storage of smart contract data and dynamic allocation of resources. We also improve node reputation verification through zero-knowledge proof and reputation scoring mechanism, and dynamically adjust consensus strategy and hierarchical structure.

Benefits of technology

It significantly improves processing efficiency in high-frequency trading scenarios, reduces transaction confirmation latency to within 1 second, increases high-frequency access response speed by 60%, improves complex contract execution efficiency by 3 to 5 times, enhances node security and privacy protection capabilities, reduces adaptation costs by 30% to 50%, and meets the differentiated needs of different scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121441920B_ABST
    Figure CN121441920B_ABST
Patent Text Reader

Abstract

The application discloses an AI-driven blockchain hybrid consensus dynamic level optimization method and system, aiming at solving the problems of insufficient adaptability of the existing blockchain consensus mechanism, low efficiency of smart contract execution, difficulty in balancing safety and privacy, etc. By constructing a dynamic level adaptive hybrid consensus architecture, the level structure is adjusted in real time according to the business load, and super nodes are dynamically elected to process high-frequency transactions; in combination with a deep reinforcement learning model to predict the load, the optimal consensus combination is automatically selected; through smart contract routing, high-frequency data is stored in memory, and low-frequency data is stored in a distributed manner, and based on the contract complexity, a graphics processing unit acceleration node is allocated; a node reputation scoring system is established, and the reputation level is verified by zero-knowledge proof, and when a specific numerical range attack is detected, the system is automatically switched to DAG asynchronous consensus and the node cleaning is started; the deep integration of hybrid consensus and dynamic level is realized to improve the execution efficiency. The application improves the high-frequency transaction processing efficiency and improves the complex contract efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of blockchain smart contract optimization, specifically involving an AI-driven dynamic hierarchical optimization method for blockchain hybrid consensus, including a hybrid consensus algorithm, a layered execution model for smart contracts, and adaptive resource adjustment technology. Background Technology

[0002] With the deepening application of blockchain technology in the digital wallet field, smart contracts, as the core carrier for digital wallets to achieve automated transactions, permission management, and cross-chain interaction, face a critical technical bottleneck in balancing execution efficiency and security performance. Currently, the blockchain systems upon which digital wallets rely have the following prominent issues in terms of consensus mechanisms and smart contract execution:

[0003] The consensus mechanisms lack adaptability. Existing digital wallets mostly employ a single consensus mechanism or a fixed-level hybrid consensus, failing to dynamically adjust to the real-time transaction load. In high-frequency payment scenarios, single PoW consensus suffers from transaction confirmation delays due to slow block generation, while pure PBFT consensus, though fast, has limited fault tolerance, making it difficult to meet the dual requirements of digital wallets for transaction real-time performance and security. For example, during peak settlement periods, supply chain finance digital wallets often experience payment failure rates exceeding 5% due to consensus bottlenecks.

[0004] Smart contracts suffer from inefficient cross-layer execution. Digital wallets require smart contracts to handle diverse tasks, such as small, frequent payments and large-scale cross-border settlements, but current technologies lack tiered data storage and dynamic resource scheduling mechanisms. Using traditional databases to store all contract states leads to I / O blocking due to high-frequency read / write operations, while uploading all data to the blockchain causes a surge in storage capacity demands for digital wallets. Furthermore, smart contract interfaces have poor adaptability; when the underlying blockchain consensus mechanism of a digital wallet is upgraded, the contract call failure rate reaches as high as 30%, severely impacting user experience.

[0005] There is a conflict between privacy protection and node trustworthiness. As a carrier for managing user assets and data, digital wallets must simultaneously guarantee transaction privacy and the trustworthiness of node behavior. While existing technologies such as ring signatures can hide the transaction initiator, they cannot be linked to the access control of consensus nodes. Malicious nodes could exploit privacy vulnerabilities to steal sensitive information from digital wallets. Furthermore, node admission mechanisms lack dynamic adjustment capabilities. When malicious nodes account for more than 20% of the network, traditional static permission models can lead to unreliable consensus results, directly threatening the asset security of digital wallets.

[0006] The lack of adaptability to various scenarios and the significant differences in technical requirements for digital wallets across different fields—for example, supply chain finance digital wallets require transaction confirmation latency of less than 1 second—are significant challenges. In summary, the shortcomings of existing technologies in areas such as dynamic adaptation of hybrid consensus, optimization of cross-level smart contract execution, and collaborative protection of privacy and security hinder the large-scale application of digital wallets in complex scenarios. Therefore, a hybrid consensus and smart contract collaboration mechanism capable of dynamic, hierarchical adaptation is urgently needed. Summary of the Invention

[0007] This invention addresses the shortcomings of existing blockchain consensus mechanisms in areas such as workload adaptability, contract execution efficiency, and node security. It provides an AI-driven method, system, computer-readable storage medium, and device for dynamic hierarchical optimization of blockchain hybrid consensus. This method dynamically adjusts the hierarchical structure and consensus strategy based on real-time workload, improving smart contract execution efficiency while enhancing node security and privacy protection capabilities, and making it resistant to tampering. Another objective of this invention is to meet the diverse needs of different application scenarios for transaction speed and security performance through dynamic hierarchical adaptation and hybrid consensus optimization, enabling smart contracts to operate efficiently and reliably in scenarios such as high-frequency payments, cross-border settlements, and supply chain finance.

[0008] To achieve the above and other related objectives, the present invention provides the following technical solution:

[0009] An AI-driven method for dynamic hierarchical optimization of blockchain hybrid consensus includes the following steps:

[0010] Based on the historical block production success rate of nodes, node reputation score and network communication quality, network nodes are dynamically elected through entropy weight algorithm and approximation ideal solution sorting algorithm to obtain super nodes to form the acceleration layer and the remaining network nodes to form the base layer.

[0011] Real-time monitoring and extraction of network parameters, calculation of hierarchical weights and node load factors, and construction of network node data based on network parameters, hierarchical weights and node load factors;

[0012] Construct a network matching model, and obtain the probability distribution and key parameter adjustment amount of the optimal consensus combination based on the network matching model and network node data, thereby forming a consensus strategy;

[0013] Through smart contracts, high-frequency access data is stored in an in-memory database, while low-frequency historical data is archived in a distributed storage system. The call complexity is obtained based on the relevant parameters of the smart contract code, and then acceleration nodes are dynamically allocated to the smart contract. An independent running environment is allocated through a sandbox isolation mechanism.

[0014] The node reputation score is updated based on block production behavior and Byzantine fault tolerance test results. The node reputation level is verified by zero-knowledge proof and node reputation score to obtain trusted nodes, and the trusted nodes are fed back into the dynamic election of network nodes.

[0015] As one possible implementation, the base layer adopts a consensus mechanism that combines proof-of-stake with practical Byzantine fault tolerance, and is responsible for global ledger maintenance and low-frequency transaction processing;

[0016] A high-frequency transaction threshold is preset, and the acceleration layer adopts the RAFT consensus mechanism to process high-frequency transactions that exceed the high-frequency transaction threshold;

[0017] The network node admission criteria include a preset reputation score threshold and a resource threshold, and the network node must simultaneously meet both the reputation score threshold and the resource threshold.

[0018] As one possible implementation, it also includes:

[0019] A preset performance threshold is set. If the performance parameters meet the performance threshold, the hierarchical structure adjustment is automatically triggered. The performance parameters include network latency, system load, and throughput volatility.

[0020] By calculating the payoff function of nodes participating in different levels using a game theory model based on dynamic weight allocation, nodes are guided to rationally choose consensus levels.

[0021] As one possible implementation, the network matching model includes a CNN-Transformer hybrid neural network, and the network node data includes a network topology matrix, node reputation feature vectors, and load time series. The probability distribution and key parameter adjustment amounts of the optimal consensus combination are obtained through the following steps:

[0022] The network topology features are extracted using CNN convolutional layers, and the temporal dependencies of the load time series are captured using a Transformer encoder.

[0023] By fusing spatial and temporal features through a fully connected layer, the consensus combination probability distribution and parameter adjustment amount are output, and the acceleration layer and the base layer are dynamically expanded or shrunk.

[0024] The optimal consensus combination is selected based on the probability distribution. The optimal consensus combination includes Proof-of-Stake and Practical Byzantine Fault Tolerance, Proof-of-Stake and Zero-Knowledge Proof, and RAFT or Directed Acyclic Graph Asynchronous Consensus.

[0025] As one possible implementation, the method involves using smart contracts to store frequently accessed data in an in-memory database and archive low-frequency historical data to a distributed storage system. The method also involves obtaining the call complexity based on the smart contract's code parameters and dynamically allocating acceleration nodes to the smart contract. This includes the following steps:

[0026] Preset a high-frequency threshold and migrate contract state data with read / write frequency that meets the threshold to the LevelDB in-memory database;

[0027] A low-frequency threshold is preset, and historical data that meets the low-frequency threshold is archived to the IPFS distributed storage system;

[0028] The depth of code loop nesting is used to reflect the nesting level complexity of the code; the number of function calls is used to reflect the interaction frequency during code execution; and the historical execution market is used to reflect the resource consumption level during actual operation. Based on the contract complexity model, the call complexity is obtained, as follows:

[0029]

[0030] in, Indicates the complexity of the call. The depth of nested functions. For the number of function calls, For historical execution duration, , , Indicates a parameter.

[0031] As one possible implementation, it also includes:

[0032] When signs of a 51% attack are detected, the current consensus mode is switched and the node cleaning process is initiated.

[0033] Identify abnormal nodes and migrate them to the shadow layer for observation. During this period, restrict the abnormal nodes' communication permissions with the main network and set a preset time threshold. If no abnormality occurs within the time threshold, restore their permissions.

[0034] As one possible implementation, it also includes:

[0035] Network nodes generate Schnorr signature commitment values ​​that include reputation ratings;

[0036] The verification network nodes only verify the validity of the proof and do not obtain the original score data.

[0037] An AI-driven blockchain hybrid consensus dynamic hierarchical optimization system includes:

[0038] The node election module dynamically elects network nodes based on the node's historical block production success rate, node reputation score, and network communication quality, using the entropy weight algorithm and the approximation ideal solution sorting algorithm to obtain super nodes that form the acceleration layer, and the remaining network nodes that form the base layer.

[0039] The parameter acquisition module monitors and extracts network parameters in real time, calculates hierarchical weights and node load factors, and constructs network node data based on network parameters, hierarchical weights and node load factors. The network parameters include node latency, throughput and system load rate.

[0040] The consensus strategy module constructs a network matching model, obtains the probability distribution of the optimal consensus combination and the adjustment amount of key parameters based on the network matching model and network node data, and then forms a consensus strategy.

[0041] The acceleration node module uses smart contracts to store high-frequency access data in an in-memory database and archive low-frequency historical data to a distributed storage system. It obtains the call complexity based on the code-related parameters of the smart contract, and then dynamically allocates acceleration nodes to the smart contract, and allocates an independent running environment through a sandbox isolation mechanism.

[0042] The reputation feedback module updates the node reputation score based on block production behavior and Byzantine fault tolerance test results. It verifies the node reputation level through zero-knowledge proofs and node reputation scores to obtain trusted nodes, and then feeds the trusted nodes back to the network node dynamic election.

[0043] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the following method:

[0044] Based on the node's historical block production success rate, node reputation score, and network communication quality, network nodes are dynamically elected using the entropy weight algorithm and the approximation ideal solution sorting algorithm to obtain super nodes that form the acceleration layer and the remaining network nodes that form the base layer.

[0045] Network parameters are monitored and extracted in real time, and hierarchical weights and node load factors are calculated. Network node data is constructed based on network parameters, hierarchical weights and node load factors. The network parameters include node latency, throughput and system load rate.

[0046] Construct a network matching model, and obtain the probability distribution and key parameter adjustment amount of the optimal consensus combination based on the network matching model and network node data, thereby forming a consensus strategy;

[0047] Through smart contracts, high-frequency access data is stored in an in-memory database, while low-frequency historical data is archived in a distributed storage system. The call complexity is obtained based on the relevant parameters of the smart contract code, and then acceleration nodes are dynamically allocated to the smart contract. An independent running environment is allocated through a sandbox isolation mechanism.

[0048] The node reputation score is updated based on block production behavior and Byzantine fault tolerance test results. The node reputation level is verified by zero-knowledge proof and node reputation score to obtain trusted nodes, and the trusted nodes are fed back into the dynamic election of network nodes.

[0049] An AI-driven blockchain hybrid consensus dynamic hierarchical optimization device includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the following method:

[0050] Based on the node's historical block production success rate, node reputation score, and network communication quality, network nodes are dynamically elected using the entropy weight algorithm and the approximation ideal solution sorting algorithm to obtain super nodes that form the acceleration layer and the remaining network nodes that form the base layer.

[0051] Network parameters are monitored and extracted in real time, and hierarchical weights and node load factors are calculated. Network node data is constructed based on network parameters, hierarchical weights and node load factors. The network parameters include node latency, throughput and system load rate.

[0052] Construct a network matching model, and obtain the probability distribution and key parameter adjustment amount of the optimal consensus combination based on the network matching model and network node data, thereby forming a consensus strategy;

[0053] Through smart contracts, high-frequency access data is stored in an in-memory database, while low-frequency historical data is archived in a distributed storage system. The call complexity is obtained based on the relevant parameters of the smart contract code, and then acceleration nodes are dynamically allocated to the smart contract. An independent running environment is allocated through a sandbox isolation mechanism.

[0054] The node reputation score is updated based on block production behavior and Byzantine fault tolerance test results. The node reputation level is verified by zero-knowledge proof and node reputation score to obtain trusted nodes, and the trusted nodes are fed back into the dynamic election of network nodes.

[0055] This invention, through its core designs such as hierarchical dynamic optimization, AI consensus decision-making, and reputation closed-loop management, achieves the following beneficial effects:

[0056] (1) By dynamically electing hierarchical nodes and adaptively switching consensus strategies, the system can accurately match different business loads, significantly improve the processing efficiency in high-frequency trading scenarios, and reduce the transaction confirmation delay to within 1 second.

[0057] (2) By using smart contract routing and GPU acceleration node dynamic allocation, data hierarchical storage and customized configuration of execution resources are achieved, the response speed of high-frequency access is improved by 60%, and the execution efficiency of complex contracts is improved by 3 to 5 times;

[0058] (3) Establish a dynamic reputation feedback closed loop and multiple security protection mechanisms, and combine zero-knowledge proof technology to protect node privacy while ensuring the effectiveness of node reputation verification, effectively resist malicious behaviors such as 51% attacks, and improve system security;

[0059] (4) Through modular design and consensus combination dynamic adaptation, it can flexibly meet the differentiated needs of different scenarios such as supply chain finance, medical data sharing, and high-frequency payment, reducing the adaptation cost by 30% to 50% and having broad application prospects.

[0060] Other advantages, objectives and features of the present invention will become apparent in part from the following description, and in part from those skilled in the art through study and practice of the invention. Attached Figure Description

[0061] Figure 1 This is a schematic flowchart of the method of the present invention;

[0062] Figure 2 This is a schematic diagram of the overall system of the present invention;

[0063] Figure 3 This is a flowchart of the dynamic hierarchical division process of the present invention;

[0064] Figure 4 This is a flowchart of the hybrid consensus switching and optimization process of this invention;

[0065] Figure 5 This is a flowchart of the AI-driven consensus combination decision-making process of the present invention;

[0066] Figure 6 This is a flowchart of the CNN-Transformer model training process of the present invention;

[0067] Figure 7 This is a schematic diagram illustrating the consensus decision-making process of this invention. Detailed Implementation

[0068] To clearly illustrate the present invention and make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings, so that those skilled in the art can implement the invention based on the description. The technology of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0069] Example 1:

[0070] This invention proposes an AI-driven blockchain hybrid consensus dynamic hierarchical optimization method and system, which achieves efficient adaptation of the blockchain system in multiple scenarios by dynamically adjusting the hierarchical structure, optimizing the consensus strategy, intelligently scheduling resources, and strengthening security protection.

[0071] The system architecture proposed in this invention breaks through the static design of traditional blockchain's "single-layer" + "fixed consensus," and for the first time proposes a four-layer orthogonal decoupled framework consisting of a "consensus layer, execution layer, interaction layer, and control layer." Figure 3 As shown, each layer is both independently optimized and deeply collaborative, achieving a fusion of hybrid consensus and intelligent optimization of dynamic hierarchies.

[0072] An AI-driven dynamic hierarchical optimization method for blockchain hybrid consensus, such as Figure 1 As shown, it includes the following steps:

[0073] S100: Based on the historical block production success rate of nodes, node reputation score and network communication quality, network nodes are dynamically elected through entropy weight algorithm and approximation ideal solution sorting algorithm to obtain super nodes to form the acceleration layer, and the remaining network nodes to form the basic layer.

[0074] S200. Monitor and extract network parameters in real time, calculate hierarchical weights and node load factors, and construct network node data based on network parameters, hierarchical weights and node load factors. The network parameters include node latency, throughput and system load rate.

[0075] S300. Construct a network matching model, and obtain the probability distribution and key parameter adjustment amount of the optimal consensus combination based on the network matching model and network node data, thereby forming a consensus strategy.

[0076] S400 uses smart contracts to store high-frequency access data in an in-memory database and archive low-frequency historical data to a distributed storage system. It obtains the call complexity based on the code-related parameters of the smart contract, and then dynamically allocates acceleration nodes for the smart contract and allocates an independent running environment through a sandbox isolation mechanism.

[0077] S500 updates the node reputation score based on block production behavior and Byzantine fault tolerance test results. It verifies the node reputation level through zero-knowledge proof and node reputation score to obtain trusted nodes and feeds the trusted nodes back into the network node dynamic election.

[0078] In this embodiment, in step S100, a two-layer consensus architecture consisting of a base layer and an acceleration layer is dynamically constructed based on the real-time business load. The base layer consists of 100 nodes and adopts the PoS+PBFT consensus mechanism, which is responsible for global ledger maintenance and low-frequency transaction processing. The acceleration layer consists of 20 super nodes and adopts the RAFT consensus mechanism, which is dedicated to handling high-frequency transactions exceeding 500 transactions per second. Based on historical block success rate, real-time reputation score and communication quality, super nodes are dynamically elected through the entropy weight algorithm to handle high-frequency transactions.

[0079] The hierarchical structure is adjusted in real time and supernodes are dynamically elected via smart contracts. The base layer consists of N nodes; in this embodiment, N=100 is used as an example. For instance, in a network with 100 nodes, if some nodes experience response delays due to excessive load, the system will re-elect supernodes to optimize network performance. A PoS+PBFT consensus mechanism is used, responsible for global ledger maintenance, low-frequency transaction processing, and security verification. Node admission requires meeting basic reputation scores and resource thresholds, including at least 4 CPU cores, at least 8GB of memory, and at least 30% remaining battery power. In this embodiment, the acceleration layer initially contains M supernodes; in this embodiment, M=20 is used as an example. A RAFT consensus mechanism is employed, focusing on processing high-frequency transactions exceeding 500 transactions per second. Supernodes are elected from the base layer nodes, with election metrics and weights including historical block production rate, reputation score, and communication latency. A weighted average score is calculated for candidate nodes, and TOPM nodes are selected.

[0080] In the super node election and re-election of this invention, multiple indicators such as the node's historical block production success rate and reputation score are comprehensively considered. The weight of each indicator is determined by calculating entropy weight. Then, the candidate nodes are sorted and selected. When the consensus response time exceeds the threshold for three consecutive times or the node load imbalance exceeds 20%, the re-election process is automatically triggered, and the consensus combination is selected and the parameters are adjusted.

[0081] This embodiment utilizes a deep reinforcement learning model, such as the CNN-Transformer model, to process network topology matrix, node reputation feature vectors, and load time series data in real time. CNN convolutional layers extract topological spatial features, the Transformer encoder captures temporal dependencies, and fully connected layers fuse features to output the consensus combination probability distribution and parameter adjustment amounts. For example, based on predicted load changes, the system may select a consensus combination of PoS+ZKP+RAFT and adjust the number of PBFT nodes and the PoW difficulty coefficient.

[0082] In this embodiment, network parameters such as node latency, throughput, and system load rate are monitored in real time. When the average network latency exceeds 500 milliseconds for 2 minutes, or the system load exceeds 80% and the throughput volatility exceeds 15%, the hierarchical structure adjustment is automatically triggered. Hierarchical weights and node load factors are dynamically calculated as a quantitative basis for nodes to participate in consensus at different levels. If acceleration layer node expansion is triggered, five nodes are added each time. When the load is below 30% for 5 minutes, acceleration layer node reduction is triggered, reducing three nodes each time. When network latency exceeds 500 milliseconds for more than 2 minutes, or the system load exceeds 80% accompanied by a throughput volatility exceeding 15%, the adjustment process includes adding acceleration nodes, calculating node revenue using a game theory model, and diverting high-frequency transactions to the acceleration layer to adapt to different business needs. For example, in a supply chain finance scenario, when logistics nodes experience excessive latency due to network congestion, the system will automatically identify and trigger adjustments.

[0083] The logic for triggering acceleration layer expansion is established through automatic identification and adjustment. The following is a closed-loop analysis of the overall logic for triggering acceleration layer expansion: First, analyzing the triggering conditions, there are load status, latency status, and throughput volatility. Triggering occurs when the load status threshold exceeds 80%, and the trend predicts that the load will exceed 85% within the next 5 minutes. Latency conditions are not triggered when the average latency exceeds 25 milliseconds but does not exceed 500 milliseconds. All triggering conditions are met when the throughput volatility fluctuates within a characteristic range. After the triggering conditions are met, optimization actions are executed, such as acceleration layer expansion, game theory model incentives, and data diversion. By adding 5 super nodes, the processing capacity of high-frequency trading is improved, and the high-frequency trading response latency is reduced to 50 milliseconds.

[0084] In the S300, a deep reinforcement learning model is used to predict the future load trend of the system. In this embodiment, a CNN-Transformer hybrid neural network and network node data are used. The topological spatial features are extracted by the CNN convolutional layer, the temporal dependencies are captured by the Transformer encoder, and the fully connected layer fuses the features to output the consensus combination probability distribution and key parameter adjustment, so as to achieve adaptive matching between the consensus strategy and the layer.

[0085] The S400 uses smart contract routing to achieve high-frequency data in-memory storage and low-frequency data distributed storage, and allocates CPU acceleration nodes based on contract complexity. For example... Figure 4In the initial monitoring phase, the monitoring system initiates the monitoring module to continuously collect data. Data is periodically refreshed according to the CNN-Transformer algorithm to establish a time-series analysis model. This model operates cyclically to maintain load prediction. A smart contract routing module enables hierarchical data storage and dynamically allocates execution resources based on contract complexity. After a contract scheduling request is issued, the frequency of data access is analyzed to obtain real-time vital signs data, which is stored in a LevelDB in-memory database. Historical data is archived to IPFS, and private data is stored using encrypted sharding.

[0086] like Figure 6 The diagram shown illustrates the training process of the CNN-Transformer model of this invention. The system first performs real-time data acquisition and feature engineering, using a CNN to process network topology data and a Transformer to encode the load sequence. Then, feature fusion is performed through a fully connected layer. Based on the fused features, a consensus decision is made, outputting different consensus combination strategies. The decision results are then fed back to the loss function to optimize the model, such as... Figure 7 As shown in the flowchart, this flowchart illustrates how the system utilizes deep learning models for intelligent decision-making based on consensus. The CNN-Transformer consists of a CNN feature extraction module, a Transformer encoding module, and a feature fusion module. The input data for the CNN feature extraction module is the network topology matrix, using 3D modeling... The 3DCNN3 uses convolutional kernel spatial encoding to output node-related feature maps. The Transformer encoding module takes time-series data as input and uses a multi-head attention mechanism to output a sequence dependency vector. The feature fusion module takes spatial features and temporal vectors as input and uses gated cross-connected layers to output the probability distributions of historical data and predicted data for the consensus strategy probability distribution. The topology matrix of the input layer is shown in A1. 3 The feature map of the matrix space of the 3 cores is used to obtain the relative positional encoding of the load sequence improved by Transformer and the temporal dependency vector. The gated cross unit in the fusion layer needs to be adjusted according to the spatial features and temporal vector. The decision layer automatically adjusts the parameters according to the data distribution of the consensus strategy. The parameter adjustment amount is updated in real time. The node mobility dynamic factor is introduced to improve the prediction accuracy of high dynamic scenarios.

[0087] In this embodiment, high-frequency access data (more than 500 read / write operations per second) is stored in a LevelDB in-memory database using smart contracts, while low-frequency historical data (not accessed for 30 days) is archived to the IPFS distributed storage system. Graphics processor (GPU) acceleration nodes are dynamically allocated to execute complex contracts based on a contract complexity model, such as by allocating execution resources according to loop nesting depth and function call count. Complex contracts are assigned to dedicated GPU-accelerated nodes for execution to improve computational efficiency. Simultaneously, a sandbox isolation mechanism is employed, allocating an independent Docker container to each contract execution instance, limiting its CPU, memory, and network bandwidth resources, and monitoring abnormal contract execution behavior in real time. For example, when processing complex financial derivatives contracts, the system automatically allocates GPU acceleration nodes and initiates sandbox isolation to prevent contract anomalies from affecting the entire system.

[0088] An isolation mechanism is employed to ensure execution security. The contract complexity model is as follows:

[0089]

[0090] in For the depth of nested loops, For the number of function calls, For historical execution duration, Indicates the complexity of the call.

[0091] In this invention, data diversion rules include high-frequency data diversion rules and low-frequency data diversion rules. For high-frequency data, contract states with read / write frequencies exceeding 500 times per second are stored in a LevelDB in-memory database, and snapshots are synchronized to the base layer every 10 minutes to ensure data consistency. In subsequent diversion of high-frequency transactions to the acceleration layer, acceleration layer nodes are dynamically scaled based on load prediction. For low-frequency data diversion, contract data that has not been accessed for 30 days is included. This contract data is automatically archived to IPFS, with a Merkle tree-driven index, and values ​​are IPFS addresses. During queries, the index is used to quickly locate callbacks. Sandboxing technology is employed to limit resources and monitor behavior, enabling the detection of infinite loops and illegal system calls. In this invention, contract resource allocation supports CUDA parallel computing, significantly improving the execution speed of complex contracts.

[0092] Intermediate transaction results are temporarily stored in a cross-level state channel, with different consensus algorithms used at different levels. For example, in a transaction between a core enterprise and a supplier, intermediate results are temporarily stored in the state channel, and the final state is submitted after confirmation by all levels. Merkle trees are used to achieve cross-level state synchronization, synchronizing only key state change data to reduce data transmission volume. During cross-level collaboration, when abnormal contract behavior is detected, such as resource overruns, a deduction in node reputation score is automatically triggered. Based on the optimized contract execution effect output from cross-level synchronization, the detection status is returned to start the next round of optimization loop. Figure 4 As shown.

[0093] Based on the above content and Figure 4 The flowchart and working mechanism are explained in detail. When "network latency exceeds 500 milliseconds or system load exceeds 80%" are the trigger conditions, the process is divided into two branches: "Maintaining the current level" and "Triggering the optimization process." Through dynamic adjustments to the level, consensus, data storage, and security strategies, the blockchain system achieves adaptive optimization. Initial monitoring and condition judgment: Monitoring begins, and the system continuously collects network status data, including average network latency, system load rate, and throughput. Checking if any of the following conditions are met: If not, proceeding to the "Maintaining the current level" branch to continue monitoring the network status. If the conditions are met: Proceeding to the "Triggering the optimization process" branch to initiate level adjustment and consensus switching.

[0094] Branch 1 maintains the existing architecture and continuous monitoring. The system retains its base and acceleration layer structures, with no adjustments to the number of nodes or consensus strategy. It returns to the initial detection phase, continuously collecting network operation data to ensure timely response to subsequent changes. Branch 2 triggers the optimization process. When the conditions of "transaction time exceeding 500 milliseconds or system load exceeding 80%" are met, the optimization process is initiated, sequentially executing three processing layer structure adjustments, dynamic switching of hybrid consensus, and output of optimization results. The detailed processes of these three steps are as follows:

[0095] The hierarchical structure adjustment alleviates the pressure on high-frequency transaction processing by temporarily increasing the number of acceleration layer nodes. A mathematical game theory model calculates the benefits of nodes participating in different layers, guiding nodes to actively choose between the base layer and the acceleration layer, achieving hierarchical load balancing with a target load difference of less than 10% between layers. A real-time transaction diversion mechanism transfers high-frequency transactions such as payment settlement and real-time orders to the acceleration layer, while low-frequency transactions such as historical record queries remain in the base layer, avoiding network congestion.

[0096] The hybrid consensus mechanism dynamically switches between layers, adjusting the hierarchical structure in sync. This dynamic switching further optimizes system performance. An entropy-weighted ideal solution is used to re-elect supernodes in the acceleration layer, prioritizing nodes with high reputation and fast response times. The acceleration layer employs efficient consensus algorithms like RAFT to process high-frequency transactions, compressing transaction latency to within one second. A data offloading and storage strategy is implemented: high-frequency data such as account balances are stored in the Level database, achieving second-level read / write responses; low-frequency data such as historical transactions are stored in the InterPlanetary File System, reducing storage pressure on the main chain. Security is enhanced by using containerization technology to allocate independent operating environments for smart contracts, preventing malicious contract attacks on the main network; reputation scoring is based on node historical behavior, dynamically adjusting node permissions and limiting participation to nodes with reduced reputation; and state channels or Merkle tree technology ensure data consistency between the base layer global ledger and high-frequency transactions in the acceleration layer.

[0097] The system outputs key optimization metrics such as transaction latency, transaction success rate, and resource utilization, providing feedback on the actual implementation effect of the "hierarchical structure adjustment + hybrid consensus switching" solution, thus completing the optimization loop.

[0098] Based on the above content, the core logic of the dynamic optimization process of the AI-driven hybrid consensus system for smart contracts is: real-time monitoring of system status - exceeding the trigger optimization conditions - exceeding the execution of layered optimization - exceeding the completion of cross-level collaboration.

[0099] Establish a node reputation scoring system, combining zero-knowledge proofs to verify reputation levels. When a specific numerical range is detected, automatically switch to DAG asynchronous consensus and initiate node cleaning. The scoring algorithm formula is: ; For node reputation data, The decay coefficient is set to 24 hours to address the issue of outdated historical behavior. These are behavioral rewards and punishments. This is a malicious behavior amplification factor, with consecutive violations increasing exponentially. Dynamic permission adjustments are made based on calculations; if a node fails to produce blocks twice consecutively, it is automatically downgraded to a verification node. Permission levels are divided into super nodes, verification nodes, and observer nodes, with different functional restrictions from high to low permission levels. This achieves hierarchical control, and switching levels corresponds to switching permission levels, which in turn involves node switching and automatic allocation of permission-restricted resources.

[0100] Figure 5The diagram illustrates the consensus combination decision-making process of this invention. First, data such as average network latency and node downtime rate are collected to determine if the average network latency exceeds 500 milliseconds. If it does, a fuzzy logic system is used to calculate weights and adjust consensus parameters. Simultaneously, load trends are predicted, and adaptive layer control and acceleration layer weight adjustments are implemented. Based on the adjustment results, the system may enable a PoS+ZKP combination and divert high-frequency transactions. This flowchart demonstrates how the system dynamically selects the optimal consensus combination based on network and load conditions.

[0101] Based on the above, the technology breakthrough award reputation score and load sequence are fused and mapped onto an elliptic curve through a mapping unit. Verification nodes only need to verify the validity of the proof, without needing to obtain the original score data. For example, when a node applies to upgrade to the acceleration layer, it uses zero-knowledge proofs to prove to the verification node that its reputation level meets the requirements, while protecting the node's privacy data. The proof range ZKRP verification time is three times faster than traditional verification. In response to AI-driven attacks, DAG consensus is used for instantaneous switching.

[0102] In step S500, a node reputation scoring system is established, with scores decaying every 24 hours at a decay coefficient of 0.95. Zero-knowledge proofs are used to verify node reputation levels, achieving trusted node identification while protecting privacy. When the attack detection engine detects signs of a 51% attack, specifically three consecutive blocks generated by the same node, the consensus mode is automatically switched to DAG asynchronous consensus, and a node cleaning process is initiated, migrating abnormal nodes to the shadow layer for observation for 72 hours. Node permissions are dynamically adjusted based on their reputation scores; nodes with reputation scores below a threshold are downgraded to the base layer and prohibited from participating in the acceleration layer consensus. For example, if a node's reputation score decreases due to multiple late block productions, the system will automatically reduce its permissions.

[0103] When three consecutive blocks are detected to be generated by the same node, it is considered an indication of a 51% attack. The system automatically switches to a DAG-based asynchronous consensus mode and initiates a node cleanup process. The 51% attack detection model is as follows: , The number of consecutive node blocks. t represents the block time offset. Abnormal nodes are migrated to the shadow layer, restricting their communication permissions with the main network. In this embodiment, to achieve resource security linkage control as described above, the security response chain module first detects Byzantine behavior and then initiates DAG asynchronous consensus. Abnormal nodes are demoted to the shadow layer, where their behavior is observed for 72 hours, and the CNN-Transform model dynamically updates their reputation scores. If no further abnormalities occur, permissions are restored. For example, when a potential 51% attack is detected, the system switches the consensus mode and isolates the abnormal node to ensure network security.

[0104] Furthermore, this embodiment employs a four-layer orthogonal decoupled architecture comprising a consensus layer, execution layer, interaction layer, and control layer, combined with a spatiotemporal fusion decision-making mechanism, to achieve deep integration and system optimization of the hybrid consensus algorithm and dynamic hierarchical structure. This deep integration of hybrid consensus and dynamic hierarchy significantly improves transaction processing efficiency, reducing latency to less than one second. Through deep linkage between the AI ​​hybrid consensus layer, smart contract execution layer, cross-layer interaction layer, and adaptive control layer, the blockchain system achieves efficient adaptation to dynamic environments. Resource and security linkage control is also added in this invention. This architecture breaks through the limitations of traditional static consensus, achieving intelligent integration of hybrid consensus and dynamic hierarchy through a closed-loop mechanism of "perception-decision-execution-feedback."

[0105] The core function of the AI ​​hybrid consensus layer in this embodiment is dynamic policy decision-making, realizing a spatiotemporal fusion decision engine, employing 3DCNN topology modeling and improved Transformer positional encoding; the core function of the smart contract execution layer is to realize resource scheduling and security isolation, employing contract complexity AST parsing and a graphics processor resource elasticity matrix; the core formula of the cross-level interaction layer is to realize data consistency packaging, using a two-stage atomic commit protocol to achieve state channel pre-confirmation and batch final confirmation; the core function of the adaptive control layer is to realize global state regulation, realizing a resource security linkage controller to enable real-time mapping of defense strategies. A four-layer framework is designed using orthogonal decoupling, with each layer communicating in real-time through standardized interfaces, while also supporting independent expansion, such as changing the consensus algorithm without modifying the execution layer. The hybrid consensus layer, as the decision-making center of the dynamic strategy, is the "brain" of the method system of this invention. Through the collaboration of the CNN-transformer decision module and the access module of the AI ​​consensus fusion module, real-time optimization and hierarchical collaboration of the strategy are achieved.

[0106] The CNN-Transformer decision module: The input layer receives data such as the network delay matrix and load time series. CNN convolutional kernels extract topological spatial features, and the Transformer encoder captures temporal dependencies through an attention mechanism. The output layer provides consensus combination strategies and parameter adjustment suggestions through linear and non-linear outputs. For example, this module can predict future load trends based on real-time load data and recommend suitable consensus algorithm combinations. The core application of Transformer in time series analysis lies in its self-attention mechanism, which enables it to effectively capture long-term dependencies in time series data. Through parallel processing capabilities and positional encoding, Transformer not only improves processing efficiency but also ensures the accuracy of the time sequence. Its flexible model structure allows for adjustments to adapt to data of varying complexity. One of the key characteristics of time series data is its inherent temporal dependencies. Transformer, through its self-attention mechanism, can capture these dependencies regardless of their distance in the sequence. Unlike traditional recurrent neural networks or long short-term memory networks, Transformer can process sequence data in parallel, thereby improving processing efficiency.

[0107] The AI ​​consensus fusion module integrates a base layer and an acceleration layer dual engine, achieving smooth switching of consensus algorithms through a fuzzy logic controller. For example, when malicious nodes are detected to account for more than 10%, the zero-knowledge proof component is automatically activated, upgrading the base layer consensus from "PoS+PBFT" to "PoS+ZKP+PBFT," improving privacy protection without sacrificing efficiency. When high-frequency transactions account for more than 60%, the acceleration layer weight is dynamically increased from 0.3 to 0.6, guiding 80% of transactions to prioritize the RAFT consensus channel. It integrates the base layer consensus engine, the acceleration layer consensus engine, the dynamic election module, and the fuzzy logic controller. The model can directly output consensus algorithm combination strategies, achieving deep integration of hybrid consensus and dynamic layers.

[0108] In this invention, spatiotemporal gate fusion is achieved through fusion layer computation and consensus decision-making. The fusion layer AI automatically calculates spatial feature weights and temporal feature weights, and trains the weight matrix based on a deep pre-trained model to obtain the spatial feature weights and temporal feature weights. Specifically:

[0109] Linear transformation:

[0110]

[0111] Sum and Singmoid activation:

[0112] Feature vector fusion This represents a spatiotemporal joint state, characterized by high load risk and topological bottlenecks. A consensus strategy decision is made based on the feature vectors, calculated as follows:

[0113]

[0114] As shown in the formula above, a probability of 0.92 represents the basic consensus layer, and a probability of 0.08 represents the acceleration layer consensus layer. The strategy decision selects different consensus layers and other layers based on the varying probabilities.

[0115] like Figure 3 The smart contract execution layer in this invention serves as a highly efficient engine for resource scheduling. This layer focuses on intelligent lifecycle management, achieving a balance between resource utilization and security through the collaboration of the contract execution module and the data storage module. In this invention, the data storage module refers to a hierarchical management system combining an in-memory library and IPFS storage, enabling efficient storage and access to both high-frequency and low-frequency data.

[0116] It supports contract routing, GPU node allocation, and sandbox isolation. For example, it automatically allocates GPU acceleration nodes to complex contracts based on their code complexity and activates a sandbox isolation mechanism. Based on a dynamic "complexity-resource" matching mechanism, contracts are categorized into simple, medium, and complex levels by analyzing the nesting depth and function call chain length of the contract code using an abstract syntax tree. Complex contracts are automatically assigned to GPU acceleration nodes, improving execution efficiency by 3-5 times through CUDA parallel computing; simultaneously, a lightweight sandbox is activated to restrict the contract's memory access range and system call permissions, preventing malicious code overflows.

[0117] like Figure 3 In this invention, the cross-layer interaction layer refers to the central hub for ensuring collaborative consistency. This layer achieves efficient collaboration between the base layer and the acceleration layer through a cross-layer communication module, solving the problems of "data silos" and "consistency breaks" in traditional layered architectures. A dynamic routing protocol is adopted: the optimal transmission path is constructed based on the real-time communication quality of nodes, and the response time for data interaction between layers is less than or equal to 200 milliseconds. For example, when high-frequency transactions processed by the acceleration layer require final confirmation at the base layer, the "fragmented signature + batch submission" mechanism reduces the number of cross-layer communications by 60%. An innovative state channel temporary storage mechanism is implemented: intermediate results of cross-layer transactions are first stored in the state channel, and the final state is submitted only after both layers reach consensus. The atomicity of transactions is ensured through a two-stage mechanism of "pre-confirmation + final confirmation," which can shorten the transaction confirmation cycle between core enterprises and suppliers from 3 seconds to 800 milliseconds in supply chain finance scenarios. Efficient data interaction between layers is achieved based on the dynamic routing protocol, with a response time of no more than 200 milliseconds.

[0118] like Figure 3In this invention, the adaptive control layer refers to a dynamically adjusted intelligent hub, which acts as the system's "nerve center." Through the linkage of the dynamic hierarchical control unit, parameter extraction engine, and security control module, it achieves real-time adaptation of the hierarchical structure and security policies. In this invention, the dynamic hierarchical control unit adjusts the hierarchical structure in real time based on business load and manages supernode election. For example, when the system load is too high, the number of acceleration layer nodes is increased to improve processing capacity. The number of acceleration layer nodes is dynamically adjusted based on the network status collected by the parameter extraction engine, ensuring that the acceleration layer always consists of nodes with optimal communication quality. In this invention, the parameter engine collects network parameters in real time, such as average network latency, throughput, and system load rate, and dynamically calculates hierarchical weights and load factors, providing a basis for nodes to participate in consensus at different levels. In this invention, the security control module includes a reputation scoring database, a ZKP verification component, and an attack detection engine. The attack detection engine has a false positive rate of less than 0.1% and a false negative rate of less than 0.05%, effectively ensuring system security.

[0119] By achieving deep integration of hybrid consensus and dynamic hierarchy between modules, the Transformer position encoding is improved using a spatiotemporal fusion decision engine—3DCNN topology modeling; resource and security linkage control, elastic resource matrix and cross-level defense real-time collaboration; a four-layer orthogonal decoupled architecture, achieving independent optimization and deep collaboration of consensus layer, execution layer, interaction layer and control layer for the first time.

[0120] In summary, this invention overcomes the technical bottlenecks of traditional blockchains in terms of consensus adaptability, contract execution efficiency, security and privacy balance, and multi-scenario adaptation by constructing an AI-driven dynamic hierarchical optimization method and system for blockchain hybrid consensus. Its core innovations lie in: achieving independent optimization and deep collaboration between the consensus layer, execution layer, interaction layer, and control layer using a four-layer orthogonal decoupling architecture; enhancing the dynamic adaptability of consensus strategies through a spatiotemporal fusion decision engine; and achieving a balance between efficiency and security through a resource and security linkage control mechanism, a flexible resource matrix, and cross-layer defense collaboration.

[0121] In practical applications, this invention has achieved the following technical effects: it can compress the confirmation delay of high-frequency transactions to within 1 second, improving transaction processing efficiency by more than 60%; it improves the execution efficiency of complex contracts by 3-5 times and increases resource utilization by 40%; through dynamic reputation management and zero-knowledge proofs, it protects node privacy while ensuring security; and the system adapts to different business scenarios, reducing adaptation costs by 30%-50% in supply chain finance scenarios. Its technical solution not only provides a new paradigm for the efficient and secure operation of blockchain smart contracts but also promotes the deep integration of AI technology and blockchain architecture, laying a solid foundation for the large-scale deployment of blockchain in complex business scenarios.

[0122] The core innovation and novelty of this invention are reflected in the following five major technological breakthroughs, completely breaking away from the inherent limitations of traditional blockchain's "static architecture + fixed consensus":

[0123] The first four-layer orthogonal decoupled flexible linkage architecture is proposed: the four-dimensional framework of "consensus layer - execution layer - interaction layer - control layer" is proposed for the first time. Through standardized interfaces, each layer can be independently optimized and deeply coordinated, which solves the pain points of "functional coupling and difficulty in expansion" in traditional layered architecture. For example, changing the consensus algorithm does not require modifying the execution layer logic, which greatly improves the system flexibility.

[0124] AI-driven spatiotemporal fusion decision engine: It innovatively adopts a hybrid model of "3DCNN topology modeling + improved Transformer position encoding", which for the first time deeply integrates network topology spatial features, load temporal dependence and node reputation data, outputs the optimal consensus combination probability distribution, and the predictive elastic scaling mechanism improves the hierarchical adjustment response speed by 3 times compared with the traditional static strategy.

[0125] Reputation-Resource-Security Closed Loop: Constructing a triple protection system of "dynamic reputation scoring + zero-knowledge proof (ZKRP) + instant DAG switching". Reputation scoring is strongly bound to node permissions and hierarchical access control. Zero-knowledge proofs achieve "trusted verification under privacy protection". DAG consensus switches instantly after a 51% attack is detected, with an attack response time of less than 100 milliseconds and a false positive rate of only 0.1%.

[0126] Contract Complexity-Resource Dynamic Matching Mechanism: Based on the abstract syntax tree, this mechanism analyzes the characteristics of contract loop nesting depth, function call chain, etc., and pioneers the execution mode of "complexity hierarchical - graphics processor acceleration - sandbox isolation". Complex contracts are improved by 3 to 5 times through CUDA parallel computing, and sandbox isolation prevents malicious code overflow, solving the problems of "uneven resource allocation and high security risk" in traditional contracts.

[0127] Cross-level collaborative consistency guarantee: The innovative "state channel pre-confirmation + Merk tree batch synchronization" mechanism ensures that the response time for data interaction between levels is no more than 200 milliseconds. The atomicity of cross-level transactions is guaranteed through a two-phase commit protocol. In supply chain finance scenarios, the transaction confirmation cycle is shortened from 3 seconds to 800 milliseconds, and the amount of data transmitted is reduced by 60%.

[0128] This invention constructs an AI-driven adaptive optimization system for blockchain, with "perception-decision-execution-feedback" as its core closed loop. First, a parameter extraction engine perceives network load, node status, and other data in real time. Second, a CNN-Transformer model determines the optimal consensus combination and hierarchical parameters. Third, smart contracts enable layered storage of high-frequency / low-frequency data, and complex contracts are accelerated by a graphics processor. Simultaneously, a dynamic reputation system and security protection module ensure trusted privacy. Finally, a four-layer orthogonal decoupling architecture enables deep cross-level collaboration, forming a complete closed loop of "state perception-strategy decision-resource scheduling-security protection-optimization feedback," ultimately achieving efficient, secure, and adaptive operation of the system in multiple scenarios.

[0129] Example 2:

[0130] An AI-driven blockchain hybrid consensus dynamic hierarchical optimization system, such as Figure 2 As shown, it includes:

[0131] The node election module 100 dynamically elects network nodes based on the node's historical block production success rate, node reputation score, and network communication quality, using the entropy weight algorithm and the approximation ideal solution sorting algorithm to obtain super nodes to form the acceleration layer, and the remaining network nodes to form the basic layer.

[0132] The parameter acquisition module 200 monitors and extracts network parameters in real time, calculates hierarchical weights and node load factors, and constructs network node data based on network parameters, hierarchical weights and node load factors. The network parameters include node latency, throughput and system load rate.

[0133] The consensus strategy module 300 constructs a network matching model, obtains the probability distribution of the optimal consensus combination and the adjustment amount of key parameters based on the network matching model and network node data, and then forms a consensus strategy.

[0134] The acceleration node module 400 uses smart contracts to store high-frequency access data in an in-memory database and archive low-frequency historical data to a distributed storage system. It obtains the call complexity based on the code-related parameters of the smart contract, and then dynamically allocates acceleration nodes to the smart contract, and allocates an independent running environment through a sandbox isolation mechanism.

[0135] The reputation feedback module 500 updates the node reputation score based on block production behavior and Byzantine fault tolerance test results. It verifies the node reputation level through zero-knowledge proof and node reputation score to obtain trusted nodes, and feeds the trusted nodes back to the network node dynamic election.

[0136] The description herein is therefore intended to be part of the completeness of the invention.

[0137] The above description of the embodiments is provided to enable those skilled in the art to understand and apply the present invention. It will be apparent to those skilled in the art that various modifications can be made to the above embodiments, and the general principles described herein can be applied to other embodiments without inventive effort. Therefore, the present invention is not limited to the above embodiments, and any improvements and modifications made to the present invention by those skilled in the art based on the disclosure thereof should be within the scope of protection of the present invention.

Claims

1. An AI-driven dynamic hierarchical optimization method for blockchain hybrid consensus, characterized in that, Includes the following steps: Based on the node's historical block production success rate, node reputation score, and network communication quality, network nodes are dynamically elected using the entropy weight algorithm and the approximation ideal solution sorting algorithm to obtain super nodes that form the acceleration layer and the remaining network nodes that form the base layer. Network parameters are monitored and extracted in real time, and hierarchical weights and node load factors are calculated. Network node data is constructed based on network parameters, hierarchical weights and node load factors. The network parameters include average network latency, throughput and system load rate. A network matching model is constructed, and the probability distribution and key parameter adjustment amounts of the optimal consensus combination are obtained based on the network matching model and network node data, thereby forming a consensus strategy. The network matching model includes a neural network model. Through smart contracts, high-frequency access data is stored in an in-memory database, while low-frequency historical data is archived in a distributed storage system. The call complexity is obtained based on the relevant parameters of the smart contract code, and then acceleration nodes are dynamically allocated to the smart contract. An independent running environment is allocated through a sandbox isolation mechanism. The node reputation score is updated based on the block production behavior and Byzantine fault tolerance test results. The node reputation level is verified by zero-knowledge proof and node reputation score to obtain trusted nodes. The trusted nodes are then fed back into the dynamic election of network nodes. This involves using smart contracts to store frequently accessed data in an in-memory database and archive low-frequency historical data to a distributed storage system. The call complexity is determined based on the smart contract's code parameters, and acceleration nodes are then dynamically allocated to the smart contract. This process includes the following steps: Preset a high-frequency threshold and migrate contract state data with read / write frequency that meets the threshold to the LevelDB in-memory database; A low-frequency threshold is preset, and historical data that meets the low-frequency threshold is archived to the IPFS distributed storage system; The depth of nested loops in the code is used to reflect the nesting level complexity of the code; the number of function calls is used to reflect the frequency of interactions during code execution; and the historical execution time is used to reflect the resource consumption level during actual operation. Based on the contract complexity model, the call complexity is obtained, as follows: in, Indicates the complexity of the call. The depth of nested functions. For the number of function calls, For historical execution duration, , , Indicates a parameter.

2. The AI-driven blockchain hybrid consensus dynamic hierarchical optimization method according to claim 1, characterized in that, The base layer adopts a consensus mechanism that combines proof-of-stake with practical Byzantine fault tolerance, and is responsible for global ledger maintenance and low-frequency transaction processing; A high-frequency transaction threshold is preset, and the acceleration layer adopts the RAFT consensus mechanism to process high-frequency transactions that exceed the high-frequency transaction threshold; The network node admission criteria include a preset reputation score threshold and a resource threshold, and the network node must simultaneously meet both the reputation score threshold and the resource threshold.

3. The AI-driven blockchain hybrid consensus dynamic hierarchical optimization method according to claim 1, characterized in that, The network parameters include average network latency, throughput, and system load rate; The performance parameters are obtained based on the network parameters, and a performance threshold is preset. If the performance parameters meet the performance threshold, the hierarchical structure adjustment is automatically triggered. By calculating the payoff function of nodes participating in different levels using a game theory model based on dynamic weight allocation, nodes are guided to rationally choose consensus levels.

4. The AI-driven blockchain hybrid consensus dynamic hierarchical optimization method according to claim 1, characterized in that, The network matching model includes a CNN-Transformer hybrid neural network, and the network node data includes a network topology matrix, node reputation feature vectors, and load time series. The probability distribution and key parameter adjustment amounts of the optimal consensus combination are obtained through the following steps: The network topology features are extracted using CNN convolutional layers, and the temporal dependencies of the load time series are captured using a Transformer encoder. By fusing spatial and temporal features through a fully connected layer, the consensus combination probability distribution and parameter adjustment amount are output, and the acceleration layer and the base layer are dynamically expanded or shrunk. The optimal consensus combination is selected based on the probability distribution. The optimal consensus combination includes Proof-of-Stake and Practical Byzantine Fault Tolerance, Proof-of-Stake and Zero-Knowledge Proof, and RAFT or Directed Acyclic Graph Asynchronous Consensus.

5. The AI-driven blockchain hybrid consensus dynamic hierarchical optimization method according to claim 1, characterized in that, Also includes: The sandbox isolation mechanism is a container-based isolation mechanism that allocates an independent Docker container to each contract execution instance, limits its CPU, memory, and network bandwidth resources, and monitors abnormal contract execution behavior in real time.

6. The AI-driven blockchain hybrid consensus dynamic hierarchical optimization method according to claim 1, characterized in that, Also includes: When signs of a 51% attack are detected, the current consensus mode is switched and the node cleaning process is initiated. Identify abnormal nodes and migrate them to the shadow layer for observation. During this period, restrict the abnormal nodes' communication permissions with the main network and set a preset time threshold. If no abnormality occurs within the time threshold, restore their permissions.

7. The AI-driven blockchain hybrid consensus dynamic hierarchical optimization method according to claim 1, characterized in that, Also includes: Network nodes generate Schnorr signature commitment values ​​that include reputation ratings; The verification network nodes only verify the validity of the proof and do not obtain the original score data.

8. An AI-driven blockchain hybrid consensus dynamic hierarchical optimization system, characterized in that, include: The node election module dynamically elects network nodes based on the node's historical block production success rate, node reputation score, and network communication quality, using the entropy weight algorithm and the approximation ideal solution sorting algorithm to obtain super nodes that form the acceleration layer, and the remaining network nodes that form the base layer. The parameter acquisition module monitors and extracts network parameters in real time, calculates hierarchical weights and node load factors, and constructs network node data based on network parameters, hierarchical weights and node load factors. The network parameters include average network latency, throughput and system load rate. The consensus strategy module constructs a network matching model, obtains the probability distribution and key parameter adjustment amount of the optimal consensus combination based on the network matching model and network node data, and then forms a consensus strategy. The network matching model includes a neural network model. The acceleration node module uses smart contracts to store high-frequency access data in an in-memory database and archive low-frequency historical data to a distributed storage system. It obtains the call complexity based on the code-related parameters of the smart contract, and then dynamically allocates acceleration nodes to the smart contract, and allocates an independent running environment through a sandbox isolation mechanism. The reputation feedback module updates the node reputation score based on block production behavior and Byzantine fault tolerance test results. It verifies the node reputation level through zero-knowledge proof and node reputation score to obtain trusted nodes and feeds the trusted nodes back to the network node dynamic election. This involves using smart contracts to store frequently accessed data in an in-memory database and archive low-frequency historical data to a distributed storage system. The call complexity is determined based on the smart contract's code parameters, and acceleration nodes are then dynamically allocated to the smart contract. This process includes the following steps: Preset a high-frequency threshold and migrate contract state data with read / write frequency that meets the threshold to the LevelDB in-memory database; A low-frequency threshold is preset, and historical data that meets the low-frequency threshold is archived to the IPFS distributed storage system; The depth of nested loops in the code is used to reflect the nesting level complexity of the code; the number of function calls is used to reflect the frequency of interactions during code execution; and the historical execution time is used to reflect the resource consumption level during actual operation. Based on the contract complexity model, the call complexity is obtained, as follows: in, Indicates the complexity of the call. The depth of nested functions. For the number of function calls, For historical execution duration, , , Indicates a parameter.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 7.

10. An AI-driven blockchain hybrid consensus dynamic hierarchical optimization device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Ai-based blockchain hybrid consensus

    CN112445612A

  • Consensus efficiency optimization method and system

    CN118118188A