Method of Reaching Consensus on Probability of Food Safety Based on the Integration of Finite Credible Data on Block Chain

The use of new technologies to empower the social co-governance of food safety is a consensus in the theoretical and practical fields of food safety governance modernization. Based on the innovative features of the block chain such as non-tampering, consensus mechanism, and a smart contract, this paper proposes a new method to facilitate the achievement of the effect of social co-governance of food safety. Firstly, it provides a profound analysis of the causes of food safety problems and the drawbacks of traditional centralized supervision, and proposes a solution with decentralized features and the design process of smart contracts to realize the chaining and integration of finite credible data in the process of food circulation; secondly, it constructs a mathematical model through finite credible data on the chain and obtains the probabilistic consensus results of food safety through rigorous derivation; Finally, the scheme, model and algorithm are effectively practiced through the experimental environment of mature block chain platform and provincial food supervision platform. The example shows that the market failure problem in food safety can be greatly alleviated by the non-tampering feature of block chain; the consensus results formed by the credible data uploading, model construction and data derivation through smart contracts can greatly alleviate the problem of involution of government administrative supervision; and the social co-governance capacity of food safety can be improved through information sharing with the active synergy of multiple subjects of co-governance.


I. INTRODUCTION
''The country is based on the people, the people are based on food, and food is the first priority'', Food safety is closely related to people's lives, and with the development of economic globalization, food safety is one of the most important health issues in the world today [1]. At the present stage, the food safety situation in China is still serious, and food safety has been ranked first in the ''Top 10 issues of concern in the process of China's overall wellbeing'' evaluation held by Well-off magazine for many years. ''Sudanese Red Duck Eggs'', ''Melamine Milk Powder'', ''Gutter Oil'' and ''clenbuterol'' are among the most publicized incidents. They have touched the sensitive nerve of the whole society, The associate editor coordinating the review of this manuscript and approving it for publication was Chi-Hua Chen . seriously affected the credibility of the government, harmed the interests of the people, and brought great harm to the physiology and heart of the masses. Due to China's top-down supervision system, local governments have been implementing ''developmental localism policies'' due to local taxation, reputation, and leadership performance, and have been concealing or under-reporting malignant food safety incidents, and the actual situation of food safety is much worse than the statistics of the relevant departments. As General Secretary Xi Jinping emphasized [2], food safety is first and foremost a matter of ''management'' and ''production'', and the application of new technologies to empower food safety management and promote the transformation of food safety supervision mechanisms to ensure the health of the nation, industrial safety and social stability is an important issue that needs to be addressed. This is an important issue.
Block chain began with the seminal paper ''Bitcoin: A Peer-to-Peer Electronic Cash System'' [3] published by a scholar alias ''Satoshi Nakamoto'' in the Cryptography Mail Group in 2008, and has been receiving high attention from academia and industry because of its decentralization, time-series data, collective maintenance, programmability, and security and reliability. In terms of technical architecture, both Bitcoin [3], Ethereum [4], and the most widely used alliance chain Hyperledger Fabric [5], which can be divided into five layers: network layer, consensus layer, data layer, smart contract layer, and application layer [6]. In the network layer, Bitcoin and Ethereum use TCP protocol, and Hyperledger Fabric uses HTTP/2 protocol, and the decentralized nodes are connected to each other in a flattened way; in the consensus layer, block chains mostly use machine algorithm consensus [7], which mainly includes Proof of Work (PoW), Proof of Stake (PoS), and Practical Byzantine fault tolerance (PBFT), among which Bitcoin and Ethereum mainly use PoW or PoS mechanism, and Hyperledger Fabric mainly uses PBFT algorithm. In the data layer, each block consists of two parts: block header and block body; block header stores Merkle root, previous block hash value, timestamp and other data; block body stores transaction data; blocks are connected by hash pointers to form a block chain. Bitcoin uses a transaction-based data model, while Ethereum and Hyperledger Fabric use an account-based data model; in the smart contract layer, transaction logic and business rules for accessing state data are defined by code, and external applications access the blocks through smart contracts and realize decentralized computing according to the contracts, Bitcoin's smart contract is a simple set of instructions, Ethereum provides Ethereum Virtual Machine, EVM as the sandbox environment and supports scripting languages such as Solidity and Serpent, while Hyperledger Fabric uses Docker containers as the sandbox environment and supports high-level languages such as Go and Java. In the application layer, Bitcoin mainly implements digital currency transactions, Ethereum supports decentralized applications in addition to Ethereum transactions, and Hyperledger Fabric mainly provides enterprise-oriented block chain applications. In terms of developmental stages, the block has mainly gone through three stages: cryptocurrency transactions represented by Bitcoin, distributed ledgers based on the block chain underlay, and enterprise applications based on programmable extensions. The combination with the food safety field is mainly to use the tamper-evident and traceability characteristics of block chain to realize a decentralized traceability system for the circulation information of the whole food chain [8], and some literature [9] constructed a framework for product traceability applications based on Ethereum's smart contracts, and both theoretical studies and experimental cases show that this innovative new technology of block chain will have a positive effect on food safety. This paper proposes a new approach to promote the effect of social co-governance of food safety by using the technological innovation characteristics of the block chain from a new perspective. The first section is an introduction, which introduces the background of the existing food safety research object and the block chain; the second section is a research foundation, which compares the historical process of food safety regulation, clarifies that the social co-governance of food safety is an inevitable trend of social governance modernization, and analyzes the drawbacks of the centralized technical structure and its resulting ''involution'' of the governance effect; the third section is the solution and smart contract design, which gives a problem-oriented solution and smart contract design process based on the decentralized features of block chain, realizes the chain and integration of finite credible data in the food circulation process, and builds a mathematical model based on finite credible data; the fourth section is the probabilistic consensus model and solution, which obtains the probabilistic consensus of food safety through rigorous mathematical; the fifth section is the experiment and analysis, which combines with the provincial food Internet supervision application system to build a ''block chain+'' food safety probabilistic consensus prototype system. The application of the system and the analysis of the examples show that this scheme is an effective example of modernized food safety governance based on innovative technologies such as block chain, which can eliminate the market failure caused by information asymmetry between supply and demand with the active synergy of multiple actors in the common governance.

