Blockchain regulatory contract construction method and blockchain system based on RegLang
Through the blockchain regulatory contract construction method based on RegLang, the problems of high threshold for smart contract programming language and incomplete regulatory contract operation mechanism in the existing technology are solved, and the digital expression of regulatory rules and real-time supervision of business contract transactions are realized.
Patent Information
- Application Number
- CN202210420316.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-21
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2042-04-21
AI Technical Summary
It is difficult for existing technology to effectively use smart contracts to digitize regulatory rules, and it faces the problems of high threshold for programming languages, unsuitable regulatory rules writing, and imperfect regulatory contract operation mechanisms.
The blockchain regulatory contract construction method based on RegLang is adopted, and regulatory contracts are written through the RegLang language, and the expression form and execution process of regulatory rules are defined to realize the digital expression and real-time supervision of regulatory rules.
The digital expression of regulatory rules is realized, so that regulatory rules operate on the blockchain in the form of regulatory contracts, and improve the real-time regulatory capabilities of business contract transactions.
Smart Images

Figure CN114780072B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain regulatory contract construction method and a blockchain system based on RegLang. Background Art
[0002] The digitization of regulatory rules is one of the core technical issues that regulatory technology needs to solve, and it is an important foundation for the application of regulatory technology. Digital regulatory rules are based on technical standards and code protocols as the basic framework, which are used to constrain regulatory behavior and regulate the compliance behavior of regulated entities. To a certain extent, they have the function of legal regulation. Since blockchain has the characteristics of information sharing, immutability, transparency and trustworthiness, and the smart contracts on the blockchain can be automatically executed, blockchain can become one of the best ways to implement regulatory technology. On the one hand, blockchain can be used as a data sharing and exchange platform between regulatory authorities and regulated entities. On the other hand, smart contracts are the best carrier for the digitization of regulatory rules. Regulatory authorities can use smart contracts to effectively supervise financial businesses and improve the real-time and penetration of supervision.
[0003] However, the research on digitalizing regulatory rules through smart contracts is still in its early stages, and the use of smart contracts for regulation has not yet been widely used. It mainly faces the following challenges:
[0004] (1) Design of smart contract programming languages for regulation. Existing smart contract programming languages are mainly designed to implement arbitrary business logic and are usually Turing-complete general-purpose languages. Most of these languages have high entry barriers and are difficult to use in the field of regulatory technology. Although researchers have proposed some design solutions for domain-specific languages, they are mainly designed for financial business and are not suitable for writing regulatory rules. Existing modeling languages and other programming languages suitable for regulatory and compliance applications are also difficult to introduce into the blockchain, and it is impossible to use existing languages to write regulatory contracts on the blockchain.
[0005] (2) The operating mechanism of the regulatory contract. Through the regulatory-oriented smart contract programming language, digital regulatory rules can be implemented, so that the regulatory rules can run on the blockchain in the form of regulatory contracts. However, there is still a need to study the operating mechanism of the regulatory contract, including the execution method of the regulatory contract, the interaction mode between the regulatory contract and the business contract, and the regulatory blockchain architecture. Summary of the invention
[0006] The technical problem to be solved by the present invention is to provide a blockchain regulatory contract construction method and blockchain system based on RegLang in response to the deficiencies of the above-mentioned prior art, so as to use blockchain to construct regulatory contracts, realize the digitization of regulatory rules, and carry out real-time supervision of business contracts.
[0007] In order to solve the above technical problems, the technical solutions adopted by the present invention are as follows: on the one hand, the present invention provides a blockchain regulatory contract construction method based on RegLang, defines the expression form of the regulatory contract corresponding to the regulatory rules, and the execution process of the regulatory contract, so as to realize the digital expression of the regulatory rules on the blockchain system;
[0008] The expression form of the regulatory contract corresponding to the regulatory rules is as follows: the regulatory contract is written in RegLang language, including multiple knowledge base code blocks and rule code blocks, and each regulatory contract includes any number of knowledge base code blocks and any number of rule code blocks; each knowledge base code block or rule code block starts with the keyword knowledgebase or rule and a name, and ends with the keyword end; each knowledge base code block includes multiple knowledge, and the knowledge defined in the knowledge base code block can be used in the rule code block; each rule code block describes a regulatory rule, including a regulatory scope statement starting with reg and ending with a colon and any number of regulatory rule statements; the content of each regulatory rule statement is a logical expression in addition to the keywords; the value of the logical expression determines the truth or falsehood of the regulatory rule statement and the regulatory scope statement, and then determines the value of the regulatory rule;
[0009] The regulatory rule statements are divided into mandatory regulatory rule statements starting with the require keyword and prohibitive regulatory rule statements starting with the prohibit keyword; when the value of the logical expression of the regulatory rule statement is true, the value of the regulatory scope statement is true; when the value of the logical expression is false, the value of the regulatory scope statement is false; when the value of the logical expression is true, the value of the mandatory regulatory rule statement is true; when the value of the logical expression is false, the value of the mandatory regulatory rule statement is false; when the value of the logical expression is false, the value of the prohibitive regulatory rule statement is true; when the value of the logical expression is true, the value of the prohibitive regulatory rule statement is false; if the value of the regulatory scope statement is false, the value of the regulatory rule is true; if the value of the regulatory scope statement is true, then: if the values of all regulatory rule statements are true, the value of the regulatory rule is true; if the values of any one or more regulatory rule statements are false, the value of the regulatory rule is false;
[0010] The grammatical rules of the RegLang language are:
[0011] The RegLang language supports basic data types, supporting numeric arrays and string arrays; RegLang supports four types of operators: arithmetic operators, member operators, comparison operators, and logical operators; the RegLang language provides four groups of built-in functions: (1) at_least() and at_most(): these two functions are used to calculate whether there are at least or at most a number of elements in an array that satisfy a logical expression. Both functions have two parameters: the first parameter is a numeric value, and the second parameter is a logical expression. The left side of the expression must be an array; (2) any_item() and all_items(): these two functions calculate whether there are elements in an array that satisfy a logical expression or whether any element in an array satisfies a logical expression. Both functions have only one parameter, which is a logical expression. The left side of the expression must be an array; (3) length(): this function is used to calculate the number of elements in an array. The function has only one parameter of array type; (4) count(): this function is used to calculate the number of true expressions in the parameter. The function has any number of parameters, each of which is a logical expression. The function returns the number of true expressions.
[0012] The execution process of the regulatory contract is as follows:
[0013] Step S1, parsing the regulatory contract into an abstract syntax tree;
[0014] Step S2: Analyze the source code of the business contract to obtain the storage layout of the corresponding business contract, that is, the key of the variables in the business contract when they are actually stored in the blockchain state database;
[0015] Step S3: Execute each rule code block of the regulatory contract in turn to verify whether the transaction of the business contract meets the requirements of the regulatory contract. During the execution of the regulatory contract, if it is necessary to read the variable status data of the business contract, connect to the state database of the blockchain and read the value of the key corresponding to the variable according to the storage layout of the business contract in step S2;
[0016] Step S4: If the execution results of all rule code blocks are true, the execution result of the regulatory contract is true, and the transaction of the business contract complies with the regulatory rules; if the execution results of any one or more rule code blocks are false, the execution result of the regulatory contract is false, and the transaction of the business contract does not comply with the regulatory rules.
[0017] On the other hand, the present invention also provides a blockchain system, which supports the operation of business contracts and regulatory contracts on the basis of the existing blockchain, so as to realize real-time supervision of business contracts through regulatory contracts;
[0018] The users of the blockchain system include ordinary users and regulatory users; all users can deploy business contracts, and only regulatory users can deploy regulatory contracts; business contracts are written in Solidity or other smart contract programming languages, and the deployment method is that the user publishes the binary code of the business contract to the blockchain system in the form of a transaction; regulatory contracts are written in RegLang, and the deployment method is that the regulatory user publishes the source code of the regulatory contract and the business contract address bound to the regulatory contract to the blockchain system in the form of a transaction; specifically, a regulatory contract can be bound to one or more business contracts, and different regulatory contracts can be bound to the same business contract at the same time.
[0019] The process of processing transactions in the blockchain system is as follows:
[0020] Step 1: Ordinary users send transactions to blockchain nodes and call business contracts;
[0021] Step 2: The blockchain accounting node packages the transaction into blocks, broadcasts them to all nodes in the blockchain system, and completes the consensus process of the blockchain system;
[0022] Step 3: The blockchain node executes the business contract according to the parameters in the transaction and generates a transaction read-write set;
[0023] Step 4: The blockchain node calls the regulatory contract corresponding to the business contract. If the execution result of the regulatory contract is true, the read-write set is written into the blockchain's state database; otherwise, the transaction is marked as invalid and the blockchain's state database is not changed.
[0024] The beneficial effect of adopting the above technical solution is that: the RegLang-based blockchain regulatory contract construction method and blockchain system provided by the present invention introduce regulatory contracts into the blockchain system, and design a new type of smart contract programming language RegLang to write regulatory contracts, which can enable regulatory rules to be digitally expressed in the form of smart contracts, and enable regulatory rules to run on the blockchain in the form of regulatory contracts, thereby realizing real-time supervision of business contract transactions. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 A grammatical rule diagram of RegLang provided by an embodiment of the present invention;
[0026] Figure 2 A schematic diagram of a blockchain system running support business contracts and regulatory contracts provided in an embodiment of the present invention;
[0027] Figure 3 A Solidity business contract example diagram provided by an embodiment of the present invention;
[0028] Figure 4A diagram showing an example of a RegLang regulatory contract provided by an embodiment of the present invention;
[0029] Figure 5 A transaction example diagram of a common user calling a business contract provided by an embodiment of the present invention;
[0030] Figure 6 This is a diagram of an example of a business contract transaction read-write set provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0031] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0032] In this embodiment, the blockchain regulatory contract construction method based on RegLang defines the expression form of the regulatory contract corresponding to the regulatory rules and the execution process of the regulatory contract to realize the digital expression of the regulatory rules on the blockchain system;
[0033] The expression form of the regulatory contract corresponding to the regulatory rules is as follows: the regulatory contract is written in RegLang language, including multiple knowledgebase code blocks and rule code blocks, and each regulatory contract includes any number of knowledgebase code blocks and any number of rule code blocks; each knowledgebase code block or rule code block starts with the keyword knowledgebase or rule and a name, and ends with the keyword end; each knowledgebase code block includes multiple pieces of knowledge, and the knowledge defined in the knowledgebase code block can be used in the rule code block; each rule code block describes a regulatory rule, including a regulatory scope statement starting with reg and ending with a colon and any number of regulatory rule statements (after the regulatory scope statement and before end, each line of code is a regulatory rule statement); the content of each regulatory rule statement is a logical expression in addition to the keywords; the value of the logical expression determines the truth or falsehood of the regulatory rule statement and the regulatory scope statement, and then determines the value of the regulatory rule;
[0034] The regulatory rule statements are divided into mandatory regulatory rule statements starting with the require keyword and prohibitive regulatory rule statements starting with the prohibit keyword; when the value of the logical expression of the regulatory rule statement is true, the value of the regulatory scope statement is true; when the value of the logical expression is false, the value of the regulatory scope statement is false; when the value of the logical expression is true, the value of the mandatory regulatory rule statement is true; when the value of the logical expression is false, the value of the mandatory regulatory rule statement is false; when the value of the logical expression is false, the value of the prohibitive regulatory rule statement is true; when the value of the logical expression is true, the value of the prohibitive regulatory rule statement is false; if the value of the regulatory scope statement is false, the value of the regulatory rule is true; if the value of the regulatory scope statement is true, then: if the values of all regulatory rule statements are true, the value of the regulatory rule is true; if the values of any one or more regulatory rule statements are false, the value of the regulatory rule is false;
[0035] In this embodiment, the grammatical rules of the RegLang language are as follows: Figure 1 As shown in the figure, the extension of the RegLang language source file is .rl. The RegLang source file contains any number of knowledgebase code blocks and rule code blocks. Each code block starts with the keyword knowledgebase or rule and the name of the code block, and ends with the keyword end. The order of interpreting the RegLang file is to interpret all the knowledgebase code blocks first, and then parse the rule code blocks in turn.
[0036] Each knowledge base can include multiple pieces of knowledge. The namespace of knowledge is the knowledge base in which it is located, which means that knowledge with the same name in different knowledge bases is different. Knowledge can be updated through the add() or del() function, or overwritten by redefinition. The add() and del() functions can accept numbers, strings, and arrays as parameters. When a duplicate value is added to knowledge, or a non-existent value is deleted from knowledge, the value will be skipped and will not cause an exception in the knowledge update. Unlike knowledge, a knowledge base with the same name will update the previous knowledge base instead of overwriting it.
[0037] The rule block maintains all supervision rules. A rule must contain a supervision scope and at least one require or prohibit statement. A require statement is satisfied when the expression evaluates to true; a prohibit statement is satisfied when the expression evaluates to false. The name of a rule block is not unique, and two rule blocks with the same name are both valid. Once a rule statement is not satisfied, no other statements and rules are evaluated.
[0038] At the same time, RegLang language supports single-line comments ( / / ) and multi-line comments ( / *...* / ).
[0039] RegLang supports basic data types such as numbers, strings, and Boolean values, as well as arrays of numbers and strings. RegLang is a weakly typed language. Regulatory experts do not need to declare the type of knowledge when defining it, and RegLang does not provide type conversion functions. RegLang's numbers only support unsigned integers, and the length of numbers is infinite. Numbers can be assigned to a piece of knowledge or used as constants in rule statements. RegLang's strings are surrounded by double quotes (""). Strings are case-insensitive, that is, "ABC", "abc", and "AbC" are the same. Strings can be assigned to a piece of knowledge or used as constants in rule statements. RegLang's Boolean values can be true and false. Boolean values can be assigned to a piece of knowledge or used as constants in rule statements. RegLang only supports arrays of numbers and string arrays, and does not support mixed arrays. Arrays can only be assigned to one piece of knowledge. Knowledge in RegLang is similar to variables in procedural and object-oriented programming languages. Knowledge can be defined and updated in the knowledge base code block and used in the rule code block.
[0040] RegLang can also use blockchain-related variables in rule code blocks, including transaction-related variables and contract-related variables. Transaction-related variables include tx.from, tx.to, tx.function, tx.readset(xxx).yyy, tx.readset(xxx).yyy, and tx.args.yyy, where xxx represents the contract address and yyy represents the variable name in Solidity. Contract-related variables include contract(xxx).name, contract(xxx).owner, and contract(xxx).state.yyy, where xxx represents the contract address and yyy represents the variable name in Solidity.
[0041] RegLang supports four types of operators: arithmetic operators, member operators, comparison operators, and logical operators, with priorities from high to low;
[0042] Arithmetic operators in RegLang can accept string values as parameters and perform automatic type conversion. RegLang supports decimal and hexadecimal strings (hexadecimal strings must start with "0x"), which means that 10+"0xa"+"10" is legal. Arithmetic operators are operators used to perform common mathematical operations on values. Unlike arithmetic operators in Solidity, since there is no limit on the length of values in RegLang, operations will not overflow.
[0043] RegLang does not support floating point numbers, so division in RegLang is floored (for example, 5 / 3 is 1). RegLang does not support negative numbers, so if the mathematical result of a subtraction is a negative number, the result of the expression is 0 (for example, 1-2 is 0).
[0044] The member operator in is used to check whether the value of a constant or a variable is in a knowledge. The right side of the operator in must be a knowledge of array type.
[0045] Comparison operators are used to compare two numbers or strings.
[0046] Similar to arithmetic operators, comparison operators also support automatic type conversion, that is, 10 == "10", 10 == "0xa", and "10" == "0xa" all produce true results. Strings in RegLang are case-insensitive, so "abc" == "ABC" produces true results.
[0047] Logical operators are used to combine logical expressions. Because multiple negations are often confusing to non-developers, RegLang does not support "not" as an operator. Instead, RegLang uses require and prohibit statements to implement logical "not", avoiding deep nesting of negations and making it easier and less error-prone to write rules.
[0048] In addition to the above operators, to make rule writing more convenient and flexible, RegLang also provides four groups of built-in functions: (1) at_least() and at_most(): These two functions are used to calculate whether there are at least or at most a number of elements in an array that satisfy a logical expression. Both functions have two parameters: the first parameter is a numeric value, and the second parameter is a logical expression. The left side of the expression must be an array. (2) any_item() and all_items(): These two functions calculate whether there are elements in an array that satisfy a logical expression or whether any element in an array satisfies a logical expression. Both functions have only one parameter, which is a logical expression. The left side of the expression must be an array. (3) length(): This function is used to calculate the number of elements in an array. The function has only one parameter of array type. (4) count(): This function is used to calculate the number of true expressions in the parameter. The function has any number of parameters, each of which is a logical expression. The function returns the number of true expressions.
[0049] The execution process of the regulatory contract is as follows:
[0050] Step S1, parsing the regulatory contract into an abstract syntax tree;
[0051] Step S2: Analyze the source code of the business contract to obtain the storage layout of the corresponding business contract, that is, the key of the variables in the business contract when they are actually stored in the blockchain state database;
[0052] Step S3: Execute each rule code block of the regulatory contract in turn to verify whether the transaction of the business contract meets the requirements of the regulatory contract. During the execution of the regulatory contract, if it is necessary to read the variable status data of the business contract, connect to the state database of the blockchain and read the value of the key corresponding to the variable according to the storage layout of the business contract in step S2;
[0053] Step S4: If the execution results of all rule code blocks are true, the execution result of the regulatory contract is true, and the transaction of the business contract complies with the regulatory rules; if the execution results of any one or more rule code blocks are false, the execution result of the regulatory contract is false, and the transaction of the business contract does not comply with the regulatory rules.
[0054] A blockchain system that supports the operation of business contracts and regulatory contracts based on the existing blockchain to achieve real-time supervision of business contracts through regulatory contracts, such as Figure 2 As shown;
[0055] The users of the blockchain system include ordinary users and regulatory users; all users can deploy business contracts, and only regulatory users can deploy regulatory contracts; business contracts are written in Solidity or other smart contract programming languages, and the deployment method is that the user publishes the binary code of the business contract to the blockchain system in the form of a transaction; regulatory contracts are written in RegLang, and the deployment method is that the regulatory user publishes the source code of the regulatory contract and the business contract address bound to the regulatory contract to the blockchain system in the form of a transaction; specifically, a regulatory contract can be bound to one or more business contracts, and different regulatory contracts can be bound to the same business contract at the same time.
[0056] The process of processing transactions in the blockchain system is as follows:
[0057] Step 1: Ordinary users send transactions to blockchain nodes and call business contracts;
[0058] Step 2: The blockchain accounting node packages the transaction into blocks, broadcasts them to all nodes in the blockchain system, and completes the consensus process of the blockchain system;
[0059] Step 3: The blockchain node executes the business contract according to the parameters in the transaction and generates a transaction read-write set;
[0060] Step 4: The blockchain node calls the regulatory contract corresponding to the business contract. If the execution result of the regulatory contract is true, the read-write set is written into the blockchain's state database; otherwise, the transaction is marked as invalid and the blockchain's state database is not changed.
[0061] In this embodiment, Figure 3 The following is an example of a business contract written in Solidity. Its main function is to define an asset and support transfer, query and other functions. Figure 4 The following is a regulatory contract instance written in RegLang corresponding to the business contract instance. The first three lines of code in the instance add a knowledge blacklist to the black knowledge base, and the other codes create a rule CheckTransfer. In the rule part, line 6 indicates that the transaction that calls the transfer function in the EIP20 contract will be checked; line 7 is a mandatory regulatory rule statement, indicating that the regulatory rule requires that the value of the transaction parameter _value should not be greater than 1000000; line 8 is a prohibitive statement, indicating that if the initiator of the transaction or the recipient of the transfer is in the blacklist, the transaction will be rejected by the regulatory contract.
[0062] In this embodiment, the process of blockchain system processing transactions is as follows:
[0063] Step 1: Ordinary users send the following to the blockchain node: Figure 5The transaction shown in the figure calls Figure 3 The business contract shown;
[0064] Step 2: The blockchain accounting node packages the transaction into blocks, broadcasts them to all nodes in the blockchain system, and completes the consensus process of the blockchain system;
[0065] Step 3: Blockchain nodes are based on Figure 5 The parameters in the transaction shown execute the business contract and generate a transaction read-write set, such as Figure 6 As shown;
[0066] Step 4: Blockchain node calls Figure 4 The supervision contract shown, the execution result of the supervision contract is true, and the read-write set is written to the state database of the blockchain.
[0067] Among them, the execution process of the supervision contract in step 4 is as follows:
[0068] Step S1: Figure 4 The regulatory contract shown is parsed into an abstract syntax tree;
[0069] Step S2: Analyze the source code of the business contract to obtain the storage layout of the corresponding business contract, that is, the key of the variables in the business contract when they are actually stored in the blockchain state database, where the key corresponding to balances[0x5929EBA30850986dE6F93397A86f9B80901896e8] is 0xb25d917326bbb11780c75cb17c3902fdd 3325bcfb75eb4c1d2e41d8fabe4a26c, balances[0x84C7768aC1Cd6d07FCA1e2BC4C3551510F6E4ABC] corresponds to the key 0x197b7f4442862bd651f49aa6256f2e268835f42a82c8daa336e3c15f4837830f;
[0070] Step S3, execute each rule of the regulatory contract in turn. In this embodiment, the knowledge base black is executed first, and then the regulatory rule CheckTransfer is executed. When the regulatory rule CheckTransfer is executed, the execution result of the regulatory scope statement in line 6 is true, the execution result of the mandatory statement in line 7 is true, and the execution result of the prohibitory statement in line 8 is true, so the execution result of the regulatory rule is true.
[0071] Step S4: The supervision contract has only one supervision rule CheckTransfer, and its execution result is true, so the execution result of the supervision contract is true.
[0072] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some or all of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope defined by the claims of the present invention.
Claims
1. A method for constructing a blockchain regulatory contract based on RegLang, characterized in that: Define the expression form of the regulatory contract corresponding to the regulatory rules, as well as the execution process of the regulatory contract, so as to realize the digital expression of the regulatory rules on the blockchain system; The expression form of the regulatory contract corresponding to the regulatory rules is as follows: the regulatory contract is written in RegLang language, including multiple knowledge base code blocks and rule code blocks, and each regulatory contract includes any number of knowledge base code blocks and any number of rule code blocks; each knowledge base code block or rule code block starts with the keyword knowledgebase or rule and a name, and ends with the keyword end; each knowledge base code block includes multiple knowledge, and the knowledge defined in the knowledge base code block can be used in the rule code block; each rule code block describes a regulatory rule, including a regulatory scope statement starting with reg and ending with a colon and any number of regulatory rule statements; the content of each regulatory rule statement is a logical expression in addition to the keywords; the value of the logical expression determines the truth or falsehood of the regulatory rule statement and the regulatory scope statement, and then determines the value of the regulatory rule; The execution process of the regulatory contract is as follows: Step S1, parsing the regulatory contract into an abstract syntax tree; Step S2: Analyze the source code of the business contract to obtain the storage layout of the corresponding business contract, that is, the key of the variables in the business contract when they are actually stored in the blockchain state database; Step S3: Execute each rule code block of the regulatory contract in turn to verify whether the transaction of the business contract meets the requirements of the regulatory contract. During the execution of the regulatory contract, if it is necessary to read the variable status data of the business contract, connect to the state database of the blockchain and read the value of the key corresponding to the variable according to the storage layout of the business contract in step S2; Step S4: If the execution results of all rule code blocks are true, the execution result of the regulatory contract is true, and the transaction of the business contract complies with the regulatory rules; if the execution results of any one or more rule code blocks are false, the execution result of the regulatory contract is false, and the transaction of the business contract does not comply with the regulatory rules.
2. The method for constructing a blockchain regulatory contract based on RegLang according to claim 1, characterized in that: The regulatory rule statements are divided into mandatory regulatory rule statements starting with the require keyword and prohibitive regulatory rule statements starting with the prohibit keyword; when the value of the logical expression of the regulatory rule statement is true, the value of the regulatory scope statement is true; when the value of the logical expression is false, the value of the regulatory scope statement is false; when the value of the logical expression is true, the value of the mandatory regulatory rule statement is true; when the value of the logical expression is false, the value of the mandatory regulatory rule statement is false; when the value of the logical expression is false, the value of the prohibitive regulatory rule statement is true; when the value of the logical expression is true, the value of the prohibitive regulatory rule statement is false; if the value of the regulatory scope statement is false, the value of the regulatory rule is true; if the value of the regulatory scope statement is true, then: if the values of all regulatory rule statements are true, the value of the regulatory rule is true; if the values of any one or more regulatory rule statements are false, the value of the regulatory rule is false.
3. The method for constructing a blockchain regulatory contract based on RegLang according to claim 1, characterized in that: The grammatical rules of the RegLang language are: The RegLang language supports basic data types, including numeric arrays and string arrays. RegLang supports four types of operators: arithmetic operators, member operators, comparison operators, and logical operators. The RegLang language provides four groups of built-in functions: (1) at_least() and at_most(): at_least() is used to calculate the number of elements in an array that satisfy a logical expression, and at_most() is used to calculate the number of elements in an array that satisfy a logical expression. Both at_least() and at_most() have two parameters: the first parameter is a numeric value, and the second parameter is a logical expression. The left side of the expression must be an array. (2) any_ item() and all_items(): any_item() is used to calculate whether there are elements in the array that satisfy the logical expression, and all_items() is used to calculate whether any element in the array satisfies the logical expression. Both any_item() and all_items() functions have only one parameter, which is a logical expression. The left side of the expression must be an array; (3) length(): This function is used to calculate the number of elements in an array. The function has only one parameter of array type; (4) count(): This function is used to calculate the number of true expressions in the parameter. The function has any number of parameters, each of which is a logical expression. The function returns the number of true expressions.
4. A blockchain system that supports the operation of a business contract and a supervision contract constructed by the RegLang-based blockchain supervision contract construction method of claim 1, so as to realize real-time supervision of the business contract through the supervision contract, characterized in that: The users of the blockchain system include ordinary users and regulatory users; all users can deploy business contracts, and only regulatory users can deploy regulatory contracts; business contracts are written in the smart contract programming language, and the deployment method is that the user publishes the binary code of the business contract to the blockchain system in the form of a transaction; regulatory contracts are written in RegLang, and the deployment method is that the regulatory user publishes the source code of the regulatory contract and the business contract address bound to the regulatory contract to the blockchain system in the form of a transaction; specifically, a regulatory contract can be bound to one or more business contracts, and different regulatory contracts can be bound to the same business contract at the same time.
5. A blockchain system according to claim 4, characterized in that: The process of processing transactions in the blockchain system is as follows: Step 1: Ordinary users send transactions to blockchain nodes and call business contracts; Step 2: The blockchain accounting node packages the transaction into blocks, broadcasts them to all nodes in the blockchain system, and completes the consensus process of the blockchain system; Step 3: The blockchain node executes the business contract according to the parameters in the transaction and generates a transaction read-write set; Step 4: The blockchain node calls the supervision contract corresponding to the business contract. If the execution result of the supervision contract is true, the read-write set is written into the state database of the blockchain. Otherwise, the transaction is marked as invalid and the blockchain state database is not changed.
Citation Information
Patent Citations
Method and platform for realizing GMP / GSP automatic supervision based on block chain
CN110956476A
Intelligent contract monitoring method and system for blockchain supervision
CN111369221A