Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

ara/deterministic-timing-rework #1790

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't you add this file to .gitignore or something? or not add it to your commit?

// https://github.com/microsoft/vscode-dev-containers/tree/v0.159.0/containers/javascript-node
{
"name": "Erlang",
"build": {
"dockerfile": "remote.Dockerfile",
"args": { "VARIANT": "24.3.4.0-alpine" }
},

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/sh"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"pgourlain.erlang"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [3000],
}
24 changes: 24 additions & 0 deletions .devcontainer/remote.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# [Choice] alpine,...
ARG VARIANT="alpine"
FROM erlang:${VARIANT} as deps-compiler

ENV DEBIAN_FRONTEND=noninteractive

# Setup rebar diagnostics
ARG REBAR_DIAGNOSTIC=0
ENV DIAGNOSTIC=${REBAR_DIAGNOSTIC}

ENV CC=gcc CXX=g++ CFLAGS="-U__sun__" \
ERLANG_ROCKSDB_OPTS="-DWITH_BUNDLE_SNAPPY=ON -DWITH_BUNDLE_LZ4=ON" \
ERL_COMPILER_OPTIONS="[deterministic]" \
PATH="/root/.cargo/bin:$PATH" \
RUSTFLAGS="-C target-feature=-crt-static"

# Install dependencies to build
RUN apk add --no-cache --update \
autoconf automake bison build-base bzip2 cmake curl \
dbus-dev flex git gmp-dev libsodium-dev libtool linux-headers lz4 \
openssl-dev pkgconfig protoc sed tar wget bash parallel

# Install Rust toolchain
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ helium_gateway

# gwmp-mux generated files
gwmp-mux

.vscode/
9 changes: 5 additions & 4 deletions config/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@
{peerbook_allow_rfc1918, true},
{peer_cache_timeout, 20000},
{sync_cooldown_time, 1},
{skewed_sync_cooldown_time, 1}
{skewed_sync_cooldown_time, 1},
{blocks_to_protect_from_gc, 80}
]},
{miner,
[
{denylist_keys, undefined},
{mode, validator},
{jsonrpc_port, 0},
{use_ebus, false},
{block_time, 500},
{election_interval, 10},
{block_time, 60000},
{election_interval, 30},
{dkg_stop_timeout, 15000},
{write_failed_txns, true},
{radio_device, undefined},
{stabilization_period, 200},
{stabilization_period, 50000},
%% dont perform regionalised checks in test envs
%% we only really need the params below if this file is changed to specify a radio device
%% as without one miner_lora is not started
Expand Down
57 changes: 57 additions & 0 deletions config/test_short.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
%% -*- erlang -*-
[
"config/sys.config",
{lager,
[
{log_root, "log"}
]},
{libp2p, [
{use_dns_for_seeds, false}
]},
{sibyl,
[
{poc_mgr_mod, miner_poc_mgr},
{poc_report_handler, miner_poc_report_handler}
]},
{blockchain,
[
{seed_dns_cname, ""},
{similarity_time_diff_mins, 30},
{random_peer_pred, fun miner_util:true_predicate/1},
{ip_confirmation_host, ""},
{enable_nat, false},
{gossip_version, 1},
{testing, true},
{honor_quick_sync, false},
{listen_addresses, ["/ip4/0.0.0.0/tcp/0"]},
{key, undefined},
{num_consensus_members, 4},
{base_dir, "data"},
{seed_nodes, ""},
{seed_node_dns, ""},
{peerbook_update_interval, 60000},
{peerbook_allow_rfc1918, true},
{peer_cache_timeout, 20000},
{sync_cooldown_time, 1},
{skewed_sync_cooldown_time, 1},
{blocks_to_protect_from_gc, 80}
]},
{miner,
[
{denylist_keys, undefined},
{mode, validator},
{jsonrpc_port, 0},
{use_ebus, false},
{block_time, 60000},
{election_interval, 30},
{dkg_stop_timeout, 15000},
{write_failed_txns, true},
{radio_device, undefined},
{stabilization_period, 2000},
%% dont perform regionalised checks in test envs
%% we only really need the params below if this file is changed to specify a radio device
%% as without one miner_lora is not started
%% including the params anyway in case someone needs it in this env
{region_override, 'US915'}
]}
].
Empty file removed external/.gitkeep
Empty file.
8 changes: 8 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@
{overlay,
[{template, "config/vm_dev.args",
"{{output_dir}}/releases/{{release_version}}/vm.args"}]}]}]},
{cluster, [
{relx, [
{release, {miner, git}, [miner, runtime_tools, tools, recon]},
{sys_config, "./config/test.config"},
{overlay, [{template, "config/vm_dev.args", "{{output_dir}}/releases/{{release_version}}/vm.args"}]}
]
}]
},
{prod, [
{pre_hooks, [
{compile, "make external_svcs"},
Expand Down
4 changes: 4 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ exported_genesis_file="/tmp/genesis_$(date +%Y%m%d%H%M%S)"
LOOP=5
while [ $LOOP -gt 0 ]; do
for node in ${nodes[@]}; do
if [[ ! -e ./_build/testdev\+miner$node/rel/miner$node/bin/miner$node ]]; then
exit 1
fi

if [[ $(./_build/testdev\+miner$node/rel/miner$node/bin/miner$node info in_consensus) = *true* ]]; then
./_build/testdev\+miner$node/rel/miner$node/bin/miner$node genesis export $exported_genesis_file
if [ $? -eq 0 -a -f $exported_genesis_file ]; then
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/miner_hbbft_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ handle_command(start_acs, State) ->
{reply, ok, ignore};
{NewHBBFT, {send, Msgs}} ->
?mark(start_acs_new),
lager:notice("Started HBBFT round because of a block timeout"),
lager:notice("NextRound (~p) starting due to block timeout", [hbbft:round(NewHBBFT)]),
{reply, ok, fixup_msgs(Msgs), State#state{hbbft=NewHBBFT}}
end;
handle_command(get_buf, State) ->
Expand Down Expand Up @@ -192,9 +192,11 @@ handle_command(
Ledger = blockchain:ledger(Chain),
Version = md_version(Ledger),
Seen = blockchain_utils:map_to_bitvector(S#state.seen),
TargetBlockTime = miner:calculate_next_block_time(Chain, true),
HBBFT2 = hbbft:set_stamp_fun(?MODULE, metadata, [Version,
#{seen => Seen,
bba_completion => S#state.bba},
bba_completion => S#state.bba,
target_block_time => TargetBlockTime},
Chain], HBBFT1),
case hbbft:next_round(HBBFT2, NextRound, []) of
{HBBFT3, ok} ->
Expand Down
Loading