Skip to content

Commit 161ace1

Browse files
authored
feat: Support for cutom geneis/chain spec for Besu and Nethermind (#161)
1 parent dc86312 commit 161ace1

File tree

9 files changed

+170
-2
lines changed

9 files changed

+170
-2
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.37.0] - 2024-03-23
9+
10+
### Added
11+
12+
- Support for custom genesis file in Besu and Nethermind
13+
- Molecule test scenario for custom genesis file
14+
815
## [0.36.0] - 2024-03-21
916

1017
### Changed

defaults/main/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,6 @@ container_keystore_dir: /keystore
167167
host_ip_address_to_bind_to: 127.0.0.1
168168

169169
bootnodes: ""
170+
171+
# Nethermind and Besu only
172+
genesis_file: ""

molecule/custom_genesis/molecule.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
role_name_check: 1
3+
dependency:
4+
name: galaxy
5+
options:
6+
ignore-certs: true
7+
ignore-errors: true
8+
role-file: requirements_dev.yml
9+
requirements-file: requirements.yml
10+
11+
12+
driver:
13+
name: vagrant
14+
provider:
15+
name: libvirt
16+
provision: false
17+
cachier: machine
18+
parallel: true
19+
default_box: '${SLINGNODE_BOX:-generic/ubuntu2204}'
20+
21+
22+
platforms:
23+
- name: instance
24+
hostname: slingnode-test-01
25+
config_options:
26+
ssh.keep_alive: true
27+
ssh.remote_user: 'vagrant'
28+
synced_folder: false
29+
memory: 10240
30+
cpus: 4
31+
provider_options:
32+
video_type: 'vga'
33+
driver: 'kvm'
34+
cpu_mode: 'host-passthrough'
35+
video_vram: '16384'
36+
37+
38+
provisioner:
39+
name: ansible
40+
env:
41+
ANSIBLE_PIPELINING: "True"
42+
playbooks:
43+
converge: ../resources/playbooks/converge.yml
44+
prepare: ../resources/playbooks/prepare.yml
45+
inventory:
46+
group_vars:
47+
all:
48+
deploy_consensus: false
49+
deploy_validator: false
50+
clients:
51+
execution: ${SLINGNODE_EXECUTION:-besu}
52+
genesis_file: "molecule/resources/fixtures/{{ 'nethermind_chainspec.json' if clients.execution == 'nethermind' else 'genesis.json' }}"
53+
54+
55+
verifier:
56+
name: ansible
57+
58+
59+
scenario:
60+
name: custom_genesis
61+
test_sequence:
62+
- lint
63+
- destroy
64+
- dependency
65+
- syntax
66+
- create
67+
- prepare
68+
- converge
69+
- verify
70+
- destroy

molecule/custom_genesis/verify.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- name: Verify
3+
hosts: all
4+
become: true
5+
gather_facts: false
6+
7+
tasks:
8+
9+
- name: Include test tasks
10+
ansible.builtin.include_tasks:
11+
file: ../resources/tests/all_clients.yml
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"config": {
3+
"chainId": 1981,
4+
"berlinBlock": 0,
5+
"clique": {
6+
"blockperiodseconds": 15,
7+
"epochlength": 30000
8+
}
9+
},
10+
"coinbase": "0x0000000000000000000000000000000000000000",
11+
"difficulty": "0x1",
12+
"extraData": "0x000000000000000000000000000000000000000000000000000000000000000001a54556254bfa3db2daa7673435ec63649925c50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
13+
"gasLimit": "0x1fffffffffffff",
14+
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
15+
"nonce": "0x0",
16+
"timestamp": "0x5c51a607",
17+
"alloc": {},
18+
"number": "0x0",
19+
"gasUsed": "0x0",
20+
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "Private",
3+
"engine": {
4+
"authorityRound": {
5+
"params": {
6+
"stepDuration": "5",
7+
"validators" : {
8+
"list": ["0x7d577a597b2742b498cb5cf0c26cdcd726d39e6e"]
9+
}
10+
}
11+
}
12+
},
13+
"params": {
14+
"gasLimitBoundDivisor": "0x0400",
15+
"maximumExtraDataSize": "0x20",
16+
"minGasLimit": "0x1388",
17+
"networkID" : "0x2323"
18+
},
19+
"genesis": {
20+
"seal": {
21+
"authorityRound": {
22+
"step": "0x0",
23+
"signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
24+
}
25+
},
26+
"difficulty": "0x20000",
27+
"gasLimit": "0x5B8D80"
28+
},
29+
"accounts": {
30+
"0x0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
31+
"0x0000000000000000000000000000000000000002": { "balance": "1", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
32+
"0x0000000000000000000000000000000000000003": { "balance": "1", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
33+
"0x0000000000000000000000000000000000000004": { "balance": "1", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } }
34+
}
35+
}

tasks/execution.yml

+13
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@
9090
mode: "0700"
9191

9292

93+
- name: Copy custom genesis file to the server (besu and nethermind only)
94+
ansible.builtin.template:
95+
src: "{{ item.src }}"
96+
dest: "{{ item.dest }}"
97+
owner: "{{ execution_client_user.user }}"
98+
group: "{{ execution_client_group.group }}"
99+
mode: "0700"
100+
loop:
101+
- src: "{{ genesis_file }}"
102+
dest: "{{ blockchain_root_path }}/execution/{{ clients.execution }}/genesis.json"
103+
when: genesis_file != "" and (clients.execution == "besu" or clients.execution == "nethermind")
104+
105+
93106
- name: Copy docker-compose files for execution client
94107
ansible.builtin.template:
95108
src: "{{ item.src }}"

templates/dc-blockchain-eth-execution-besu.yml.j2

+5-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ services:
9292
- --engine-jwt-secret=/jwt/{{ jwt_secret_file }}
9393
- --engine-rpc-port={{ execution_client_authrpc_port }}
9494
- --logging={{ besu_log_level }}
95+
{% if not genesis_file %}
9596
- --network={{ network }}
97+
{% endif %}
9698
{% if execution_client_metrics_enabled|bool == True %}
9799
- --metrics-enabled
98100
- --metrics-host=0.0.0.0
@@ -112,7 +114,9 @@ services:
112114
{% if bootnodes %}
113115
- --bootnodes={{ bootnodes }}
114116
{% endif %}
115-
117+
{% if genesis_file %}
118+
- --genesis-file={{ besu_data_dir }}/genesis.json
119+
{% endif %}
116120

117121
networks:
118122
service_net:

templates/dc-blockchain-eth-execution-nethermind.yml.j2

+5-1
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,19 @@ services:
9393
- --Metrics.Enabled={{ execution_client_metrics_enabled | string | lower }}
9494
- --Metrics.ExposePort={{ execution_client_metrics_port }}
9595
- --Metrics.IntervalSeconds={{ nethermind_metrics_intervalseconds }}
96+
{% if not genesis_file %}
9697
- --config={{ network }}
98+
{% endif %}
9799
- --Sync.AncientBodiesBarrier=1
98100
- --Sync.AncientReceiptsBarrier=1
99101
- --log={{ nethermind_log_level }}
100102
- --Pruning.FullPruningMaxDegreeOfParallelism={{ nethermind_pruning_full_pruning_max_degree_of_parallelism }}
101103
{% if bootnodes %}
102104
- --Network.Bootnodes={{ bootnodes }}
103105
{% endif %}
104-
106+
{% if genesis_file %}
107+
- --Init.ChainSpecPath={{ nethermind_data_dir }}/genesis.json
108+
{% endif %}
105109

106110

107111
networks:

0 commit comments

Comments
 (0)