Merge pull request 'Manage the RSKj node config so upgrades can't mis-network nodes' (#715) from fix/rsk-manage-node-config into master
Reviewed-on: #715
This commit was merged in pull request #715.
This commit is contained in:
6 files changed
+105
-6
No files matched your search
@@ -2,6 +2,14 @@
|
||||
|
||||
This file is used to list changes made in each version of the kosmos_rsk cookbook.
|
||||
|
||||
## 0.6.1
|
||||
|
||||
* Manage `/etc/rsk/node.conf` and the RPC/node config from Chef. The rskj
|
||||
package owns `node.conf` and rewrites it on every configure based on the
|
||||
`shared/config` debconf answer, which is not reliably preserved across
|
||||
upgrades; after a plain package upgrade the question fell back to the default
|
||||
(`mainnet`), so upgraded testnet nodes started syncing the wrong chain.
|
||||
|
||||
## 0.6.0
|
||||
|
||||
* Bump rskj to 9.0.5 (mitigates CVE-2026-114938)
|
||||
|
||||
@@ -2,3 +2,21 @@ node.default['rskj']['version'] = "9.0.5~#{node['lsb']['codename']}"
|
||||
node.default['rskj']['network'] = 'testnet'
|
||||
|
||||
node.default['rskj']['nginx']['domain'] = nil
|
||||
|
||||
# RPC settings for the managed node config (templates/kosmos-node.conf.erb).
|
||||
# The node sits behind the openresty RSK proxies, so it listens on all
|
||||
# interfaces and the proxies add the CORS headers the public API needs.
|
||||
node.default['rskj']['rpc']['bind_address'] = '0.0.0.0'
|
||||
node.default['rskj']['rpc']['cors'] = '*'
|
||||
node.default['rskj']['rpc']['port'] = 4444
|
||||
node.default['rskj']['rpc']['modules'] = {
|
||||
'eth' => 'true',
|
||||
'net' => 'true',
|
||||
'rpc' => 'true',
|
||||
'web3' => 'true',
|
||||
'evm' => 'false',
|
||||
'sco' => 'false',
|
||||
'txpool' => 'true',
|
||||
'debug' => 'false',
|
||||
'personal' => 'true'
|
||||
}
|
||||
@@ -3,7 +3,7 @@ maintainer 'Kosmos Developers'
|
||||
maintainer_email 'ops@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/configures RSKj and related software'
|
||||
version '0.6.0'
|
||||
version '0.6.1'
|
||||
chef_version '>= 18.2'
|
||||
issues_url 'https://gitea.kosmos.org/kosmos/chef/issues'
|
||||
source_url 'https://gitea.kosmos.org/kosmos/chef'
|
||||
|
||||
@@ -27,11 +27,6 @@ execute 'preseed-rskj-license' do
|
||||
not_if 'debconf-get-selections | grep -q "shared/accepted-rsk-license-v1-1.*true"'
|
||||
end
|
||||
|
||||
execute 'preseed-rskj-config' do
|
||||
command "echo \"rskj shared/config select #{node['rskj']['network']}\" | debconf-set-selections"
|
||||
not_if "debconf-get-selections | grep -q \"shared/config.*#{node['rskj']['network']}\""
|
||||
end
|
||||
|
||||
apt_package 'rskj' do
|
||||
options '--assume-yes'
|
||||
version node['rskj']['version']
|
||||
@@ -39,6 +34,37 @@ apt_package 'rskj' do
|
||||
notifies :restart, 'service[rsk]', :delayed
|
||||
end
|
||||
|
||||
# The rskj package owns /etc/rsk/node.conf: its postinst re-asks the
|
||||
# `shared/config` debconf question on every configure and re-points node.conf at
|
||||
# the selected network's shipped config. That debconf state is not reliably
|
||||
# preserved across upgrades -- after a plain package upgrade the question fell
|
||||
# back to the template default ("mainnet") and the node began syncing the wrong
|
||||
# chain from scratch. The shipped configs also bind RPC to 127.0.0.1, which the
|
||||
# openresty proxies cannot reach. So manage our own config and the node.conf
|
||||
# symlink from Chef, after the package has been configured, so a package upgrade
|
||||
# can no longer mis-network the node.
|
||||
rskj_network = node['rskj']['network']
|
||||
rskj_rpc_hosts = ['localhost']
|
||||
rskj_rpc_hosts << node['rskj']['nginx']['domain'] if node['rskj']['nginx']['domain']
|
||||
|
||||
template "/etc/rsk/kosmos-#{rskj_network}.conf" do
|
||||
source 'kosmos-node.conf.erb'
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
variables(
|
||||
network: rskj_network,
|
||||
rpc: node['rskj']['rpc'],
|
||||
hosts: rskj_rpc_hosts
|
||||
)
|
||||
notifies :restart, 'service[rsk]', :delayed
|
||||
end
|
||||
|
||||
link '/etc/rsk/node.conf' do
|
||||
to "/etc/rsk/kosmos-#{rskj_network}.conf"
|
||||
notifies :restart, 'service[rsk]', :delayed
|
||||
end
|
||||
|
||||
service "rsk" do
|
||||
action [:enable, :start]
|
||||
end
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
blockchain.config.name = "<%= @network %>"
|
||||
|
||||
database.dir = /var/lib/rsk/database/<%= @network %>
|
||||
|
||||
rpc {
|
||||
providers : {
|
||||
web: {
|
||||
cors: "<%= @rpc['cors'] %>",
|
||||
http: {
|
||||
enabled: true,
|
||||
bind_address = "<%= @rpc['bind_address'] %>",
|
||||
hosts = [<%= @hosts.map { |host| "\"#{host}\"" }.join(',') %>]
|
||||
port: <%= @rpc['port'] %>,
|
||||
}
|
||||
ws: {
|
||||
enabled: false,
|
||||
bind_address: "<%= @rpc['bind_address'] %>",
|
||||
port: 4445,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modules = [
|
||||
<% @rpc['modules'].each do |name, enabled| -%>
|
||||
{
|
||||
name: "<%= name %>",
|
||||
version: "1.0",
|
||||
enabled: "<%= enabled %>"
|
||||
},
|
||||
<% end -%>
|
||||
]
|
||||
}
|
||||
@@ -33,3 +33,18 @@ describe parse_config_file('/etc/rsk/node.conf', {
|
||||
its(['blockchain.config.name']) { should eq '"testnet"' }
|
||||
its(['database.dir']) { should eq '/var/lib/rsk/database/testnet' }
|
||||
end
|
||||
|
||||
# The node config and the node.conf symlink are managed by Chef, so a package
|
||||
# upgrade can no longer reset them to the default (mainnet) network.
|
||||
describe file('/etc/rsk/kosmos-testnet.conf') do
|
||||
it { should exist }
|
||||
its('content') { should match(/^blockchain\.config\.name = "testnet"$/) }
|
||||
its('content') { should match(%r{^database\.dir = /var/lib/rsk/database/testnet$}) }
|
||||
its('content') { should match(/bind_address = "0\.0\.0\.0"/) }
|
||||
its('content') { should match(/cors: "\*"/) }
|
||||
end
|
||||
|
||||
describe file('/etc/rsk/node.conf') do
|
||||
it { should be_symlink }
|
||||
its('link_path') { should eq '/etc/rsk/kosmos-testnet.conf' }
|
||||
end
|
||||
Reference in new issue
Block a user