In the previous post I described a primary blockchain (based on Ethereum RSK) that could connect with a secondary level blockchains, using special transactions. In this post, I describe the mechanism to make it happens. Usually, an Ethereum RSK has transactions and a parent block:
The new trick is to have SOME blocks with TWO parents, connecting TWO blockchains (the primary one and a secondary blockchain), and special transactions that affects the TWO blockchains:
So, we could have two blockchains with normal blocks, with some special blocks that allows the execution of interchain transactions:
The primary blockchain could have special blocks with MORE THAN ONE secondary blockchain. But the secondary blockchains only allow the special blocks that connect with the primary one:
The normal blocks are mined by miners/producers in each blockchain. But the new special blocks ARE MINED by miners that keep BOTH BLOCKCHAINS states of word. There are machines that verifies the primary blockchain, other machines that verifies a secondary blockchain, and so on. But SOME machines verifies TWO blockchains.
Suppose we have the blue blockchain (the primary blockchain) and the green blockchain (a secondary one). Then, there is an special account (the bridge blue-green account) to be used in the special transactions. That bridge account in the blue blockchain has initial 0 balance. The same bridge account in the green blockchain has a total balance of the total amount managed in the blue (primary) blockchain (in RSK, the total amount is 21M of ethers, smart bitcoins).
A user signs a transaction in the blue blockchain, from his/her account TO bridge account. If a transaction has the blue-green bridge account as the target account, then IT IS AN SPECIAL transaction. For blue machines, that transaction transfer the specified value FROM user blue account, to blue bridge account. For green machines, the same transaction transfer the specified value from green bridge account to user green account.
Then, the user could use his/her green balance in green transactions. But at any moment, he/she could transfer from green user account to green bridge account. That is another special transaction: for green machines, it represents a transfer from user green account to green bridge account; for blue machines, it is a transfer from blue bridge account to blue user account.
Both green and blue user account, have the same address, public and private keys. It is up to the user decision to send a transaction to the green blockchain or to the blue blockchain.
In each secondary blockchain, there is only one bridge account. In the primary blockchain, there is a bridge account FOR EACH secondary blockchain.
A miner that keeps blue and green world state could build the special block. But other nodes could validate only the blue part or the green part. In this way, a secondary blockchain could add scalability to the primary one, and it could have its own fees and process time. A new secondary blockchain could be added when an special operation in primary blockchain creates a new bridge account. Nobody controls these accounts: there are target accounts in all special transactions. Only the sign of the source user account is needed.
In this way, the inter-blockchain transactions are build over the same blocks, you don’t need convoluted atomic swap mechanism, the same blocks execute the TWO transfers in one special transaction.
More about this mechanism, and miner incentive for bi-blockchain blocks, in next posts.