commit 363de8601d202b5d068d31cc8323b488b4f4df79 Author: Mohammed Sohail Date: Sat Feb 5 12:50:01 2022 +0300 release: kitabu chain v0.1.0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b263945 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +openethereum/.env +openethereum/key +openethereum/data +openethereum/password +devops/caddy \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b3bf12b --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +## 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. diff --git a/devops/Caddyfile b/devops/Caddyfile new file mode 100644 index 0000000..385236d --- /dev/null +++ b/devops/Caddyfile @@ -0,0 +1,12 @@ +rpc.yourdomain { + reverse_proxy openethereum:8545 +} + +ws.yourdomain { + @websockets { + header Connection *Upgrade* + header Upgrade websocket + } + + reverse_proxy @websockets openethereum:8546 +} diff --git a/devops/docker-compose.yml b/devops/docker-compose.yml new file mode 100644 index 0000000..14d58b8 --- /dev/null +++ b/devops/docker-compose.yml @@ -0,0 +1,17 @@ +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 diff --git a/openethereum/.env.example b/openethereum/.env.example new file mode 100644 index 0000000..fe09ed2 --- /dev/null +++ b/openethereum/.env.example @@ -0,0 +1,2 @@ +EXT_IP= +ACCOUNT= \ No newline at end of file diff --git a/openethereum/docker-compose.yml b/openethereum/docker-compose.yml new file mode 100644 index 0000000..55a9f50 --- /dev/null +++ b/openethereum/docker-compose.yml @@ -0,0 +1,37 @@ +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 diff --git a/openethereum/kitabu.json b/openethereum/kitabu.json new file mode 100644 index 0000000..48c6e86 --- /dev/null +++ b/openethereum/kitabu.json @@ -0,0 +1,205 @@ +{ + "name": "Kitabu Sarafu", + "dataDir": "kitabu_sarafu", + "engine": { + "authorityRound": { + "params": { + "stepDuration": 4, + "maximumUncleCountTransition": 0, + "maximumUncleCount": 0, + "emptyStepsTransition": 4, + "maximumEmptySteps": 60, + "validators": { + "safeContract": "0x000000000000000000000000000000000000000a" + } + } + } + }, + "params": { + "accountStartNonce": "0x0", + "chainID": "0x13ba", + "eip140Transition": "0x0", + "eip145Transition": "0x0", + "eip150Transition": "0x0", + "eip155Transition": "0x0", + "eip160Transition": "0x0", + "eip161abcTransition": "0x0", + "eip161dTransition": "0x0", + "eip211Transition": "0x0", + "eip214Transition": "0x0", + "eip658Transition": "0x0", + "eip1014Transition": "0x0", + "eip1052Transition": "0x0", + "eip1283Transition": "0x0", + "eip1283DisableTransition": "0x0", + "eip1283ReenableTransition": "0x0", + "eip1344Transition": "0x0", + "eip1706Transition": "0x0", + "eip1884Transition": "0x0", + "eip2028Transition": "0x0", + "eip1559Transition": "0x1", + "eip1559BaseFeeMaxChangeDenominator": "0x8", + "eip1559ElasticityMultiplier": "0x2", + "gasLimitBoundDivisor": "0x400", + "maxCodeSize": "0x6000", + "maxCodeSizeTransition": "0x0", + "maximumExtraDataSize": "0xffff", + "minGasLimit": "0x1", + "networkID": "0x13ba" + }, + "genesis": { + "seal": { + "authorityRound": { + "step": "0x0", + "signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + } + }, + "difficulty": "0x2", + "gasLimit": "0x5b8d80" + }, + "accounts": { + "0x0000000000000000000000000000000000000000": { + "balance": "0x1" + }, + "0x0000000000000000000000000000000000000001": { + "balance": "0x1", + "builtin": { + "name": "ecrecover", + "pricing": { + "linear": { + "base": 3000, + "word": 0 + } + } + } + }, + "0x0000000000000000000000000000000000000002": { + "balance": "0x1", + "builtin": { + "name": "sha256", + "pricing": { + "linear": { + "base": 60, + "word": 12 + } + } + } + }, + "0x0000000000000000000000000000000000000003": { + "balance": "0x1", + "builtin": { + "name": "ripemd160", + "pricing": { + "linear": { + "base": 600, + "word": 120 + } + } + } + }, + "0x0000000000000000000000000000000000000004": { + "balance": "0x1", + "builtin": { + "name": "identity", + "pricing": { + "linear": { + "base": 15, + "word": 3 + } + } + } + }, + "0x0000000000000000000000000000000000000005": { + "balance": "0x1", + "builtin": { + "name": "modexp", + "pricing": { + "0x0": { + "info": "EIP-198: Big integer modular exponentiation. Byzantium hardfork", + "price": { + "modexp": { + "divisor": 20 + } + } + }, + "0x441064": { + "info": "EIP-2565: ModExp Gas Cost. Berlin hardfork (4_460_644)", + "price": { + "modexp2565": {} + } + } + } + } + }, + "0x0000000000000000000000000000000000000006": { + "balance": "0x1", + "builtin": { + "name": "alt_bn128_add", + "pricing": { + "0": { + "price": { "alt_bn128_const_operations": { "price": 500 } } + }, + "0x17d433": { + "info": "EIP 1108 transition at block 1_561_651 (0x17d433)", + "price": { "alt_bn128_const_operations": { "price": 150 } } + } + } + } + }, + "0x0000000000000000000000000000000000000007": { + "balance": "0x1", + "builtin": { + "name": "alt_bn128_mul", + "pricing": { + "0": { + "price": { "alt_bn128_const_operations": { "price": 40000 } } + }, + "0x17d433": { + "info": "EIP 1108 transition at block 1_561_651 (0x17d433)", + "price": { "alt_bn128_const_operations": { "price": 6000 } } + } + } + } + }, + "0x0000000000000000000000000000000000000008": { + "balance": "0x1", + "builtin": { + "name": "alt_bn128_pairing", + "pricing": { + "0": { + "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 } } + }, + "0x17d433": { + "info": "EIP 1108 transition at block 1_561_651 (0x17d433)", + "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 } } + } + } + } + }, + "0x0000000000000000000000000000000000000009": { + "balance": "0x1", + "builtin": { + "name": "blake2_f", + "activate_at": "0x17d433", + "pricing": { + "blake2_f": { + "gas_per_round": 1 + } + } + } + }, + "0x000000000000000000000000000000000000000a": { + "balance": "0x1", + "constructor": "0x6080604052739f57b4a25638f3bdffcb1f3d2902860601a1aa656000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604051806020016040528073d36ac22d450a9b3a08969cf057fb40e9b2c2640a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681525060019060016100b7929190610218565b503480156100c457600080fd5b5060005b6001805490508110156101f7576002600182815481106100e457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600460006001848154811061018157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080806001019150506100c8565b506001600360006101000a81548160ff0219169083151502179055506102dd565b828054828255906000526020600020908101928215610291579160200282015b828111156102905782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190610238565b5b50905061029e91906102a2565b5090565b5b808211156102d957600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055506001016102a3565b5090565b6108ae806102ec6000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063a7873c1b1161005b578063a7873c1b14610114578063b3f05b9714610148578063b7ab4db514610168578063f559ae80146101c75761007d565b806340a141ff146100825780634d238c8e146100c6578063752862111461010a575b600080fd5b6100c46004803603602081101561009857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061020b565b005b610108600480360360208110156100dc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610312565b005b61011261043d565b005b61011c610506565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61015061052a565b60405180821515815260200191505060405180910390f35b61017061053d565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156101b3578082015181840152602081019050610198565b505050509050019250505060405180910390f35b610209600480360360208110156101dd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506105cb565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461026357600080fd5b600360009054906101000a900460ff1661027c57600080fd5b6102c4600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546106e0565b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000905561030f6107d7565b50565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461036a57600080fd5b600360009054906101000a900460ff1661038357600080fd5b6002819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160028054905003600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061043a6107d7565b50565b6001600360006101000a81548160ff0219169083151502179055507f8564cd629b15f47dc310d45bcbfc9bcf5420b0d51bf0659a16c67f91d27632536002604051808060200182810382528381815481526020019150805480156104f657602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116104ac575b50509250505060405180910390a1565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900460ff1681565b606060028054806020026020016040519081016040528092919081815260200182805480156105c157602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610577575b5050505050905090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461062357600080fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f39487b135b88702be9a144e7066245bf92d7fac0f685ddcf8e721cabfa5a912760405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008190505b600160028054905003811015610793576002600182018154811061070657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166002828154811061073e57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080806001019150506106e6565b50600280548061079f57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055905550565b6000600360006101000a81548160ff02191690831515021790555060014303407f55252fa6eee4741b4e24a74a70e9c11fd2c2281df8d6ea13126ff845f7825c8961082061053d565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610863578082015181840152602081019050610848565b505050509050019250505060405180910390a256fea2646970667358221220ede1992767acd8d86f2946bc23a83d9df282223dc0144b6bf1ef16f5d7c15a0464736f6c634300060c0033" + }, + "0x77Bea3320Fa46aFF3C7c128B83F5E436596Ba73D": { + "balance": "0x204fce5e3e25026110000000" + }, + "0x9F57B4A25638F3bdfFcB1F3d2902860601a1Aa65": { + "balance": "0x204fce5e3e25026110000000" + }, + "0x0568a760219d13Dd3d4f4cBC13e0Fe4b138CaB24": { + "balance": "0x204fce5e3e25026110000000" + } + } +} diff --git a/openethereum/kitabu.toml b/openethereum/kitabu.toml new file mode 100644 index 0000000..0178be9 --- /dev/null +++ b/openethereum/kitabu.toml @@ -0,0 +1,22 @@ +[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