Now that every node is configured, and either creates or imports blocks, we can create and deploy a Validator Set contract. The following steps assume that Node0
, Node1
and Alice
nodes are running.
In this tutorial, Alice
will deploy and be the owner of the contract. In a real world setting, Alice could be replaced by a multi-signature contract or any other governing logic, so as to prevent one single entity from controlling the Validator Set.
remixd
The Validator Set contract used for Kovan Network is in fact a set of contracts. We will first download them locally before using remixd
and Remix to deploy this set of contracts.
remixd
is a convenient way to load local files to Remix and avoid tedious manual work. Explaining how to install remixd
is outside of the scope of this tutorial. Please install it with npm, and we’ll continue from there.
git clone https://github.com/openethereum/kovan-validator-set.git && cd ./kovan-validator-set/contracts
remixd
from here to share the content of this directory with Remix:
remixd -s ./
This opens a WebSockets channel to allow your browser to access local files on the port 65520.
We will now connect remix to Alice
’s node. We’ve set it up earlier to accept connections from Remix domain over the standard JSON RPC HTTP port 8545.
Run
tab in the top right-hand corner of the window.Web3 provider
in the “Environment” drop-down menu.alice.toml
.The contract used in this tutorial is not trivial to understand as it consists of a set of contracts using a proxy as well as libraries.
You can read more about the internals in the dedicated repository. The important concept to understand is that RelaySet
is a proxy contract that will point to the main contract that itself allows to add and remove validators. Proxy contracts allow to be flexible and update the “proxied” contract in the future if needed. In our case, RelayedOwnedSet
will be the “proxied” contract.
We will need to deploy RelaySet
, then deploy RelayedOwnedSet
, and finally, link the former with the later.
RelaySet
by selecting it in the drop-down menu on the right part of Remix and click Deploy
.RelaySet
contract is deployed, copy its address.RelayedOwnedSet
in the drop-down menu. The constructor requires two arguments, the RelaySet
address and the initial set of validators (this is an array).RelayedOwnedSet
by filling the parameters with the address copied at the previous step, and Node0
’s address. It should look similar to (notice that the array ["0x.."]
for _initial
parameter):
setRelay
function from RelaySet
contract to link the proxied with the proxy contract.
The Validator Set contract is now deployed. You can make sure Node0
is the only allowed validator by calling getValidators
.
← Part 1 - Configuring each node | Part 3 - Hardfork to use the Validator Set contract → |