Is it possible to make it so that anyone can safely write code directly in the e-government office?
Introduction
Electronic government (eng. E-Government) is a method of providing information and providing an already established set of government services to citizens, business, other branches of government and government officials, in which personal interaction between the state and the applicant is minimized and information technology is used as much as possible.
Smart contracts (eng. Smart contracts) - an electronic algorithm that describes a set of conditions, the fulfillment of which entails some events in the real world or digital systems. The implementation of smart contracts requires a decentralized environment that completely eliminates the human factor, and a cryptocurrency is required to be able to be used in a smart transfer contract.
Proponents of smart contracts claim that many types of contractual relationships can be partially or fully “self-fulfilling” and self-sufficient. Smart cryptographic contracts can provide better security than traditional law-based contracts and reduce other
transaction costs associated with contracting and potential litigation costs.
')
“Too high transaction costs can interfere with economic activity.
Social and state institutions can reduce these costs by using formal rules and informal norms. ”
We are all moving towards the fact that every year these same transaction costs are becoming less and less due to the creation of various platforms like Alibaba, the ability to communicate via instant messengers, interaction with the government through websites, etc.
Considering that smart contracts allow us to reduce costs, it is logical to assume that they, too, very soon will enter our life as well as smartphones, social networks, e-Government, distance education, remote work. Anything that reduces costs sooner or later becomes mainstream.
Smart contracts
With smart contracts in Ethereum, etc., there is a problem that negates all their advantages. If you fit into some kind of wrong contract, then you “hit”. Just like the “hit” members of
The DAO . But then the Ethereum developers, headed by its founder Vitalik Buterin, connected themselves to the solution of the problem, in fact, taking over the functions of the supreme power. Acne offered to vote: return the money to the victims or leave everything as is. Imagine that some businessman is told that he needs to conclude a contract for $ 1 billion, but if something goes wrong and there is a typo in the contract, then 23-year-old Canadian citizen Vitalik Buterin will figure it out and resolve the situation.
Solving such issues should not be software developers, but the lawfully elected authorities in your country or a judicial system independent of the state (in different countries in different ways).
But this problem should not be solved "in the forehead."
The governor of Arizona has signed a historic law on smart contracts and blockchain technology .
Ahead is the mare in the form of a classical legal system and pulls the smart contracts, the terms of use of which are written in paper contracts.
Hyperledger, Corda (R3) - what is it and what are they for?
In short, in order for companies or banks that do not trust each other, could exchange some data. Replace them with the usual central server and logging is quite possible. If the central server will be owned by some large bank that everyone trusts, then it is even better, because no need to spend money on infrastructure maintenance.
The main disadvantage of Hyperledger, Corda is that they unite companies in different unrelated groups. It will no longer be possible to write a smart contract that will work with data from different groups (if only through crutches in the form of entering data into a contract manually or through a special server that collects data from external sources), i.e. when going beyond the limits of the virtual machine, the same
problem occurs as with Ethereum. Creating a global union in Hyperledger and Corda is not provided, since there are no fees for resources, and the architecture is not sharpened for this.
e-Government on the blockchain
In this
news you can see, it would seem, something innovative. But imagine that the documents will be stored not on the e-Government server, but on the departmental servers. To maintain these servers, you need to hire specialists, pay for the channel, for electricity, update the failed equipment, and so on. It is certainly good that no one will be able to forge a scanned copy of a document, but even on e-govenrment servers the probability of such a fake is also not high. With this approach, the UAE can spend huge sums of money by 2020, and get not an increase in costs, but an increase in them.
Digital economy in the Russian Federation
I happened to attend one event at
ASI , dedicated to the digital economy. The impression was that the government has no idea what a digital economy is and how to build it. After this
news, it became obvious that there was no plan for creating a digital economy, and the assembled working group should come up with it.
Electronic Government of the Russian Federation:

It is planned to integrate the digital economy into such an architecture. It all consists of a huge number of databases in different departments. According to people's opinions, the accuracy of the data is terrifying, in order to show good statistics, the numbers are constantly being corrected. All this is governed by laws, which, as many know, contradict each other and are accepted in large quantities in the Duma. In order for it to at least somehow work, a tremendous number of officials is required.
Optimal architecture
Imagine having the opportunity to build everything from scratch. How the architecture core itself should look like so that transaction costs can be reduced to the lowest possible values, while ensuring an adequate level of security for the system itself.

In our version of the architecture, we see 4 main columns:
1. Smart contracts
Smart contracts to solve this problem is a very useful tool to use. But in order to use this tool in an optimal way, another tool in the form of a state is needed - it must take responsibility for creating institutions that will resolve possible disputes.
Super rights

Citizens give the state such rights during elections, if, of course, the form of government is not monarchist :)
The smart contracts themselves, from which the entire e-government backend will be built, look like this:

data / conditions / action - here, I think, everything is approximately clear, this is also the case with Ethereum and others. In fact, just a program code. But the conditions of change can be disassembled in more detail.
On a regular hosting you have a PHP code that only you and hosting administrators can change. On the servers of the classic e-government, some programmers / system administrators have access, maybe someone else. If someone changes something, eases the logs, and then it turns out that everyone forgot about VCS, then you can mess up a lot of dirty tricks and stay with nothing. To protect against such situations, we have all the changes permanently saved in the blockchain. And if there is no right to change, then nothing will change. The exception is super-rights, but if someone with such authority added at least one comma to the contract code, this will also remain forever in the blockchain. This will record who made the change and when.
Payment of consumed resources
Who will pay for the work of a smart contract? A smart contract can have loops and queries to the database with a billion rows.
Each contract is tied to a purse with us. In the case of the Russian Federation, this will be a purse with rubles. A wallet can have many owners. And the owners may be temporary, for example, officials. Therefore, such wallets in the “conditions for withdrawal of funds” indicates a smart contact, which can check the presence of a person in some registry and then write off the funds. Due to this, a purse of some department / fund, etc. can be tied to a smart contract. Within the contact itself, funds can be written off from the one who calls it (if the caller has approved this amount of write-off).
An example of a smart contract that simply updates the data in the register of citizens:

To change such a contract, you must pass the test that occurs in MainConditions. When executing a contract, funds for resources will be deducted from the wallet 0875-3553-1112-8181-5545.
2. Registries
If you use a classic DBMS, then with the logging off, you can safely change the data through the console and no one will notice - the main thing is to agree on access to the server in e-Government. To reduce the likelihood of such an incident, serious regulation is required at the physical level, which, they say, is often not respected.
We have this problem solved at the kernel level.

Just as with smart contracts, rights are established - the rights to change, view, add new rows, columns. And if you have no rights, then nothing will be changed / viewed. The exception is super-rights. And any action is recorded in the blockchain.
3. Interfaces
For additional security, interfaces must also be controlled. Otherwise, if someone gets access to the server where there is no VCS, then they will be able to replace the data entry forms, and then cover their tracks.

It is necessary to take into account that these pages will be created not only by state bodies, but also by companies and ordinary citizens. A company may want to create a product catalog. Someone will create a platform where citizens will be able to sell their goods. Someone will create an analogue of “Alibaba”, a catalog of homeowners, etc. etc.
Payment of consumed resources
There is one problem here. Each request to the database must be paid by someone. If the state is to pay for this, then what happens if someone constantly pulls hundreds of millions of rows out of the database while loading the server? It is logical to assume that the creator of the page or the group of creators should pay (as for the usual cloud hosting). But then competitors will enter the pages of companies and specifically consume resources. For protection, you can place heavy pages in closed access and allow them only with the consent to pay the resources spent by the page visitor, and page owners can block access to free pages for citizens who have the F5 (CMD + r) key. But in most cases, costs will be minimal, and you will not have to think about payment and blocking.
4. Blockchain
Readers who are familiar with the blockchain technology are probably wondering - who will be the nodes?
To keep public data in clear form is currently not acceptable. Even if we encrypt them and leave only the ID outside, it will be possible to understand who is who in the transaction history. Personally, I am convinced that the future is behind an open blockchain, but in current realities, for the time being, only a closed type is allowed.

A node is a data center, the blocks are signed one by one every second. The number of data centers should be more than three. If there are 2 of them, then in the case of a plug it will be impossible to understand who has the correct data, you will have to rebuild the database from the very first block.
That is, if someone wants to write to the database x = 1 through the console, where x was 0, and then access this value from the smart contract code, then on all other nodes the transaction simply does not work, and at that moment, when someone specifies if x == 0 in the contract code, the compromised node will not be able to accept such a block, while the others will accept, as a result, those who accepted will work in their branch of the blockchain, and the compromised node will what will appear on the router as different hashes.
An interesting question - who will be the owner of the data center - the state or a private company?
Total
The state will be able to set up access rights to registries, create smart laws to work with them and observe how companies and citizens will build their projects around them, create new forms of business, various platforms, ERP, etc.
Due to the fact that the data cannot be corrected, reliable reports will be obtained, on the basis of which it will be possible to make forecasts, carry out optimization, etc., using AI. Private keys can be issued not only to people, but also to devices, so that IoT does not stand aside and work within a single information space.
Conclusion
In this article, I described the architecture that will allow the implementation of smart contracts in e-Government, which can lead to a significant reduction in bureaucracy and acceleration of all economic processes.
I hope that this material and our developments (which, by the way,
open-source ) will be in some form useful and will be used by
people from this list .
If you think that something is missing in our architecture, please write.