A. THE EVOLUTION PROCESS OF FOOD SAFETY CO-GOVERNANCE
According to the development of China's food management mechanism, food industry and food hygiene status, China's food safety supervision has gone through several development stages [10], and here the practical history is summarized into five stages (as shown in Table 1 below) with the mainline of China's food safety supervision system and economic development.
The main cause of food safety problems is the asymmetry of information between supply and demand (also known as ''market failure''), which requires administrative intervention by the government, However, as the complexity of food risks progresses, the limitations of the government itself come to the fore (also known as ''government failure''), and in response to this double failure and rising social concern, in 2013, Vice Premier Yang [11], who is in charge of food safety, for the first time explicitly proposed to build a social co-governance model for food safety, with corporate self-regulation, government supervision, social collaboration, public participation, and legal protection . The research on social co-governance of food safety in western developed countries is earlier than that in China. Fearne and Martinez [12] introduced social co-governance into the field of food safety. At present, the consensus has been basically reached at the conceptual level [13]. At the operational logic level, the theory of public governance breaking through the simple thinking of dividing the government and the market, the various forces in society can exert their respective advantages, has strong complementarity, and efficiency will increase dramatically. It also makes the prevention and control of food safety risks from the traditional punishment-oriented to the modern preventive orientation [14], David and Cary [15] analyzed and discussed the function, role and governance boundary of each participant in the co-governance system.
The path of food safety development in China is different from the free market to the regulatory state in the West. China established a modern regulatory system under conditions where both the market and society were not yet mature, and the pluralistic system of co-governance is not a copy of the Western governance model, but a summary of our experience in practical exploration. Peng et al. [16] analyzed China's 20-year exploration of the U.S. food and drug regulatory model from both vertical and horizontal dimensions, while Lupin [17] conducted a comparative analysis of social governance systems from the perspective of the legal system and the participating subjects, clarifying the main responsibilities of the government as a governance subject in a cogovernance system. Yinglian [18] summarize the theoretical content and action plans of food safety strategies based on a ''mission-structure-action'' framework; some literature [19] also focuses on the construction paths and practices of social co-governance for food safety, reflecting on the problems and difficulties faced in building the system and its functional design. In conclusion, modernization of food safety governance in China through collaborative social co-governance is the trend of development and a consensus in both theoretical and practical fields in this new situation.
Institutional innovation needs to be effectively supported by technological innovation, and the two are intertwined to drive social progress, and co-governance of food safety is no exception. In keeping with other industrial development paths, food safety information technology is at a single stage of coverage, with a vertical chimney system in place. The concept of ''intelligent food safety'' has been introduced in the media and in government documents under the national ''big data, big platform'' approach to data sharing [20], but most of the current systems are built around monolithic government supervision, in keeping with the ''involution'' of government administrative agencies, and the high investment in information technology regulation does not lead to high performance in food safety governance. Block chain, as an innovative new technology, can effectively support and realize the change of thinking from traditional regulation to comprehensive governance. Blockchain-based regulatory technology, building an embedded and technology-assisted organic regulatory path to solve the dual failure of government and market and considering the characteristics of the technology itself is one of the effective methods to build a social co-governance system for food safety [8]. With the gradual improvement of the basic layout of the block chain, the combination of block chain and business is expanding to multiple fields. At present, the combination of block chain and food safety mostly stays in the traceability mechanism formed by the non-tampering feature of block chain, which solves the problem of the establishment of the trust mechanism in the whole process of the food supply chain. Figure 1 A four-step ASMI method (A-analysis & identification, S-synthetization & categorization, M-match & mapping) was used. I-Inference & Conclusion) analyzed the applicability of the block chain in food safety co-governance, and combined the technological innovation of the block chain with social co-governance of food safety. It will surely generate new kinetic energy and bring breakthroughs in theoretical mechanism and practical application.

