Block generation method and device, storage medium and electronic equipment
By obtaining blockchain network state parameters to adjust block generation configuration information and dynamically optimizing block storage capacity, the performance problem caused by pre-setting block capacity in the blockchain network is solved, and the transaction processing speed and reliability of the network are improved.
Patent Information
- Application Number
- CN202111397226.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-23
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2041-11-23
AI Technical Summary
In existing technologies, the pre-setting of block capacity in blockchain networks affects network performance, leading to frequent input/output operations by nodes or slow transaction processing speed, and increasing the possibility of accounting failure.
By acquiring the state parameters of the blockchain network, block generation configuration information is determined, block storage capacity is adjusted, and block capacity configuration rules are dynamically adjusted based on state parameters and relationships to optimize block generation frequency and node input/output frequency.
Dynamically adjusting block size optimizes blockchain network performance, reduces node input/output frequency, increases transaction processing speed, and reduces the risk of accounting failures.
Smart Images

Figure CN114036237B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of blockchain technology, and more specifically, to a block generation method, apparatus, storage medium, and electronic device. Background Technology
[0002] Blockchain technology is a technology that enables the collective maintenance of a reliable database in a decentralized and trustless manner. In a blockchain network, even mutually untrusted nodes can easily verify data and reach consensus through a certain consensus mechanism. Therefore, blockchain technology can significantly reduce the trust costs between multiple nodes, thus having broad application scenarios and value in cross-border payments, credential services, and the financial sector.
[0003] When building a blockchain network, relevant network parameters, such as block size, can be pre-defined. However, this approach may also affect the performance of the blockchain network. Summary of the Invention
[0004] The purpose of this disclosure is to provide a block generation method, apparatus, storage medium, and electronic device to solve the aforementioned related technical problems.
[0005] To achieve the above objectives, according to a first aspect of the present disclosure, a block generation method is provided, comprising:
[0006] Obtain block generation configuration information, which is determined based on the state parameters of the blockchain network;
[0007] The block storage capacity is determined based on the block generation configuration information.
[0008] Based on the block storage capacity, the data to be stored in the blockchain is packaged into blocks.
[0009] Optionally, obtaining the block generation configuration information includes:
[0010] Obtain the state parameters of the blockchain network to obtain the first state parameter, which includes one or more of the following: transaction concurrency, throughput, transaction success rate, and response time.
[0011] The first state type of the blockchain network is determined based on the first state parameter;
[0012] Based on the first state type, and the relationship between the state type of the blockchain network, the block capacity configuration rules, and the adjustment gain parameters, the target block capacity configuration rules are determined.
[0013] The block generation configuration information includes the target block capacity configuration rules.
[0014] Optionally, determining the target block capacity configuration rule based on the first state type and the correlation between the blockchain network state type, block capacity configuration rules, and adjustment gain parameters includes:
[0015] Based on the first state type and the association relationship, determine multiple candidate block capacity configuration rules corresponding to the first state type and adjustment gain parameters corresponding to each candidate capacity configuration rule;
[0016] The candidate block capacity configuration rule with the largest adjusted gain parameter is used as the target block capacity configuration rule.
[0017] Optionally, after packaging the data to be stored in the blockchain into blocks, the method further includes:
[0018] The state parameters of the blockchain network are obtained again to obtain the second state parameters;
[0019] The second state type of the blockchain network is determined based on the second state parameter;
[0020] The target adjustment gain value is calculated based on the first state type, the second state type, and the correlation relationship.
[0021] The adjustment gain parameters corresponding to the first state type and the target block capacity configuration rule in the association relationship are updated according to the target adjustment gain value.
[0022] Optionally, calculating the target adjustment gain value using the first state type, the second state type, and the correlation includes:
[0023] By querying the aforementioned relationships, the initial adjustment gain parameter corresponding to the first state type, the first state type, and the adjustment gain parameter corresponding to the target block capacity configuration rule are obtained;
[0024] The target adjustment gain value r′ is calculated using the following formula:
[0025] r′=Q(s,a)+α(r+γmaxQ(s′,a′)-Q(s,a))
[0026]
[0027] Wherein, Q(s,a) is the initial adjustment gain parameter, α is the learning rate, γ is the discount rate, maxQ(s′,a′) is the adjustment gain parameter corresponding to the first state type and the target block capacity configuration rule, r is the incentive value for the blockchain network to switch from the first state type to the second state type, s is the description value of the first state type, and s′ is the description value of the second state type.
[0028] Optionally, it also includes:
[0029] Based on the previously obtained historical block generation configuration information, the block capacity configuration rule in the historical block generation configuration information is used as the initial block capacity configuration rule corresponding to the first state type.
[0030] By querying the association relationship based on the initial block capacity configuration rule and the first state type, the initial adjustment gain parameter corresponding to the initial block capacity configuration rule and the first state type is obtained;
[0031] In the absence of historical block generation configuration information, or when the initial adjustment gain parameter is less than a preset threshold, a block capacity configuration rule is randomly determined as the target block capacity configuration rule.
[0032] Before determining the target block capacity configuration rule based on the first state type and the correlation between the blockchain network state type, block capacity configuration rules, and adjustment gain parameters, the method further includes:
[0033] The initial adjustment gain parameter is determined to be greater than the preset threshold.
[0034] Optionally, it also includes:
[0035] The state parameters of the blockchain network are linearly mapped to obtain the mapping result;
[0036] The state description value of the blockchain network is calculated based on the mapping result;
[0037] The state description value is divided into multiple range intervals, wherein each range interval corresponds to a state type of the blockchain network;
[0038] Determining the first state type of the blockchain network based on the first state parameter includes:
[0039] Calculate the target state description value based on the first state parameter;
[0040] The first state type of the blockchain network is determined based on the range of the target state description value.
[0041] According to a second aspect of the present disclosure, a block generation apparatus is provided, comprising:
[0042] The first acquisition module is used to acquire block generation configuration information, which is determined based on the state parameters of the blockchain network.
[0043] A storage capacity determination module is used to determine the storage capacity of a block based on the block generation configuration information;
[0044] The block packaging module is used to package the data to be stored in the blockchain into blocks based on the block storage capacity.
[0045] Optionally, the first acquisition module includes:
[0046] The first acquisition submodule is used to acquire the state parameters of the blockchain network and obtain the first state parameters, which include one or more of the following: transaction concurrency, throughput, transaction success rate, and response time.
[0047] The first determining submodule is used to determine the first state type of the blockchain network based on the first state parameter;
[0048] The second determining submodule is used to determine the target block capacity configuration rule based on the first state type and the correlation between the state type of the blockchain network, the block capacity configuration rule, and the adjustment gain parameter.
[0049] The block generation configuration information includes the target block capacity configuration rules.
[0050] Optionally, the second determining submodule includes:
[0051] The first determining subunit is used to determine, based on the first state type and the association relationship, multiple candidate block capacity configuration rules corresponding to the first state type and adjustment gain parameters corresponding to each candidate capacity configuration rule;
[0052] The first execution subunit is used to select the candidate block capacity configuration rule with the largest adjusted gain parameter as the target block capacity configuration rule.
[0053] Optionally, the device further includes:
[0054] The second acquisition module is used to acquire the state parameters of the blockchain network again after the block packaging module packages the data to be stored in the blockchain into blocks, and obtain the second state parameters.
[0055] The first determining module is used to determine the second state type of the blockchain network based on the second state parameter;
[0056] The first calculation module is used to calculate the target adjustment gain value based on the first state type, the second state type, and the correlation relationship.
[0057] The first update module is used to update the adjustment gain parameters corresponding to the first state type and the target block capacity configuration rule in the association relationship according to the target adjustment gain value.
[0058] Optionally, the first computing module includes:
[0059] The query submodule is used to query the association relationship to obtain the initial adjustment gain parameter corresponding to the first state type, the first state type, and the adjustment gain parameter corresponding to the target block capacity configuration rule;
[0060] The first calculation submodule is used to calculate the target adjustment gain value r′ using the following formula:
[0061] r′=Q(s,a)+α(r+γmaxQ(s′,a′)-Q(s,a))
[0062]
[0063] Wherein, Q(s,a) is the initial adjustment gain parameter, α is the learning rate, γ is the discount rate, maxQ(s′,a′) is the adjustment gain parameter corresponding to the first state type and the target block capacity configuration rule, r is the incentive value for the blockchain network to switch from the first state type to the second state type, s is the description value of the first state type, and s′ is the description value of the second state type.
[0064] Optionally, it also includes:
[0065] The first execution module is used to generate configuration information based on the previously obtained historical blocks and use the block capacity configuration rule in the historical block generation configuration information as the initial block capacity configuration rule corresponding to the first state type.
[0066] The query module is used to query the association relationship based on the initial block capacity configuration rule and the first state type to obtain the initial adjustment gain parameter corresponding to the initial block capacity configuration rule and the first state type;
[0067] The second determining module is used to randomly determine the block capacity configuration rule as the target block capacity configuration rule when there is no historical block generation configuration information or the initial adjustment gain parameter is less than a preset threshold.
[0068] The device further includes:
[0069] The third determining module is used to determine that the initial adjusting gain parameter is greater than the preset threshold before the second determining submodule determines the target block capacity configuration rule based on the first state type and the correlation between the state type of the blockchain network, the block capacity configuration rule, and the adjustment gain parameter.
[0070] Optionally, it also includes:
[0071] The mapping module is used to linearly map the state parameters of the blockchain network to obtain the mapping result.
[0072] The second calculation module is used to calculate the state description value of the blockchain network based on the mapping result;
[0073] The second execution module is used to divide the state description value into multiple range intervals, wherein each range interval corresponds to a state type of the blockchain network.
[0074] The first determining submodule includes:
[0075] The second calculation submodule is used to calculate the target state description value based on the first state parameter;
[0076] The third determining submodule is used to determine the first state type of the blockchain network based on the range of the target state description value.
[0077] According to a third aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method described in any of the first aspects above.
[0078] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising:
[0079] A memory on which computer programs are stored;
[0080] A processor for executing the computer program in the memory to implement the steps of the method described in any of the first aspects above.
[0081] In the above technical solution, nodes in the blockchain network can obtain block generation configuration information determined based on the state parameters of the blockchain network, and determine the block storage capacity according to the block generation configuration information. In this way, the nodes can package the data to be uploaded to the chain according to the determined block storage capacity, thereby generating new blocks. Since the block generation configuration information is determined based on the state parameters of the blockchain network, the above technical solution can effectively adjust the block size according to the state of the blockchain network. For example, when the block generation frequency of the blockchain network is high, the capacity of a single block can be increased, thereby reducing the block generation frequency, and further reducing the input / output frequency of the nodes, thus optimizing the performance of the blockchain network.
[0082] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0083] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:
[0084] Figure 1 This is a flowchart illustrating a block generation method according to an exemplary embodiment of this disclosure.
[0085] Figure 2 This is a flowchart illustrating a block generation method according to an exemplary embodiment of this disclosure.
[0086] Figure 3 This is a flowchart illustrating the determination of the state type of a blockchain network as shown in an exemplary embodiment of this disclosure.
[0087] Figure 4 This is a flowchart illustrating a block generation method according to an exemplary embodiment of this disclosure.
[0088] Figure 5 This is a block diagram of a block generation apparatus shown in an exemplary embodiment of the present disclosure.
[0089] Figure 6 This is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure. Detailed Implementation
[0090] The specific embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit this disclosure.
[0091] Before introducing the block generation method, apparatus, storage medium, and electronic device provided in this disclosure, the application scenarios of this disclosure will first be introduced. Block capacity, as a parameter of the blockchain network, is usually preset by developers based on experience.
[0092] Block size has a significant impact on the performance of a blockchain network. For example, a smaller block size may result in faster block generation, leading to frequent input / output operations by the network's nodes and thus reducing node performance. Conversely, a larger block size may result in slower block generation, which in turn slows down transaction processing. Furthermore, a larger block size allows for larger data submissions during the accounting process, increasing the likelihood of accounting failures.
[0093] Therefore, this disclosure provides a block generation method. Figure 1 This is a flowchart of a block generation method shown in this disclosure, see reference. Figure 1 The method includes:
[0094] In step 11, the block generation configuration information is obtained.
[0095] The block generation configuration information is determined based on the state parameters of the blockchain network. Taking the method applied to a sorting node in a consortium blockchain as an example, the sorting node can obtain the state parameters of the blockchain network (such as response time, concurrency, etc.) and determine the block generation configuration information based on the obtained state parameters. In some implementation scenarios, the block generation configuration information can also be determined by other devices based on the state parameters of the blockchain network. In this case, step 11 may refer to the sorting node obtaining the block generation configuration information generated by other devices.
[0096] The block generation configuration information may include block capacity adjustment strategies, such as "increasing the block capacity by a first target value" or "decreasing the block capacity by a second target value," etc. Here, increasing the block capacity by a first target value may mean increasing the number of transactions that a single block can accommodate by a first target value, and decreasing the block capacity by a second target value may mean decreasing the number of transactions that a single block can accommodate by a second target value.
[0097] Thus, in step 12, the block storage capacity is determined based on the block generation configuration information.
[0098] For example, if the current block storage capacity is A, and the block generation configuration information includes "increase the block capacity by 10", the sorting node can determine the new block storage capacity as A+10. Of course, in some implementation scenarios, the block generation configuration information may also include block storage capacity information. In this case, the sorting node or other execution devices of this method can directly apply the block storage capacity from the block generation configuration information.
[0099] In step 13, based on the block storage capacity, the data to be stored in the blockchain is packaged into blocks.
[0100] By employing the above technical solution, nodes in a blockchain network can obtain block generation configuration information determined based on the blockchain network's state parameters, and determine the block storage capacity according to this configuration information. In this way, the nodes can package the data to be uploaded to the chain according to the determined block storage capacity, thereby generating new blocks. Since the block generation configuration information is determined based on the blockchain network's state parameters, the above technical solution can effectively adjust the block size according to the blockchain network's state. For example, when the blockchain network's block generation frequency is high, the capacity of a single block can be increased, thereby reducing the block generation frequency, and consequently reducing the node's input / output frequency, thus optimizing the blockchain network's performance.
[0101] Figure 2 This is a flowchart of a block generation method shown in this disclosure, such as... Figure 2 As shown, the method is in Figure 1 Based on this, obtaining the block generation configuration information (step 11) includes:
[0102] In S111, the state parameters of the blockchain network are obtained, resulting in the first state parameter.
[0103] The first state parameter includes one or more of the following: transaction concurrency, throughput, transaction success rate, and response time. In some implementation scenarios, depending on application requirements, the state parameter may also include other parameters in the blockchain network, and this disclosure does not impose any restrictions on this.
[0104] In S112, the first state type of the blockchain network is determined based on the first state parameter.
[0105] Figure 3 This disclosure presents a flowchart for determining the state type of a blockchain network. In some implementation scenarios, the state type of a blockchain network can be determined through the following steps.
[0106] S31, linearly map the state parameters of the blockchain network to obtain the mapping result.
[0107] For example, the state parameters of a blockchain network can include transaction concurrency, throughput, transaction success rate, and response time. In this case, a linear mapping can be performed as follows:
[0108]
[0109]
[0110]
[0111]
[0112] Where b is the number of concurrent transactions, x1 is the mapping result of the number of concurrent transactions, p is the throughput, x2 is the mapping result of the throughput, k is the transaction success rate, x3 is the mapping result of the transaction success rate, t is the response time, and x4 is the mapping result of the response time.
[0113] S32, calculate the state description value of the blockchain network based on the mapping result.
[0114] For example, a linear regression algorithm can be used to calculate the state description value using the mapping results x1, x2, x3, and x4. For instance, a function f(x) can be defined with the following expression:
[0115]
[0116] Where b is a constant term. Next, the values of w1, w2, w3, and w4 can be calculated using gradient descent. Here, the loss function J(w i ):
[0117]
[0118] Where, f(x) i y can be calculated based on the expression for the linear mapping and the expression for f(x) mentioned above. i System parameters characterizing the block size of a blockchain network include the number of concurrent transactions, throughput, transaction success rate, and response time for each group of transactions in the blockchain system, which can be represented by a corresponding parameter y. i value.
[0119] Next, we can find the partial derivative of w.
[0120]
[0121] Thus, w can be calculated by combining equations (1), (2), and (3). i The value of f(x) is obtained to obtain the linear relationship between f(x) and x1, x2, x3, and x4.
[0122]
[0123] In some implementation scenarios, the Sigmoid function can also be used to normalize f(x) to obtain the state description value f(x)'.
[0124]
[0125] S33, the state description value is divided into multiple range intervals, wherein each range interval corresponds to a state type of the blockchain network.
[0126] As an example, the relationship between the state type S of the blockchain network and the state description value f(x)' is as follows:
[0127]
[0128] The step of determining the first state type of the blockchain network based on the first state parameter (S112) includes:
[0129] The target state description value is calculated based on the first state parameter, and the first state type of the blockchain network is determined based on the range of the target state description value.
[0130] The calculation method for the target state description value is described in the above embodiment regarding S32, and will not be repeated here.
[0131] S113, based on the first state type and the correlation between the state type of the blockchain network, the block capacity configuration rules, and the adjustment gain parameters, determine the target block capacity configuration rules.
[0132] The block generation configuration information includes the target block capacity configuration rule. In some possible implementations, the block generation configuration information may also include the validity period of the target block capacity configuration rule, etc. This disclosure does not limit this.
[0133] In one possible implementation, determining the target block capacity configuration rule (S113) based on the first state type and the correlation between the blockchain network state type, block capacity configuration rules, and adjustment gain parameters includes:
[0134] Based on the first state type and the association relationship, determine multiple candidate block capacity configuration rules corresponding to the first state type and adjustment gain parameters corresponding to each candidate capacity configuration rule;
[0135] The candidate block capacity configuration rule with the largest adjusted gain parameter is used as the target block capacity configuration rule.
[0136]
[0137] Table 1
[0138] Table 1 illustrates the state type S, block capacity configuration rule A, and adjustment gain parameter Q (i.e., ...) of a blockchain network exemplarily disclosed in this disclosure. The relationship between m∈[1,5], n∈[1,11], where m and n are positive integers. The Q value... It can be used to describe the incentives obtained under a certain blockchain state after adopting a certain block capacity configuration rule. Larger representations using this block capacity configuration rule are beneficial to the state of the blockchain. Smaller representations using this block capacity configuration rule are detrimental to the blockchain state.
[0139] The implementation method of step S113 above will be described here with reference to Table 1. Assuming the first state type is type 0, the block capacity configuration rules corresponding to type 0 include five types: -10, -5, 0, 5, and 10, with corresponding Q values of... as well as Therefore, you can choose as well as The block capacity configuration rule corresponding to the largest value in the list is used as the target block capacity configuration rule. In this way, by applying the target block capacity configuration rule, a greater incentive can be obtained.
[0140] By employing the above technical solution, nodes in the blockchain network can obtain block generation configuration information determined based on the blockchain network's state parameters, and determine the block storage capacity according to this configuration information. In this way, the nodes can package the data to be uploaded to the chain according to the determined block storage capacity, thereby generating new blocks. Since the block generation configuration information is determined based on the blockchain network's state parameters, the above technical solution can effectively adjust the block size and optimize the blockchain network based on its state.
[0141] Figure 4 This is a flowchart of a block generation method shown in this disclosure, such as... Figure 4 As shown, the method is in Figure 1 Based on this, after packaging the data to be stored in the blockchain into blocks (step 13), the process further includes:
[0142] S14, obtain the state parameters of the blockchain network again to obtain the second state parameters. The second state parameters include one or more of the following: transaction concurrency, throughput, transaction success rate, and response time.
[0143] S15, determine the second state type of the blockchain network based on the second state parameter.
[0144] For methods on determining the state type of a blockchain network based on state parameters, please refer to [link / reference]. Figure 3 The embodiments described herein will not be repeated here for the sake of brevity.
[0145] S16, calculate the target adjustment gain value based on the first state type, the second state type, and the correlation relationship.
[0146] In one possible implementation, the target adjustment gain value can be calculated as follows:
[0147] By querying the aforementioned relationships, the initial adjustment gain parameter corresponding to the first state type, the first state type, and the adjustment gain parameter corresponding to the target block capacity configuration rule are obtained;
[0148] The target adjustment gain value r′ is calculated using the following formula:
[0149] r′=Q(s,a)+α(r+γmaxQ(s′,a′)-Q(s,a))
[0150]
[0151] Where Q(s,a) is the initial adjustment gain parameter, α is the learning rate, and γ is the discount rate. In specific implementations, the learning rate and the discount rate can be set according to application requirements. For example, in the example in Table 1, the learning rate can be preset to 0.15, and the discount rate can be preset to 0.965. maxQ(s′,a′) is the adjustment gain parameter corresponding to the first state type and the target block capacity configuration rule, r is the incentive value for the blockchain network to switch from the first state type to the second state type, and s is the descriptive value of the first state type. ′ This is the description value for the second state type.
[0152] Taking Table 1 as an example, if the first state type is 0, the initial adjustment gain parameter corresponding to the first state type is... The target block capacity configuration rule is -10 (corresponding to...) If the second state type is 5, then:
[0153]
[0154]
[0155] S17, update the adjustment gain parameters corresponding to the first state type and the target block capacity configuration rule in the association relationship according to the target adjustment gain value.
[0156] Using the above example, we can The value of is updated to r′.
[0157] By adopting the above technical solution, the block capacity can be dynamically adjusted according to the state of the blockchain network during operation, thus solving the problem of poor blockchain network performance caused by relying on manual experience to set block capacity values in related technologies. Furthermore, after adjusting the block capacity, the above technical solution can continuously monitor the adjustment result and calculate the adjustment gain, thereby continuously updating the adjustment gain parameters in the correlation relationship based on the calculated adjustment gain. In this way, the accuracy of block capacity control decisions can be improved.
[0158] The following is an illustrative description of the generation process of the association relationship. In some implementation scenarios, the association relationship may be in an initial state, for example, each adjustment gain parameter in the association relationship is 0.
[0159] In this case, the method further includes:
[0160] Based on the previously obtained historical block generation configuration information, the block capacity configuration rule in the historical block generation configuration information is used as the initial block capacity configuration rule corresponding to the first state type.
[0161] By querying the association relationship using the initial block capacity configuration rule and the first state type, the initial adjustment gain parameter corresponding to the initial block capacity configuration rule and the first state type is obtained.
[0162] It should be noted that the current state type of the blockchain network can be obtained by the blockchain network responding to the previous adjustment of the block capacity configuration rules. Therefore, based on the initial block capacity configuration rules in the previous historical block generation configuration information and the first state type, the correlation can be queried to obtain the initial adjustment gain parameter of the first state type.
[0163] Next, if there is no historical block generation configuration information, or if the initial adjustment gain parameter is less than a preset threshold, a block capacity configuration rule is randomly determined as the target block capacity configuration rule.
[0164] It should be noted that if there is no historical block generation configuration information or the initial adjustment gain parameter is less than a preset threshold, the association relationship can be determined to be in its initial state, at which point the adjustment gain parameter in the association relationship has low reference value. Therefore, a block capacity configuration rule can be randomly determined as the target block capacity configuration rule.
[0165] Since the initial adjustment gain parameter has low reference value when it is less than a preset threshold, the adjustment gain parameter in the correlation relationship has low reference value. Therefore, in one possible implementation, before determining the target block capacity configuration rule based on the first state type and the correlation relationship between the blockchain network state type, block capacity configuration rules, and adjustment gain parameters, the following steps are also included:
[0166] The initial adjustment gain parameter is determined to be greater than the preset threshold.
[0167] The aforementioned technical solution establishes a correlation between the state types of the blockchain network, block capacity configuration rules, and adjusted gain parameters. Based on this correlation and the state of the blockchain network, it enables decisions regarding the control of the current block capacity. This approach helps improve the performance of the blockchain network.
[0168] Based on the same inventive concept, this disclosure also provides a block generation apparatus. Figure 5 This is a block diagram of a block generation apparatus shown in this disclosure, with reference to... Figure 5 The device 500 includes:
[0169] The first acquisition module 501 is used to acquire block generation configuration information, which is determined based on the state parameters of the blockchain network.
[0170] Storage capacity determination module 502 is used to determine the block storage capacity based on the block generation configuration information;
[0171] The block packaging module 503 is used to package the data to be stored in the blockchain into blocks based on the block storage capacity.
[0172] In the above technical solution, nodes in the blockchain network can obtain block generation configuration information determined based on the state parameters of the blockchain network, and determine the block storage capacity according to the block generation configuration information. In this way, the nodes can package the data to be uploaded to the chain according to the determined block storage capacity, thereby generating new blocks. Since the block generation configuration information is determined based on the state parameters of the blockchain network, the above technical solution can effectively adjust the block size according to the state of the blockchain network. For example, when the block generation frequency of the blockchain network is high, the capacity of a single block can be increased, thereby reducing the block generation frequency, and further reducing the input / output frequency of the nodes, thus optimizing the performance of the blockchain network.
[0173] Optionally, the first acquisition module includes:
[0174] The first acquisition submodule is used to acquire the state parameters of the blockchain network and obtain the first state parameters, which include one or more of the following: transaction concurrency, throughput, transaction success rate, and response time.
[0175] The first determining submodule is used to determine the first state type of the blockchain network based on the first state parameter;
[0176] The second determining submodule is used to determine the target block capacity configuration rule based on the first state type and the correlation between the state type of the blockchain network, the block capacity configuration rule, and the adjustment gain parameter.
[0177] The block generation configuration information includes the target block capacity configuration rules.
[0178] Optionally, the second determining submodule includes:
[0179] The first determining subunit is used to determine, based on the first state type and the association relationship, multiple candidate block capacity configuration rules corresponding to the first state type and adjustment gain parameters corresponding to each candidate capacity configuration rule;
[0180] The first execution subunit is used to select the candidate block capacity configuration rule with the largest adjusted gain parameter as the target block capacity configuration rule.
[0181] Optionally, the device further includes:
[0182] The second acquisition module is used to acquire the state parameters of the blockchain network again after the block packaging module packages the data to be stored in the blockchain into blocks, and obtain the second state parameters.
[0183] The first determining module is used to determine the second state type of the blockchain network based on the second state parameter;
[0184] The first calculation module is used to calculate the target adjustment gain value based on the first state type, the second state type, and the correlation relationship.
[0185] The first update module is used to update the adjustment gain parameters corresponding to the first state type and the target block capacity configuration rule in the association relationship according to the target adjustment gain value.
[0186] Optionally, the first computing module includes:
[0187] The query submodule is used to query the association relationship to obtain the initial adjustment gain parameter corresponding to the first state type, the first state type, and the adjustment gain parameter corresponding to the target block capacity configuration rule;
[0188] The first calculation submodule is used to calculate the target adjustment gain value r′ using the following formula:
[0189] r′=Q(s,a)+α(r+γmaxQ(s′,a′)-Q(s,a))
[0190]
[0191] Wherein, Q(s,a) is the initial adjustment gain parameter, α is the learning rate, γ is the discount rate, maxQ(s′,a′) is the adjustment gain parameter corresponding to the first state type and the target block capacity configuration rule, r is the incentive value for the blockchain network to switch from the first state type to the second state type, s is the description value of the first state type, and s′ is the description value of the second state type.
[0192] Optionally, it also includes:
[0193] The first execution module is used to generate configuration information based on the previously obtained historical blocks and use the block capacity configuration rule in the historical block generation configuration information as the initial block capacity configuration rule corresponding to the first state type.
[0194] The query module is used to query the association relationship based on the initial block capacity configuration rule and the first state type to obtain the initial adjustment gain parameter corresponding to the initial block capacity configuration rule and the first state type;
[0195] The second determining module is used to randomly determine the block capacity configuration rule as the target block capacity configuration rule when there is no historical block generation configuration information or the initial adjustment gain parameter is less than a preset threshold.
[0196] The device further includes:
[0197] The third determining module is used to determine that the initial adjusting gain parameter is greater than the preset threshold before the second determining submodule determines the target block capacity configuration rule based on the first state type and the correlation between the state type of the blockchain network, the block capacity configuration rule, and the adjustment gain parameter.
[0198] Optionally, it also includes:
[0199] The mapping module is used to linearly map the state parameters of the blockchain network to obtain the mapping result.
[0200] The second calculation module is used to calculate the state description value of the blockchain network based on the mapping result;
[0201] The second execution module is used to divide the state description value into multiple range intervals, wherein each range interval corresponds to a state type of the blockchain network.
[0202] The first determining submodule includes:
[0203] The second calculation submodule is used to calculate the target state description value based on the first state parameter;
[0204] The third determining submodule is used to determine the first state type of the blockchain network based on the range of the target state description value.
[0205] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0206] According to a third aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method described in any of the first aspects above.
[0207] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising:
[0208] A memory on which computer programs are stored;
[0209] A processor for executing the computer program in the memory to implement the steps of the method described in any of the first aspects above.
[0210] Figure 6 This is a block diagram illustrating an electronic device 600 according to an exemplary embodiment. For example... Figure 6As shown, the electronic device 600 may include a processor 601 and a memory 602. The electronic device 600 may also include one or more of a multimedia component 603, an input / output (I / O) interface 604, and a communication component 605.
[0211] The processor 601 controls the overall operation of the electronic device 600 to complete all or part of the steps in the block generation method described above. The memory 602 stores various types of data to support the operation of the electronic device 600. This data may include, for example, instructions for any application or method operating on the electronic device 600, and application-related data such as contact data, sent and received messages, pictures, audio, video, etc. The memory 602 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. Multimedia component 603 may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in memory 602 or transmitted via communication component 605. The audio component also includes at least one speaker for outputting audio signals. I / O interface 604 provides an interface between processor 601 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. Communication component 605 is used for wired or wireless communication between the electronic device 600 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IoT, eMTC, or other 5G technologies, or combinations thereof, is not limited here. Therefore, the corresponding communication component 605 may include: a Wi-Fi module, a Bluetooth module, an NFC module, etc.
[0212] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the block generation method described above.
[0213] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the block generation method described above. For example, the computer-readable storage medium may be the memory 602 including the program instructions described above, which may be executed by the processor 601 of the electronic device 600 to complete the block generation method described above.
[0214] In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable device, the computer program having a code portion for performing the block generation method described above when executed by the programmable device.
[0215] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and these simple modifications all fall within the protection scope of this disclosure.
[0216] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0217] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
Claims
1. A block generation method, characterized in that, include: Obtain block generation configuration information, which is determined based on the state parameters of the blockchain network; The block storage capacity is determined based on the block generation configuration information. Based on the block storage capacity, the data to be stored in the blockchain is packaged into blocks; The process of obtaining block generation configuration information includes: Obtain the state parameters of the blockchain network to obtain the first state parameter, which includes one or more of the following: transaction concurrency, throughput, transaction success rate, and response time. The first state type of the blockchain network is determined based on the first state parameter; Based on the first state type, and the relationship between the state type of the blockchain network, the block capacity configuration rules, and the adjustment gain parameters, the target block capacity configuration rules are determined. The block generation configuration information includes the target block capacity configuration rules.
2. The method according to claim 1, characterized in that, The step of determining the target block capacity configuration rule based on the first state type and the correlation between the blockchain network state type, block capacity configuration rules, and adjustment gain parameters includes: Based on the first state type and the association relationship, determine multiple candidate block capacity configuration rules corresponding to the first state type and adjustment gain parameters corresponding to each candidate block capacity configuration rule; The candidate block capacity configuration rule with the largest adjusted gain parameter is used as the target block capacity configuration rule.
3. The method according to claim 1, characterized in that, After packaging the data to be stored in the blockchain into blocks, the process also includes: The state parameters of the blockchain network are obtained again to obtain the second state parameters; The second state type of the blockchain network is determined based on the second state parameter; The target adjustment gain value is calculated based on the first state type, the second state type, and the correlation relationship. The adjustment gain parameters corresponding to the first state type and the target block capacity configuration rule in the association relationship are updated according to the target adjustment gain value.
4. The method according to claim 3, characterized in that, The step of calculating the target adjustment gain value based on the first state type, the second state type, and the correlation includes: By querying the aforementioned relationships, the initial adjustment gain parameter corresponding to the first state type, the first state type, and the adjustment gain parameter corresponding to the target block capacity configuration rule are obtained; The target adjustment gain value is calculated using the following formula. : in, The initial adjustment gain parameter is... For learning rate, The discount rate is... The adjustment gain parameter corresponding to the configuration rules for the first state type and the target block capacity is defined, where r is the incentive value for the blockchain network to switch from the first state type to the second state type, and s is the description value of the first state type. 'a' is the description value for the second state type, and 'a' is the description value for the block capacity configuration rule corresponding to the first state type and the initial adjustment gain parameter in the association relationship. The description value of the rule configured for the target block capacity.
5. The method according to claim 1, characterized in that, Also includes: Based on the previously obtained historical block generation configuration information, the block capacity configuration rule in the historical block generation configuration information is used as the initial block capacity configuration rule corresponding to the first state type. By querying the association relationship based on the initial block capacity configuration rule and the first state type, the initial adjustment gain parameter corresponding to the initial block capacity configuration rule and the first state type is obtained; In the absence of historical block generation configuration information, or when the initial adjustment gain parameter is less than a preset threshold, a block capacity configuration rule is randomly determined as the target block capacity configuration rule. Before determining the target block capacity configuration rule based on the first state type and the correlation between the blockchain network state type, block capacity configuration rules, and adjustment gain parameters, the method further includes: The initial adjustment gain parameter is determined to be greater than the preset threshold.
6. The method according to claim 1, characterized in that, Also includes: The state parameters of the blockchain network are linearly mapped to obtain the mapping result; The state description value of the blockchain network is calculated based on the mapping result; The state description value is divided into multiple range intervals, wherein each range interval corresponds to a state type of the blockchain network; Determining the first state type of the blockchain network based on the first state parameter includes: Calculate the target state description value based on the first state parameter; The first state type of the blockchain network is determined based on the range of the target state description value.
7. A block generation device, characterized in that, include: The first acquisition module is used to acquire block generation configuration information, which is determined based on the state parameters of the blockchain network. A storage capacity determination module is used to determine the storage capacity of a block based on the block generation configuration information; The block packaging module is used to package the data to be stored in the blockchain into blocks based on the block storage capacity; The first acquisition module includes: The first acquisition submodule is used to acquire the state parameters of the blockchain network and obtain the first state parameters, which include one or more of the following: transaction concurrency, throughput, transaction success rate, and response time. The first determining submodule is used to determine the first state type of the blockchain network based on the first state parameter; The second determining submodule is used to determine the target block capacity configuration rule based on the first state type and the correlation between the state type of the blockchain network, the block capacity configuration rule, and the adjustment gain parameter. The block generation configuration information includes the target block capacity configuration rules.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the method described in any one of claims 1-6.
9. An electronic device, characterized in that, include: A memory on which computer programs are stored; A processor for executing the computer program in the memory to implement the steps of the method according to any one of claims 1-6.
Citation Information
Patent Citations
A performance optimization method and device for a block chain system
CN109947740A