How to make smart contracts work in a small network? Suppose we have a small computer network, there are 30 random people who have provided their computers to perform any computational tasks on them. Let's call these 30 computers nodes. We can access any of these 30 nodes arbitrarily, but by the condition of the problem, we do not know whether the node is honest. That is, we can not guarantee that the node will execute exactly the f (x) that we send to it, or that the node will certainly give us the correct answer.

Also, we have, by condition, A and B that want to conclude a smart contract with each other. A smart contract is a code (usually a small one, 15-25 lines long), whose body will certainly execute when a certain condition is set in the code.

In our case, the smart contract says that if event E1 occurs, B will pay A from its account, and if event E2 occurs, then A will pay B (how exactly will the payment in details not be discussed, it will occur within this network, using conventional cryptocurrency algorithms in the classic blockchain, for example).

The problem is that neither A nor B can guarantee if they entrust the execution of the smart contract code to a random node from our network that it will be executed correctly. One node can execute the received code in reverse or not execute at all. So which cryptographic algorithm A and B can use to ensure (statistically) the correct execution of the concluded smart contract? As already mentioned, they can use the services of any of the 30 nodes as you like.

I thought about dividing the smart contract into small parts and dividing them one by one into each of the 30 nodes, but how would this help if some dishonest nodes still execute their code incorrectly? We can easily find a dishonest node and exclude it, but a smart contract must be executed correctly the first time - that is, certainly, and not after the selection of honest nodes. When one of the nodes behaves incorrectly, the entire smart contract will already be executed incorrectly.
One approach is to use a system like Ethereum, Truebit, or their successors.  In Ethereum, every node checks that the smart contract was executed correctly.  In Truebit, there is a sophisticated way to assign the contract to untrusted nodes and check that they executed it correctly.

Another approach is to use trusted hardware, like SGX.

There are probably other options as well.

I suggest reading up on those systems.  There's lots written on them.