B. AN OVERVIEW OF BLOCK CHAIN SMART CONTRACTS
Nick Szabo [21] first introduced the concept of smart contracts in 1994 and defined them as ''a set of digitally specified promises, including protocols on which contract participants can execute these promises''. In simple terms, a smart contract is a process in which all the connected agreements between people, protocols and networks are programmed and run-on distributed nodes. Before the advent of block chain, smart contracts were not used in practice because it   was difficult to ensure proper execution of contracts in a decentralized situation. The basic operational framework of a smart contract is shown in Figure 2. The execution of the smart contract code mainly consists of the following six steps: 1) the client outside the chain sends a request to the API service interface of any node when needed; 2) the API service interface of the node receives the request and sends a valid instruction to the local node to start the smart contract through the virtual machine (VM); 3) the receiving node creates a sandbox execution environment to start the contract code; 4) the contract is effectively executed process, the relevant local state is updated; 5) after the contract execution is completed, the receiving node confirms the transaction to the local; 6) after the receiving node confirms the completion of the transaction locally, it broadcasts the transaction to other nodes and reaches a consensus state through the consensus algorithm.
Bitcoin scripts are some simple stack-based instructions that do not satisfy Turing completeness, and there is no smart contract in the strict sense. Because the security of the contract code cannot be guaranteed, generally smart contracts do not run directly on the block chain nodes, but in an isolated sandbox environment. Due to the effective isolation of the sandbox, the contract and the host node cannot interfere with each other, limiting the scope of malicious code. More mature sandboxes currently include virtual machines and containers, of which Ethereum uses virtual machines and Hyperledger Fabric uses containers.
Overall, smart contracts have not yet been widely used in the commercial sector, but their technical advantages in terms of certainty, consistency, terminability, observability and verifiability, decentralization, efficiency and real-time, and low cost have been widely recognized [22]. After 2015 (the first year of block chain), research institutions at home and abroad have set off a wave of research on block chain and smart contracts, and the current research phase of block chain has separated digital currency and block chain technology, and block chain 2.0 based on smart contracts can be suitable for more complex application scenarios and generate more advanced functional requirements.

