Detailed Description
In order to make the purpose, technical solutions and advantages of this document more clear, the technical solutions of this specification will be clearly and completely described below with reference to specific embodiments of this specification and the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of this document, and not all embodiments. All other embodiments obtained by a person skilled in the art without making any inventive step based on the embodiments in this description belong to the protection scope of this document.
The technical solutions provided by the embodiments of the present description are described in detail below with reference to the accompanying drawings.
In order to solve the problem that an existing blockchain platform lacks accurate authority control over transactions and corresponding transaction accounts, an embodiment of the specification provides an authority control method in a blockchain, and by adopting the authority control method provided by the embodiment of the specification, a common node in the blockchain can obtain a first transaction from a transaction pool, the first transaction is sent by a client, and the first transaction carries an authority setting request aiming at a target authority type; the consensus node initiates a consensus operation aiming at the first transaction in the block chain; after the first transaction passes the consensus in the blockchain, the permission control intelligent contract used for setting the permission based on the permission setting request in the transaction after passing the consensus is used, the target permission type is set in the blockchain, and the setting and the control of the permission type in the blockchain are realized, so that whether the transaction has the corresponding permission or not can be determined when a certain transaction is executed subsequently.
Specifically, an implementation flow diagram of a method for managing and controlling permissions in a blockchain, which is provided by one or more embodiments of the present specification and applied to a consensus node in the blockchain, is shown in fig. 1, and includes:
s110, a first transaction is fished from the transaction pool, the first transaction is sent by the client, and the first transaction carries an authority setting request aiming at the target authority type.
The target authority types can include authority types such as transfer transaction, account creation, white list setting, black list setting and the like.
Optionally, in this embodiment of the present specification, when creating the starting block, a part of the authority types and the corresponding authority accounts may be set, specifically, before the first transaction is retrieved from the transaction pool, the method provided in this embodiment of the present specification further includes:
when a starting block is created, deploying a permission control intelligent contract, wherein the permission control intelligent contract is used for setting permission based on a permission setting request;
setting and storing a first authority type and/or an authority account of the first authority type through an authority control intelligent contract;
an administrator user is created.
Optionally, in order to avoid that the method for managing and controlling permissions in the blockchain is damaged by some malicious users, the first transaction may be sent by the administrator user through the client. That is, after creating the starting block, the block chain may set an administrator user, where the administrator user has an authority to set the authority type and the corresponding authority account or change the set authority type and/or the authority account corresponding to the set authority type, and other general users do not have such authority.
And S120, initiating a consensus operation aiming at the first transaction in the block chain.
Optionally, the embodiment of the present specification does not limit a specific algorithm corresponding to the consensus operation.
S130, after the first transaction passes the consensus in the block chain, setting a target permission type in the block chain through a permission management and control intelligent contract; the authority control intelligent contract is used for setting the authority based on the authority setting request in the transaction after consensus.
Optionally, after the target permission type is set by the permission management and control intelligent contract, the transaction corresponding to the target permission type may be executed in the block chain. Taking the example that the target authority type contains the transfer transaction, before the authority type of the transfer transaction is set in the block chain, the block chain cannot execute the transaction; and after the authority type of the transfer transaction is set in the blockchain, the transaction can be executed in the blockchain.
Optionally, in order to facilitate an administrator user to obtain feedback information of an authority setting result of a target authority type, and facilitate the administrator user to manage and control the authority in the block chain, after an authority account of the target authority type is set in the block chain through an authority management and control intelligent contract, the method provided in the embodiment of the present specification further includes:
and returning the permission setting result aiming at the target permission type to the client.
Optionally, after the permission type is set, a corresponding permission account may be set for the permission type to perfect permission management and control and provide a more accurate permission management and control scheme. Specifically, after a target permission type is set in a block chain by a permission management and control intelligent contract, the method provided in the embodiment of the present specification further includes:
a second transaction is fished from the transaction pool, the second transaction is sent by the client, and the second transaction carries an authority setting request aiming at the authority account of the target authority type;
initiating a consensus operation for the second transaction in a blockchain;
after the second transaction passes the consensus in the blockchain, setting an authority account of a target authority type in the blockchain through an authority control intelligent contract; the authority control intelligent contract is used for setting the authority based on the authority setting request in the transaction after consensus.
The permission account for the target permission type may include setting a white list for the target permission type, only the permission account in the white list has a permission to execute the transaction corresponding to the target permission type, and the permission account for the target permission type may further include setting a black list for the target permission type, where the permission account in the black list does not have a permission to execute the transaction corresponding to the target permission type.
For example, a white list capable of executing the transfer transaction may be set for the transfer transaction, including the account a and the account b, that is, only the account a and the account b may execute the transfer transaction; a blacklist, including the c-account and the d-account, on which the transfer transaction cannot be performed, may also be set for the transfer transaction, that is, the c-account and the d-account cannot perform the transfer transaction.
Optionally, after setting the authority account of the target authority type in the block chain through the authority management and control intelligent contract, in order to facilitate an administrator user to obtain a setting condition of the authority account corresponding to the target authority type in time, the method provided in the embodiment of the present specification further includes:
and returning the setting result of the authority account corresponding to the target authority type to the client.
Optionally, the second transaction relates to setting of the authority, and in order to avoid malicious modification of the authority by another general account, the second transaction may be sent by the administrator user through the client.
Optionally, after setting the authority account of the target authority type in the block chain by the authority management intelligent contract, in order to facilitate authority management of subsequent transactions, the embodiments of the present specification provide further methods further including:
and recording the target authority type and the mapping relation between the authority accounts of the target authority type in a state database of the consensus node.
For example, the transfer transaction and the mapping relationship between the white list account and the black list account of the transfer transaction can be recorded in the state database of the consensus node
Optionally, after the state database of the consensus node records the target authority type and the mapping relationship between the authority accounts of the target authority type, the method provided in the embodiment of the present specification further includes:
the target transaction sent by the target user is fished from the transaction pool, and the target transaction carries the transaction type of the target transaction;
inquiring an authority type corresponding to the transaction type of the target transaction from a state database;
if the authority type corresponding to the transaction type of the target transaction exists in the authority types of the state database, inquiring an authority account corresponding to the transaction type of the target transaction based on the mapping relation, and determining whether the target user has the authority of the target transaction;
and if the target user has the authority of the target transaction, initiating a consensus operation aiming at the target transaction in the block chain.
The following describes in detail a method for managing and controlling permissions in a block chain according to an embodiment of the present disclosure with reference to an application scenario shown in fig. 2. Fig. 2 includes a client, a blockchain platform, and an intelligent contract for rights management, including:
s21, the blockchain platform deploys the intelligent contract for authority control in the blockchain after the creation of the starting block;
after the authority control intelligent contract is deployed, some authority types can be set, authority accounts corresponding to the authority types can be set, the authority accounts corresponding to the authority types can not be set, and the authority accounts corresponding to one or more of the authority types can be set.
In order to better manage and control the permissions in the blockchain, the embodiments of the present specification may set an account of an administrator user after creating the starting block, and only the administrator user has the permission to set and change the permission type and the corresponding permission account.
S22, the client sends the transaction with the set authority type to the blockchain platform;
the set permission type transaction may be sent by an administrator user to the blockchain platform through a client.
For example, an administrator user may send a transaction to the blockchain platform through a client that carries a set request for the type of authority for the transfer transaction.
S23, the consensus node in the block chain initiates consensus operation aiming at the transaction of the set authority type;
the embodiment of the present specification does not limit the specific algorithm corresponding to the consensus operation.
S24, after the transaction with the set authority type reaches consensus in the block chain, the authority control intelligent contract sets and stores the authority contract;
s25, synchronizing the execution result at each consensus node in the block chain;
each consensus node in the block chain may store the set permission type in a state database in the consensus node.
S26, the block chain platform returns the execution result to the client;
for example, the blockchain platform returns a result that the permission type setting for the transfer transaction is successful to the client.
S27, the client sends the transaction of the authority account corresponding to the set authority type to the block chain platform;
the transaction of the authority account corresponding to the set authority type can be sent to the blockchain platform by the administrator user through the client.
For example, an administrator user may send a transaction carrying a setting request including an account a, an account b, and an account c for an authority account corresponding to a transfer transaction to the blockchain platform through the client.
S28, the consensus node in the block chain initiates a consensus operation aiming at the transaction of the authority account corresponding to the set authority type;
s29, after the transaction of the authority account corresponding to the set authority type reaches consensus in the block chain, the authority control intelligent contract sets and stores the authority account corresponding to the authority type;
s210, synchronizing the execution result at each consensus node in the block chain;
each consensus node in the block chain can store the authority account corresponding to the set authority type in a state database in the consensus node. For example, each consensus node in the blockchain may maintain a mapping between the set transfer transaction and the a, b, and c accounts in a status database in the consensus node.
S211, the block chain platform returns an execution result to the client;
for example, the blockchain platform returns the result that the setting of the authority account for the transfer transaction comprises the account a, the account b and the account c to the client successfully.
S212, the client sends a transaction to the blockchain platform, wherein the transaction carries a transaction type and a corresponding transaction account;
for example, the transaction type is a transfer transaction, and the transaction account comprises an account a and an account b.
S213, the consensus node in the block chain checks whether the transaction has the corresponding authority type and authority account.
For example, whether the authority type of the transfer transaction is set or not can be inquired from a state database in the consensus node, when the authority type of the transfer transaction is determined to be stored in the state database, whether the authority account corresponding to the transfer transaction comprises an account a and an account b or not is determined, if the authority account corresponding to the transfer transaction comprises the account a and the account b, consensus operation aiming at the transaction can be initiated in a block chain, and otherwise, a result of transaction execution failure is returned.
By adopting the authority control method provided by the embodiment of the specification, the common identification node in the block chain can be used for fishing out a first transaction from the transaction pool, the first transaction is sent by the client, and the first transaction carries an authority setting request aiming at a target authority type; the consensus node initiates a consensus operation aiming at the first transaction in the block chain; after the first transaction passes the consensus in the blockchain, the permission control intelligent contract used for setting the permission based on the permission setting request in the transaction after passing the consensus is used, the target permission type is set in the blockchain, and the setting and the control of the permission type in the blockchain are realized, so that whether the transaction has the corresponding permission or not can be determined when a certain transaction is executed subsequently.
Fig. 3 is a schematic structural diagram of a rights management unit 300 in a block chain according to an embodiment of the present disclosure. Referring to fig. 3, in a software implementation, the privilege management apparatus 300 in a block chain may include a transaction fetching module 310, a transaction consensus module 320, and a contract execution module 330, where:
the transaction fetching module 310 fetches a first transaction from a transaction pool, the first transaction is sent by a client, and the first transaction carries an authority setting request for a target authority type;
a transaction consensus module 320 that initiates a consensus operation for the first transaction in the blockchain;
a contract execution module 330 that sets the target privilege type in the blockchain by a privilege management intelligence contract after the first transaction passes consensus in the blockchain; the authority control intelligent contract is used for setting authority based on the authority setting request in the transaction after consensus.
The apparatus 300 for regulating authority in a block chain provided based on the embodiments of the present specification can know that:
a common node in a block chain can obtain a first transaction from a transaction pool, the first transaction is sent by a client, and the first transaction carries an authority setting request aiming at a target authority type; the consensus node initiates a consensus operation aiming at the first transaction in the block chain; after the first transaction passes the consensus in the blockchain, the permission control intelligent contract used for setting the permission based on the permission setting request in the transaction after passing the consensus is used, the target permission type is set in the blockchain, and the setting and the control of the permission type in the blockchain are realized, so that whether the transaction has the corresponding permission or not can be determined when a certain transaction is executed subsequently.
Optionally, in an embodiment, after the contract execution module 330 sets the target permission type in the blockchain through a permission management intelligence, the apparatus further includes:
the first transaction fetching module fetches a second transaction from a transaction pool, the second transaction is sent by the client, and the second transaction carries an authority setting request aiming at an authority account of a target authority type;
a first transaction consensus module that initiates a consensus operation for the second transaction in the blockchain;
a first contract execution module that, after the second transaction passes consensus in the blockchain, restricts, by the entitlement control intelligence, an entitlement account in the blockchain that sets the target entitlement type; the authority control intelligent contract is used for setting authority based on the authority setting request in the transaction after consensus.
Optionally, in an embodiment, before the transaction fishing module 310 fishes the first transaction from the transaction pool, the apparatus further includes:
the contract deployment module is used for deploying an authority control intelligent contract when the starting block is created, wherein the authority control intelligent contract is used for setting authority based on an authority setting request;
the authority setting module is used for setting and storing a first authority type and/or an authority account of the first authority type through the authority control intelligent contract;
and the administrator user creating module is used for creating administrator users.
Optionally, in one embodiment, the first transaction is sent by the administrator user through the client;
the second transaction is sent by the administrator user through the client.
Optionally, in an embodiment, after the first contract execution module sets, through an authority management intelligence, an authority account corresponding to the target authority type in the blockchain, the apparatus further includes:
and the authority recording module is used for recording the target authority type and the mapping relation between the authority accounts of the target authority type in a state database of the consensus node.
Optionally, in an embodiment, after the rights recording module records the mapping relationship between the target rights type and the rights account of the target rights type in the status database of the consensus node, the apparatus further includes:
the second transaction fetching module is used for fetching a target transaction sent by a target user from a transaction pool, wherein the target transaction carries the transaction type of the target transaction;
the authority inquiry module inquires an authority type corresponding to the transaction type of the target transaction from the state database;
the authority determining module is used for inquiring an authority account corresponding to the transaction type of the target transaction based on the mapping relation and determining whether the target user has the authority of the target transaction if the authority type corresponding to the transaction type of the target transaction exists in the authority types of the state database;
and the second transaction consensus module initiates consensus operation aiming at the target transaction in the block chain if the target user has the authority of the target transaction.
Optionally, in an embodiment, after the contract execution module 330 sets the target permission type in the blockchain through a permission management intelligent contract, the apparatus further includes:
and the first execution result returning module returns the permission setting result aiming at the target permission type to the client.
Optionally, in an embodiment, after the first contract execution module sets the authority account of the target authority type in the block chain through the authority management intelligence, the apparatus further includes:
and the second execution result returning module returns the setting result of the authority account corresponding to the target authority type to the client.
The permission management and control device 300 in the block chain can implement the method in the embodiment of the method in fig. 1 to fig. 2, and specifically refer to the permission management and control method in the block chain in the embodiment shown in fig. 1 to fig. 2, which is not described again.
Fig. 4 is a schematic structural diagram of an electronic device provided in an embodiment of the present specification. Referring to fig. 4, at a hardware level, the electronic device includes a processor, and optionally further includes an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory, such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, the network interface, and the memory may be connected to each other via an internal bus, which may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 4, but that does not indicate only one bus or one type of bus.
And the memory is used for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory may include both memory and non-volatile storage and provides instructions and data to the processor.
The processor reads a corresponding computer program from the nonvolatile memory to the memory and then runs the computer program to form the authority control device in the block chain on a logic level. The processor is used for executing the program stored in the memory and is specifically used for executing the following operations:
a first transaction is fished from a transaction pool, the first transaction is sent by a client, and the first transaction carries an authority setting request aiming at a target authority type;
initiating a consensus operation for the first transaction in the blockchain;
after the first transaction passes consensus in the blockchain, setting the target permission type in the blockchain by a permission management intelligence rule; the authority control intelligent contract is used for setting authority based on the authority setting request in the transaction after consensus.
By adopting the electronic equipment provided by the embodiment of the specification, the common identification node in the block chain can obtain a first transaction from the transaction pool, the first transaction is sent by the client, and the first transaction carries the permission setting request aiming at the target permission type; the consensus node initiates a consensus operation aiming at the first transaction in the block chain; after the first transaction passes the consensus in the blockchain, the permission control intelligent contract used for setting the permission based on the permission setting request in the transaction after passing the consensus is used, the target permission type is set in the blockchain, and the setting and the control of the permission type in the blockchain are realized, so that whether the transaction has the corresponding permission or not can be determined when a certain transaction is executed subsequently.
The method for managing permissions in a block chain as disclosed in the embodiment shown in fig. 1 of this specification may be applied to a processor, or may be implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps and logic blocks disclosed in one or more embodiments of the present specification may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with one or more embodiments of the present disclosure may be embodied directly in hardware, in a software module executed by a hardware decoding processor, or in a combination of the hardware and software modules executed by a hardware decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
The electronic device may further execute the method for managing and controlling permissions in the block chain of fig. 1, which is not described herein again.
Of course, besides the software implementation, the electronic device in this specification does not exclude other implementations, such as logic devices or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or logic devices.
Embodiments of the present specification also propose a computer-readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a portable electronic device comprising a plurality of application programs, are capable of causing the portable electronic device to perform the method of the embodiment shown in fig. 1, and in particular to perform the following:
a first transaction is fished from a transaction pool, the first transaction is sent by a client, and the first transaction carries an authority setting request aiming at a target authority type;
initiating a consensus operation for the first transaction in the blockchain;
after the first transaction passes consensus in the blockchain, setting the target permission type in the blockchain by a permission management intelligence rule; the authority control intelligent contract is used for setting authority based on the authority setting request in the transaction after consensus.
By using the computer-readable storage medium provided by the embodiment of the present specification, it can be known that a consensus node in a blockchain can retrieve a first transaction from a transaction pool, where the first transaction is sent by a client and carries an authority setting request for a target authority type; the consensus node initiates a consensus operation aiming at the first transaction in the block chain; after the first transaction passes the consensus in the blockchain, the permission control intelligent contract used for setting the permission based on the permission setting request in the transaction after passing the consensus is used, the target permission type is set in the blockchain, and the setting and the control of the permission type in the blockchain are realized, so that whether the transaction has the corresponding permission or not can be determined when a certain transaction is executed subsequently.
In short, the above description is only a preferred embodiment of the present disclosure, and is not intended to limit the scope of the present disclosure. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of the present disclosure should be included in the scope of protection of one or more embodiments of the present disclosure.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.