Compare commits

...

No commits in common. "master" and "sohail/kitabu-clique" have entirely different histories.

9 changed files with 96 additions and 360 deletions

6
.gitignore vendored
View File

@ -1,5 +1 @@
openethereum/.env
openethereum/key
openethereum/data
openethereum/password
devops/caddy
data

View File

@ -1,61 +1,2 @@
## Kitabu Chain
# kitabu-chain
### Prerequisites
_This step assumes you have root access on a Debian or Ubuntu based host OS_
```bash
$ apt get update
$ apt install chrony curl git
$ curl -fsSL https://get.docker.com | bash
$ curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose
```
### Validator node setup
#### 1. Clone this repo
```bash
$ git clone https://git.grassecon.net/grassrootseconomics/kitabu-chain
$ cd kitabu chain
```
#### 2. Obtain your private key
If you have an existing keystore file, rename it to `key` else create a new one:
```bash
$ openethereum account new --base-path=$(pwd)
$ mv keys/ethereum/UTC* ./key
$ rm -rf keys
```
Save the password of the key created above in a `password` file. Save the key's public address for the next step.
#### 3. Setup environmental variables and other configs
```bash
cp .env.example .env
```
Edit the `.env` file:
- `EXT_IP`: Your server's external IP (`curl ifconfig.me`)
- `ACCOUNT`: Your private key's public address
Edit `docker-compose.yml` or `kitabu.toml` to tweak the Openethereum config as per your own preferences.
#### 4. Start the validator node
```bash
$ docker-compose up
# or...
$ docker-compose up -d
```
#### 5. Reverse proxy setup
The `devops` folder contains a Caddy config to use as a reverse proxy to further control access to your validator node's API.
Replace `.yourdomain` in the `Caddyfile` and point it to your server IP.

View File

@ -0,0 +1,94 @@
// Author: Mohamed Sohail <mohamedsohailazim@gmail.com>
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.6.12;
contract KitabuValidators {
address constant SYSTEM_ADDRESS =
0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE;
address public admissionController =
0x9F57B4A25638F3bdfFcB1F3d2902860601a1Aa65;
address[] validators;
bool public finalized;
mapping(address => uint256) validatorSetIndex;
event NewAdmissionController(
address indexed old,
address indexed newController
);
event InitiateChange(bytes32 indexed parentHash, address[] newSet);
event ChangeFinalized(address[] currentSet);
modifier onlySystemChange() {
require(msg.sender == SYSTEM_ADDRESS);
_;
}
modifier alreadyFinalized() {
require(finalized);
_;
}
modifier onlyAdmissionController() {
require(msg.sender == admissionController);
_;
}
constructor() public {
validators.push(admissionController);
validatorSetIndex[admissionController] = 0;
finalized = true;
}
function setNewAdmissionController(address newController)
public
onlyAdmissionController
{
emit NewAdmissionController(admissionController, newController);
admissionController = newController;
}
function getValidators() public view returns (address[] memory) {
return validators;
}
function initiateChange() private {
finalized = false;
emit InitiateChange(blockhash(block.number - 1), getValidators());
}
function finalizeChange() public onlySystemChange {
finalized = true;
emit ChangeFinalized(validators);
}
function addValidator(address newValidator)
public
onlyAdmissionController
alreadyFinalized
{
validators.push(newValidator);
validatorSetIndex[newValidator] = validators.length - 1;
initiateChange();
}
function removeValidator(address exValidator)
public
onlyAdmissionController
alreadyFinalized
{
orderedRemoval(validatorSetIndex[exValidator]);
delete validatorSetIndex[exValidator];
initiateChange();
}
function orderedRemoval(uint256 index) private {
for (uint256 i = index; i < validators.length - 1; i++) {
validators[i] = validators[i + 1];
}
validators.pop();
}
}

View File

@ -1,12 +0,0 @@
rpc.yourdomain {
reverse_proxy openethereum:8545
}
ws.yourdomain {
@websockets {
header Connection *Upgrade*
header Upgrade websocket
}
reverse_proxy @websockets openethereum:8546
}

View File

@ -1,17 +0,0 @@
version: '3.9'
services:
caddy:
restart: unless-stopped
container_name: caddy
image: caddy:2-alpine
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./caddy/data:/data
ports:
- '80:80'
- '443:443'
networks:
- openethereum_kitabu
networks:
openethereum_kitabu:
external: true

View File

@ -1,2 +0,0 @@
EXT_IP=
ACCOUNT=

View File

@ -1,37 +0,0 @@
version: '3.9'
services:
openethereum:
init: true
user: root
restart: unless-stopped
container_name: kitabu-openethereum
image: openethereum/openethereum:v3.3.3
command:
--config=/root/kitabu.toml
--nat='extip:$EXT_IP'
--engine-signer='$ACCOUNT'
--jsonrpc-port=8545
--jsonrpc-cors=all
--jsonrpc-interface=all
--jsonrpc-hosts=all
--jsonrpc-apis=web3,eth,net,parity
--ws-port=8546
--ws-interface=all
--ws-hosts=all
volumes:
- ./key:/root/data/keys/kitabu_sarafu/key
- ./kitabu.json:/root/kitabu.json
- ./kitabu.toml:/root/kitabu.toml
- ./password:/root/password
- ./data:/root/data
expose:
- '8545'
- '8546'
ports:
- '30303:30303'
- '30303:30303/udp'
networks:
- kitabu
networks:
kitabu:
driver: bridge

File diff suppressed because one or more lines are too long

View File

@ -1,22 +0,0 @@
[parity]
chain = "/root/kitabu.json"
base_path = "/root/data"
[network]
max_peers = 25
snapshot_peers = 10
[account]
password = ["/root/password"]
[mining]
reseal_on_txs = "none"
force_sealing = true
min_gas_price = 1
gas_floor_target = "1"
[footprint]
tracing = "on"
pruning = "archive"
pruning_history = 256
cache_size_db = 2000