III. SOLUTION AND SMART CONTRACT DESIGN
The food traceability process can be mainly divided into three segments: production, distribution and consumption (as shown in Figure 3), and the flow of food transaction entities proceeds from right to left in Figure 3 (indicated by yellow arrows). Ideally, the flow of entities should be synchronized with the corresponding transaction information. In reality, however, the information corresponding to the entity flow and the information transmitted by the information flow is not consistent (marked by red prohibitions in Figure 3), and the information flow from one link to the next is not consistent (marked by blue prohibitions in Figure 3), which leads to information asymmetry between upstream and downstream participants in the food supply chain. This ultimately leads to the fact that consumers can only obtain a subset of food-related information or false information and are unable to make effective purchasing decisions, which is referred to as market failure. To solve the problem of market failure, strong government regulation is needed. Compared with the traditional manual sampling and testing methods, information technology means to support the use of centralized supervision, that is, through the identification (generally including food natural fingerprints or additional RFID tags in two ways), the whole process of information will be collected in full volume, and then based on the full amount of information regulation and analysis, to achieve the effectiveness of administrative supervision. However, low promotion and high cost of the full-volume information collecting scheme make it difficult to present the effect of the centralized supervision method, and it is difficult to solve the problem of government supervision failure. Based on block chain nontampering and smart contract technology, this paper proposes a method for reaching probabilistic consensus on food safety (as shown in the design framework in Figure 3), which obtains some information in the flow of food orders by means of smart contract interface docking and stores the information tamper-evidently on the block chain, derives probabilistic consensus results on food safety through the derivation of trusted information on the chain, and ultimately, the reliability of the probabilistic food safety consensus results is effectively enhanced through the active participation of participants in multiple sessions.

A. PROBABILISTIC CONSENSUS SMART CONTRACT FOR FOOD SAFETY
The food safety probability consensus smart contract requires the participants in each link of food production, distribution and consumption to submit the authenticity data that need to be stored according to the requirements agreed in the contract. Since the block chain infrastructure platform generally provides public and private key authentication management methods for identity authentication, the contract design in this paper omits this part and focuses only on the algorithm description of the business logic in the contract.
The ex-factory contract mainly refers to the need to effectively transfer the manufacturer information and food information to the smart contract through the smart contract structure when the food is shipped from the manufacturer and stored on the chain. The specific algorithm logic is shown in Protocol 1, where m represents the food manufacturer and c represents the interface of the smart contract.
The circulation contract mainly refers to the process of food in different circulation links, which requires food information to be passed and stored on the chain in accordance with the requirements of the smart contract during the order delivery process. The specific algorithm logic is shown in Protocol 2, where u m represents the upstream manufacturers of food distribution, d m represents the downstream manufacturers of food distribution, and c represents the interface of the smart contract. It is important to note that this contract takes the information transfer of the consumption link as a way of circulation, which is unified in the circulation contract, and d m represents a final consumer at this time. return indexed(c d m u m (str))//index is used to search logs 18 End procedure According to the existing food safety inspection and quarantine and sales regulations, a sampling and testing process is required before selling to consumers, and the results of the testing determine whether a batch of food meets the basic requirements for sales. The sampling contract is the process of sampling and testing and the effective information to be chained. The specific algorithm logic is shown in Protocol 3, where s represents the sampling organization, n represents the index of the chain for a commodity circulation in the previous circulation, c represents the interface of the smart contract, and r represents the result of the testing.

B. COMPLETE ANALYSIS OF CONTRACT
In order to explain the mechanism of action of smart contracts in this paper, as well as to analyze the completeness of smart contracts. Suppose here that producer m produces and ships two products A and B, the number of product A is 100 and the if ((s,str)) = ) 8 add (s,str,r) 9 return indexed(c r s (str))//index is used to search logs 10 end if 11 End procedure number of product B is 200 (shown in state S 0 in Figure 4). The manufacturer gives products A and B to distributors D 1 and D 2 for shipment; distributor D 1 in turn gives products A to distributors D 3 , D 4 and D 5 for handling; distributor D 2 gives products B to distributors D 5 and D 6 for handling. Distributors D 3 and D 6 do not effectively upload their downstream distribution or sales information as required (shown by S 3 and S 6 as indicated by the dotted lines in Figure 4), and distributors D 4 and D 5 give both products A and product B to the collector market D 7 . Consumer D 8 purchases three units of product B from collector market D 7 , and consumer D 9 purchases five units of product A from collector market D 7 . Such a smart contract design converts the information transfer problem between producers and consumers in food safety into a finite state machine state transfer problem. The probability of branch generation decreases gradually after six blocks are connected to each block in the real state and are considered as a stable state [23], [24]. The state of the whole system is infinitely cyclic, and the stability probability analysis of each structure can be performed to obtain probabilistic consensus results for food safety.

