This runs a private ethereum network of three besu nodes, one of which is a validator.
Besu is running using the flexible permissioning extension that allows to control account behavior using a smart contract.
Two trivial smart contracts are included to demonstrate how OpenZeppelin access control can be used either on a per-contract basis (DirectContract
) or using a central authority for all contracts (DelegateContract
).
Start the nodes via
docker-compose up -d
If you want to see the besu node logs, omit the -d
and run this command in a separate terminal.
Then compile and deploy all contracts to your network using
./deploy
and follow the instructions given there.
Stop the besu network via
docker-compose down
This retains the state of the blockchain. To erase all blockchain data and start from scratch run
rm -r docker-data/node*/{DATABASE_METADATA.json,caches,database}
Permissioning setup happens in three phases:
- A bootstrap contract is included in the genesis file.
Besu nodes are started with
--permissions-accounts-contract-enabled --permissions-accounts-contract-address=0x0000000000000000000000000000000000008888
to activate account permissioning using this particular contract. The bootstrap contract allows all blockchain interactions and has the sole purpose of being a placeholder before being updated by the actual account permissioning contract. - The AccountRules contract is deployed by an arbitrary account. By deploying, this account becomes the admin account for entire blockchain.
- The CentralAccessControl contract is deployed. Again, the account deploying it becomes the administrator of that contract.
All subsequently deployed contracts are derived from the DelegatedAccessControl contract and linked to the CentralAccessControl
instance on deployment.
Every blockchain interaction is checked on two levels:
- Transactions are checked by looking up whether the sender is permitted in the
AccountRules
contract. - Calls in a transaction are checked by looking up whether the caller has the required role in the
CentralAccessControl
contract.