IV. PROBABILISTIC CONSENSUS MODEL AND SOLUTION
According to the aforementioned design and completeness analysis of the probabilistic consensus smart contract for food safety in Section 3, assuming a total of {D 1 , D 2 ,. . . . . . , D N } VOLUME 9, 2021 participants (here the producer is set as D 1 for simplicity, and both the participants of circulation and consumption are treated as unified traders D i as), it is possible to turn the food safety information circulation problem into the following information transfer matrix. That is, over a period of time, the information passed from D i to D j can be retrieved from within the ledger of the block chain as strij, which is a group of attributes [a 1 , a 2 ,. . . , a k ]. Because of the Non-tampering feature of block chain, the information of product-related attributes can be ensured to be true (e.g., date of production, ingredients, etc.) under the premise that it is produced by that manufacturer. Thus, the question posed in this paper can be transformed into how likely the product purchased by the downstream or final consumer is produced by the manufacturer D 1 under the premise that a limited amount of information is publicly available. Let µ i denote the probability that the product purchased by the ith trader is obtained from the producer D 1 , then µ 1 = 1 (the probability of obtaining directly from the producer is 1), µ 2 = λ 21 · µ 1 , and so on to obtain µ i = m j=1 (λ ij ·µ j ). Then the research problem of this paper can be further transformed into the problem of solving the system of equations µ i . The system of equations µ i is defined as following.
The solution to the system of equations µ i is given below. With D = {D 1 , D 2 ,. . . . . . , D N } as vertices and λ ij as an edge, a directed weighted graph V can be formed. It is clear that the graph V satisfies the following characteristics.
Feature 4: There are no edges connecting a vertex to itself, and there are no multiple edges with the same starting point and the same ending point.
Theorem 1: Suppose ξ represents a pathway from D i to D j and the product of the weight of all edges on the pathway is denoted θ(ξ ),when i = j, ξ represents a ring, then: ∀i ∈ [1, 2, . . . , N ], 0 < θ(ξ i ) < 1.
Suppose θ(ξ i ) = 1, according to the definition of θ(ξ i ), then the weight of all edges from vertex D i to D j are 1. At this time, if there exists an edge between any vertex D j outside the ring and any vertex D k inside the ring, that is to say, λ jk > 0, then there is λ ij + λ jk > 1, which contradicts feature 3; also if the entry degrees of all vertices in the ring are greater than 0, that is to say, d − (D i ) > 0, i ∈ [0, 1, . . . , k],then vertex D 1 cannot reach any vertex except D 1 , which contradicts feature 1, and therefore, there is no ring with θ(ξ i ) = 1.
The proof is complete. The transaction probability matrix λ is an (n, n-1)dimensional matrix, and here the dimension of D 1 is increased on to become the assigned adjacency matrix ω of the directed weighted graph V , then λ ii = 0 is known from feature 4, and λ i1 = 0 is known from feature 2.
Summing up, we can obtain ω k = θ(ξ k ij )• The proof is complete. Theorem 3: lim k→∞ ω k is a zero matrix, denoted as lim k→∞ ω k = 0. Proof: By Theorem 2, we know that to prove that lim k→∞ ω k is a zero matrix, we only need to prove that lim k→∞ θ(ξ k ij ) is a zero matrix, lim k→∞ θ(ξ k ij ) = 0. The meaning of θ(ξ k ij ) is that there are k pathways from vertex D i to D j , when k → ∞ n then the pathway must contain more than 1 ring, assume that a ring needs to go through k + β edges (where the first K edges do not repeat the vertex), then the product of the pathway repeated τ times is then the system of equations µ i can be expressed as: µ = A·µ+f . Obviously, the directed weighted graph consisting of the vertex D and the weight λ satisfies the four characteristics described earlier in this section and the adjacency matrix is A T . According to Theorem 3, lim k→∞ (A T ) k = lim k→∞ (A k ) T = 0 can be obtained, so lim k→∞ (A k ) = 0, then there exists a unique solution for the system of equations µ i and it can be solved using the 1st order constant length iteration method to solve, that is to say, µ k is the kth approximate iterative solution of the system of equations µ i .

V. EXPERIMENTS AND ANALYSIS A. EXPERIMENTAL ENVIRONMENT
The research related to this paper was supported by special funds from the Shaanxi Provincial Education Department Service Local Special Project (NO:19JC015) and Shaanxi Provincial Social Science Foundation Project (2020F014). In order to conduct effective experiments on this paper and the results of the research process, the group built a development environment together with the software contractor of the Shaanxi Provincial Market Supervision Platform, and the development environment architecture of the constructed food safety social co-governance platform is shown in Figure 5 below. The overall experimental environment consists of three parts: the enterprise business management system, the comprehensive provincial business supervision and service platform, and the Ethereum block chain platform. The enterprise business management system is built by the participating enterprises in each aspect of food safety, and the data is uploaded according to the requirements of the provincial comprehensive business supervision and service platform related to data filling; the provincial comprehensive business supervision and service platform is built by Liane Software Co., Ltd. through the microservice architecture, and the interaction with the block chain platform smart contract is realized through the microservice RESTful interface; The research group is mainly responsible for the construction of the block chain platform and the model and calculation analysis of relevant data, and the analysis results are fed back to the co-governance platform for presentation.
Based on Ethereum's mature framework, the group built the basic environment required for the food safety co-governance platform, implemented the algorithmic logic of the smart contract through the Solidity language, and realized interface management and data communication with the provincial food comprehensive business monitoring and service platform through microservice registration and management. The first version of the block chain platform was developed in mid-July 2019 was completed, and the docking was completed in late August. After 2 months of trial operation on line, the smart contract was adjusted and redeployed once, and Figure 6 below shows the monitoring display page of the block chain platform.

B. NUMERICAL SOLUTION OF THE MODEL
In order to experiment and validate the probabilistic consensus model of food safety proposed in this paper, statistical analysis was conducted here on the upstream data of the outbound, circulation, and consumption links of a food brand's products within September to November 2019. The distribution network of this brand is mainly divided into two parts: Guan Zhong, northern and southern Shaanxi (as shown in Figure 7 below, D 1 represents the manufacturer, and the distribution network is mainly divided into two parts, gradually extending to the sales nodes at the district and county levels), and the number on the line is the number of recorded transactions stored in the block chain.
Based on the storage and recording of the total inventory of each circulation subject in the circulation contract in Section 3.1 of this paper, the vector result of the total VOLUME 9, 2021  inventory N * can be retrieved as N * = [28, 32, 33, 19,26,38,49,23,17,32,31,30,55,39,29,25,15,34,45,34,22,20,23,18,33,28,19,19, 27] T , According to the relevant definition in Section 4 of this paper, the transaction probability matrix λ, for example, λ 56 = 12/26, can be obtained (to save space, the calculation results of λ are not shown here). According to the calculation of the solution of the system of equations µ i , the 1st order constant length iteration method is used here to solve the model, and the iteration is stopped when |µ k+1 −µ k | < 0.01. The solution result of the model can be obtained as µ (27) , as shown at the bottom of the next page. It can be seen that the results of the iterative method can meet the practical need. Since the initial matrix in this model is a sparse matrix, the iterative method is used to obtain the approximate solution, which can greatly improve the computational efficiency. The above results are derived based on the current information and data of the up-chain, but there are problems of information omission and misrepresentation, resulting in errors in the underlying information of the up-chain. When more information is appropriated and more accurate, it will make the consensus calculation result of this model closer to the actual situation. For example, by adding the information of up-chain records from D 2 to D 9 and D 6 to D 10 (as shown by the dashed line in Figure 6), the calculation results can be obtained by recalculating the transaction probability matrix λ and the set of equations µ i . From the calculation results, it can be seen that the increase of more real information leads to a certain degree of improvement in the probability of D 9 and D 10 , and similarly conversely if the total information in the circulating contracts is corrected, it leads to a certain degree of decrease in the probability of a certain participant, µ (22) , as shown at the bottom of the page.
Under the abstraction and overall derivation theory of this model, the value of the results obtained is not significant at the beginning of the system operation, but because µ i is a decreasing function of λ ij , as the amount and accuracy of information on the chain increases, it will make the calculation results converge to u * = [1, 1, . . . , 1] T , achieving the purpose of promoting social consensus on food safety through information disclosure and sharing.

C. FEASIBILITY ANALYSIS OF THE SOLUTION
This paper proposes a method for deriving probabilistic consensus results of food safety based on block chain technology with finite credible data, which aim to address the problems of ''market failure'' and ''government failure'' in the existing social consensus on food safety. The block chain's non-tampering feature enables the effective sharing of information among the participants in the whole process; the smart contract interface enables the up-chain of limited information to alleviate the high cost of the traditional centralized regulatory scheme; and the data derivation of limited information is used to obtain the probabilistic consensus results. The theoretical model and practical cases of the scheme have been explained in Sections III and IV of this paper, and the feasibility of the scheme is briefly discussed in this section. Information technology tools to assist food safety regulation have been tried in many ways around the world. The core meaning is to enhance government regulation through information technology in order to prevent market failure. However, traditional centralized programs have had little success because of the great cost required to achieve information collection on the entire food process and chain, hence the idea of social co-governance of food safety. However, most of the research on co-governance has remained at the institutional level, lacking the support of technological tools. The approach proposed in this paper achieves limited information sharing on the existing government regulatory capacity or platform, which greatly alleviates the high cost and poor scalability of centralized schemes. The technical guarantee of block chain ensures the problem of data credibility, and the consensus result based on the theoretical model can make a probabilistic consistency among different subjects about the current food state. Through the cooperation and efforts of different actors, the effect of co-governance on food safety will be achieved. Thus, this solution is an effective compromise between ''market failure'' and ''government failure''.

2) SYSTEM EFFICIENCY
The issue of efficiency of industrial application of the block chain has always been a concern. The solution mainly includes two aspects of the efficiency level, one is the efficiency issue of uploading chain after interacting through the interface of smart contract, and the other is the issue of effective retrieval and analysis application of uploaded data. Under the experimental platform built by this program, the chain uploading is mainly done by the provincial food supervision platform after receiving the supervision data, triggering the interface of smart contract for action, and then invoking the function of Ethereum base platform to realize the chain uploading. The data statistics during the period found that from the call of Invoke () function to start interaction with the smart contract, the average response time to the completion of the supreme chain is about 1.5s, and then through the caching mechanism, the performance index of data on the chain can meet the needs of the basic scenario of food supervision. However, the retrieval efficiency of the data on the chain is far from the level of industrial-grade applications, because the solution stores a running book on the chain. After removing multiple flow records from the text file, a large number of operations are required for string logic processing, which cannot achieve real-time display of block chain stored data and analysis results, and the user experience needs to be enhanced, which is one of the main direction points for the subsequent improvement of this solution.

3) DATA SECURITY
In terms of security, there is no authentication link involved in the design of this paper, and the platform's basic CA facility is used by default to implement it. Therefore, security issues such as leakage by public/private keys and forged digital signatures are not analyzed here. The security problem mainly comes from the participants in the food circulation link trying to tamper with the data previously on the chain, modifying the Hash value saved on the chain according to the result of data tampering, expecting the false data to be considered as trusted data by data visitors. The means of attack against the block chain are mainly Double-pay and Selfish Mining. The double-pay attack can be implemented when the attacking node's arithmetic power exceeds 50%, and a Selfish Mining attack can be implemented when the attacking arithmetic power of the whole network exceeds 25%. However, the attack encountered by this system is different from the traditional attack method. The main threat of this scheme is that the participants in the food circulation try to tamper with the data of the nth block before the latest block at the moment. The attacker must modify the data value and then modify all the hash values after the nth block before the latest block at the same time in order for the attack to succeed. To simplify the calculation, assume that no new node participates in the attack process, the current arithmetic power of the honest node of the whole network is i hash calculations per second, the current computational difficulty of the block hash value contains j prefix binary 0, the attacker arithmetic power is k hash calculations per second, then the probability of the honest node adding a new block is (i/2 j )/s the probability of the attacker adding a new block is (k/2 j )/s, The initial height difference between the attack node and the honest node is h 0 = l. Let h m be the height difference at the mth second, the edge of height h m+1 will have three possibilities: first, the attacker does not generate blocks and the honest node generates blocks; second, the attacker generates blocks and the honest node does not generate blocks; third, both the attacker and the honest node do not generate blocks. This gives the probability distribution of the change in height h m+1 as: When h m+1 = −1, the data tampering is successful and t height changes are possible in t seconds. Suppose r 1 is the number of occurrences of the first condition, and the second condition will occur at least (r 1 + n+1) times ( t! r 1 !(r 1 + n + 1 + r 2 )!(t − 2r 1 − n − 1 − r 2 )! (p 1 ) r 1 (p 2 ) r 1 +n+1+r 2 (p 3 ) t−2r 1 −n−1−r 2 ) when the attacker tampers with it successfully. Let r 2 be the difference between the actual number of occurrences of the second condition and the minimum number of occurrences, then the actual number of occurrences of the second condition is (r 1 + n+1+r 2 ) times and the number of occurrences of the third condition is (t−2r 1 − n−1−r 2 ). Then the probability of a successful attack in t seconds is, p n t , as shown at the bottom of the previous page, where r 1 ∈ [0, (t − 1 − n)/2] and r 2 ∈ [0, t − 2r 1 − n − 1], according to the formula of p n t , the attacker's probability of success in tampering with data will weaken with the increase of block depth n. When the attacker's arithmetic power is less than that of the honest node, the attacker's probability of success will first increase and then decrease, and eventually converge to 0. When the attacker's arithmetic power is greater than or equal to that of the honest node, the attacker's probability of success will gradually increase, but the increase will be less and less; when the attacker's arithmetic power and that of the honest node are equal, the probability of success of the attack is maximum. However, this scheme is based on a mature block chain platform, and it is difficult for the attacker to reach the same arithmetic power as the honest node; even if the arithmetic power is equal, the reward for block mining is much higher than the gain from modifying the data. Therefore, the food-safe probabilistic consensus smart contract proposed in this paper is able to meet the security requirements.
In order to quantify the security of block chain data, the numerical results of p n t were calculated during the experiment (shown in Figure 8 below). When the attacking node's arithmetic power is equal to or greater than the honest node's arithmetic power, the attacker's success probability of tampering with the data will reach more than 60% at h = 4; it will also reach about 30% at h = 10. Since the Ethereum platform is used, the attacker's arithmetic power will be much smaller than that of the honest one, and the possibility of this situation is almost 0, so we do not do too much analysis. When the attacking node's arithmetic power is less than 50% of the honest node's arithmetic power, the attacker's probability of successfully tampering with the first 4 blocks is less than 0.2%, and the probability of successful block chain attack when h = 10 will always be less than 0.3%. The idea of this model is to derive the consensus result based on the analysis of finite credible data, so only the reliability of the initial on-chain data is needed to ensure the overall data security and accuracy. In actual operation, the credible data of government regulation can be chained in the pre-data stage, which can ensure the security of data and also greatly alleviate the problem of involution of government regulation effectiveness.

VI. CONCLUSION AND OUTLOOK
Based on a detailed review of the causes of food safety and the drawbacks of traditional centralized supervision, this paper realizes the chaining of finite credible data for the entire food safety chain through three smart contracts: the factory contract, the circulation contract, and the sampling contract. Based on the probabilistic consensus model construction and graph theory derivation process, it can enable all participants to achieve a certain probability level on the results of food safety social co-governance; meanwhile, based on the experimental environment of mature block chain platform and provincial food supervision platform, the scheme, model and algorithm proposed in this paper are effectively practiced. The examples show that the market failure problem in food safety can be greatly alleviated by the non-tampering feature of block chain; the consensus results formed by the trustworthy data uploading, model construction and data derivation through smart contracts can greatly alleviate the problem of involution of government administrative supervision. Compared to previous studies, this solution overcomes the difficulty of obtaining all available information on food safety due to high costs and large quantities, by assigning a probability value to the limited information and obtaining the results by mathematical derivation, allowing for a quantitative perception of food safety. However, the willingness of distribution and consumption participants to share food safety information such as their inventory information and purchase information with others needs to be further studied. This solution is an effective example of modernized food safety governance supported by innovative technologies such as block chain, and is of great demonstrative significance for the technical practice path of building social co-governance for food safety; future work will mainly include the rapid retrieval and analysis of up-chain Data, the effective winding up of consumer terminal data, and the improvement of data analysis efficiency and real-time targeted pushing of analysis results.
SUN YIN-HE was born in Pingdingshan, Henan, in 1997. He received the bachelor's degree in engineering from Zhengzhou Institute of Aeronautical Industry Management, in 2020, with a focus on industrial engineering. He is currently studying at Xi'an Polytechnic University, majoring in management science and engineering and the research direction is mainly blockchain. During the school period, he has participated in many horizontal projects, such as the integration of the two industrialization and standardization consulting services. He won several scholarships during the school period.
YANG QIAN was born in Lantian, Xi'an, Shaanxi, China, in 1998. She received the bachelor's degree in management from Xi'an Polytechnic University, in June 2020, with a focus on information management and information. Since September 2020, she has been studying as a Graduate Student at Xi'an Polytechnic University, majoring in management science and engineering. Her research interest includes data governance.