2 Commits

Author SHA1 Message Date
Jarvis Carroll 8d3d30425b Fix semicolon 2025-06-24 07:04:32 +10:00
spivee 92d061f572 Disable AVX2 for now
AVX2 is much less available than one would expect, is hard for e.g. me to test, and because of the way gmhive_worker currently works, the illegal-instruction exit codes go undetected, leaving users confused as their balance stays at zero, despite the app saying they are getting solutions.
2025-06-23 22:19:04 +09:00
7 changed files with 41 additions and 102 deletions
+1 -1
View File
@@ -3,6 +3,6 @@
{registered,[]}, {registered,[]},
{included_applications,[]}, {included_applications,[]},
{applications,[stdlib,kernel]}, {applications,[stdlib,kernel]},
{vsn,"0.3.6"}, {vsn,"0.2.5"},
{modules,[gajumine,gmc_con,gmc_conf,gmc_gui,gmc_sup]}, {modules,[gajumine,gmc_con,gmc_conf,gmc_gui,gmc_sup]},
{mod,{gajumine,[]}}]}. {mod,{gajumine,[]}}]}.
+1 -2
View File
@@ -3,7 +3,7 @@
%%% @end %%% @end
-module(gajumine). -module(gajumine).
-vsn("0.3.6"). -vsn("0.2.5").
-behavior(application). -behavior(application).
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <craigeverett@qpq.swiss>"). -copyright("QPQ AG <craigeverett@qpq.swiss>").
@@ -29,7 +29,6 @@ start(normal, _Args) ->
{ok, _} = application:ensure_all_started(ssl), {ok, _} = application:ensure_all_started(ssl),
ok = application:ensure_started(hakuzaru), ok = application:ensure_started(hakuzaru),
ok = application:ensure_started(zxwidgets), ok = application:ensure_started(zxwidgets),
ok = application:ensure_started(gproc),
gmc_sup:start_link(). gmc_sup:start_link().
+9 -40
View File
@@ -3,7 +3,7 @@
%%% @end %%% @end
-module(gmc_con). -module(gmc_con).
-vsn("0.3.6"). -vsn("0.2.5").
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <craigeverett@qpq.swiss>"). -copyright("QPQ AG <craigeverett@qpq.swiss>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").
@@ -101,28 +101,16 @@ start_link() ->
init(none) -> init(none) ->
ok = log(info, "Starting"), ok = log(info, "Starting"),
{AProcs, AMem} = proc_mem(),
TwoMaps = default_spec(mem) * 2,
RProcs =
case AProcs >= 2 of
true -> 2;
false -> 1
end,
RMem =
case AMem >= TwoMaps of
true -> TwoMaps;
false -> default_spec(mem)
end,
{Acc, Keys, Network, MaxCores, MaxMem} = {Acc, Keys, Network, MaxCores, MaxMem} =
case read_conf() of case read_conf() of
{ok, C} -> {ok, C} ->
{maps:get(account, C, none), {maps:get(account, C, none),
maps:get(keys, C, []), maps:get(keys, C, []),
maps:get(network, C, <<"mainnet">>), maps:get(network, C, <<"mainnet">>),
maps:get(max_cores, C, RProcs), maps:get(max_cores, C, 2),
maps:get(max_mem, C, RMem)}; maps:get(max_mem, C, 3550722201)};
none -> none ->
{none, [], <<"mainnet">>, RProcs, RMem} {none, [], <<"mainnet">>, 2, 3550722201}
end, end,
State = #s{network = Network, acc = Acc, keys = Keys, max_cores = MaxCores, max_mem = MaxMem}, State = #s{network = Network, acc = Acc, keys = Keys, max_cores = MaxCores, max_mem = MaxMem},
{ok, start_gui(State)}. {ok, start_gui(State)}.
@@ -136,11 +124,6 @@ start_gui(State = #s{acc = none}) ->
start_gui(State = #s{acc = AccID}) -> start_gui(State = #s{acc = AccID}) ->
Window = gmc_gui:start_link(#{}), Window = gmc_gui:start_link(#{}),
ok = gmc_gui:set_account(AccID), ok = gmc_gui:set_account(AccID),
ok =
case lists:member("autostart", zx_daemon:argv()) of
false -> ok;
true -> gmc_gui:start_stop()
end,
State#s{window = Window}. State#s{window = Window}.
@@ -222,10 +205,7 @@ do_start_stop(#s{acc = PubKey, keys = Keys, network = Network, max_cores = MaxCo
{Fatness, Type} = {Fatness, Type} =
case os:type() of case os:type() of
{unix, linux} -> {unix, linux} ->
case Network of {"mean", "generic"};
<<"mainnet">> -> {"mean", "avx2"};
<<"testnet">> -> {"mean", "generic"}
end;
{unix, darwin} -> {unix, darwin} ->
% Check memory. >7gb gets mean, <7gb gets lean % Check memory. >7gb gets mean, <7gb gets lean
{"mean", "generic"}; {"mean", "generic"};
@@ -233,11 +213,7 @@ do_start_stop(#s{acc = PubKey, keys = Keys, network = Network, max_cores = MaxCo
% Check memory. >7gb gets mean, <7gb gets lean % Check memory. >7gb gets mean, <7gb gets lean
% Check avx2. % Check avx2.
% Both should be provided by the F# start program % Both should be provided by the F# start program
case Network of {"mean", "generic"}
% <<"mainnet">> -> {"mean", "avx2.exe"};
<<"mainnet">> -> {"mean", "generic.exe"};
<<"testnet">> -> {"mean", "generic.exe"}
end
end, end,
Miner = filename:join(platform_dir(), unicode:characters_to_binary([Fatness, Bits, "-", Type])), Miner = filename:join(platform_dir(), unicode:characters_to_binary([Fatness, Bits, "-", Type])),
Count = optimize_count(MaxCores, MaxMem), Count = optimize_count(MaxCores, MaxMem),
@@ -270,7 +246,7 @@ optimize_count(MaxC, MaxM) ->
MaxMem = max(MapSize, MaxM), MaxMem = max(MapSize, MaxM),
{Procs, Memory} = proc_mem(), {Procs, Memory} = proc_mem(),
MeanMaps = min(MaxMem, Memory) div MapSize, MeanMaps = min(MaxMem, Memory) div MapSize,
Recommended = min(MaxCores, min(Procs, MeanMaps)), Recommended = min(MaxCores, max(min(Procs, MeanMaps) - 1, 1)),
Notice = fun(F, A) -> gmc_gui:message({notice, io_lib:format(F, A)}) end, Notice = fun(F, A) -> gmc_gui:message({notice, io_lib:format(F, A)}) end,
ok = Notice("Physical Processors: ~p", [Procs]), ok = Notice("Physical Processors: ~p", [Procs]),
ok = Notice("Physical Memory: ~p", [Memory]), ok = Notice("Physical Memory: ~p", [Memory]),
@@ -288,15 +264,8 @@ platform_dir() ->
{unix, linux} -> {unix, linux} ->
"linux_x86_64"; "linux_x86_64";
{unix, darwin} -> {unix, darwin} ->
case string:trim(os:cmd("uname -m")) of % TODO: Check M2 vs x86
"arm64" -> "mac_m2";
"mac_arm64";
"x86_64" ->
"mac_x86_64";
Other ->
ok = log(info, "uname -m: ~p", [Other]),
"mac_x86_64"
end;
{win32, nt} -> {win32, nt} ->
"win_x86_64" "win_x86_64"
end, end,
+19 -19
View File
@@ -3,7 +3,7 @@
%%% @end %%% @end
-module(gmc_conf). -module(gmc_conf).
-vsn("0.3.6"). -vsn("0.2.5").
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <craigeverett@qpq.swiss>"). -copyright("QPQ AG <craigeverett@qpq.swiss>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").
@@ -18,15 +18,15 @@
-record(s, -record(s,
{wx = none :: none | wx:wx_object(), {wx = none :: none | wx:wx_object(),
frame = none :: none | wx:wx_object(), frame = none :: none | wx:wx_object(),
lang = en :: en | jp, lang = en :: en | jp,
j = none :: none | fun(), j = none :: none | fun(),
net = none :: none | wx:wx_object(), net = none :: none | wx:wx_object(),
acc = none :: none | wx:wx_object(), acc = none :: none | wx:wx_object(),
keys = none :: none | wx:wx_object(), keys = none :: none | wx:wx_object(),
cores = 2 :: pos_integer(), cores = none :: none | wx:wx_object(),
memory = 3550722201 :: pos_integer()}). memory = none :: none | wx:wx_object()}).
@@ -97,9 +97,9 @@ init({Prefs, {Net, Acc, Keys, {AProcs, AMem, MProcs, MMem}}}) ->
ok = wxFrame:center(Frame), ok = wxFrame:center(Frame),
true = wxFrame:show(Frame), true = wxFrame:show(Frame),
State = State =
#s{wx = WX, frame = Frame, #s{wx = WX, frame = Frame,
lang = Lang, j = J, lang = Lang, j = J,
net = Network, acc = AccTx, keys = KeysTx, net = Network, acc = AccTx, keys = KeysTx,
cores = CoresTx, memory = MemoryTx}, cores = CoresTx, memory = MemoryTx},
{Frame, State}. {Frame, State}.
@@ -205,7 +205,7 @@ done(State = #s{net = Network, acc = AccTx, keys = KeysTx, cores = CoresTx, memo
1 -> <<"testnet">>; 1 -> <<"testnet">>;
_ -> <<"mainnet">> _ -> <<"mainnet">>
end, end,
AccID = string:trim(wxTextCtrl:getValue(AccTx)), AccID = wxTextCtrl:getValue(AccTx),
MOAR_IDs = wxTextCtrl:getValue(KeysTx), MOAR_IDs = wxTextCtrl:getValue(KeysTx),
CoreS = wxTextCtrl:getValue(CoresTx), CoreS = wxTextCtrl:getValue(CoresTx),
GigsS = wxTextCtrl:getValue(MemTx), GigsS = wxTextCtrl:getValue(MemTx),
@@ -213,16 +213,16 @@ done(State = #s{net = Network, acc = AccTx, keys = KeysTx, cores = CoresTx, memo
buh_bye(State). buh_bye(State).
cores("") -> cores("") ->
2; none;
cores(CoreS) -> cores(CoreS) ->
try try
list_to_integer(CoreS) list_to_integer(CoreS)
catch catch
_:_ -> 2 _:_ -> none
end. end.
bytes("") -> bytes("") ->
3550722201; none;
bytes(GigsS) -> bytes(GigsS) ->
try try
list_to_integer(GigsS) * gig() list_to_integer(GigsS) * gig()
@@ -231,14 +231,14 @@ bytes(GigsS) ->
try try
trunc(list_to_float(GigsS) * gig()) trunc(list_to_float(GigsS) * gig())
catch catch
_:_ -> 3550722201 _:_ -> none
end end
end. end.
% NOTE: 32 is space, 12288 is full-width space. % NOTE: 32 is space, 12288 is full-width space.
binify_keys(MOAR) -> binify_keys(MOAR) ->
lists:usort([list_to_binary(K) || K <- string:lexemes(MOAR, [$\r, $\n, 32, 12288, $\t, $,, $;])]). [list_to_binary(K) || K <- string:lexemes(MOAR, [$\r, $\n, 32, 12288, $\t, $,, $;])].
acc(none) -> ""; acc(none) -> "";
+3 -32
View File
@@ -3,14 +3,14 @@
%%% @end %%% @end
-module(gmc_gui). -module(gmc_gui).
-vsn("0.3.6"). -vsn("0.2.5").
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <craigeverett@qpq.swiss>"). -copyright("QPQ AG <craigeverett@qpq.swiss>").
-license("GPL-3.0-or-later"). -license("GPL-3.0-or-later").
-behavior(wx_object). -behavior(wx_object).
-include_lib("wx/include/wx.hrl"). -include_lib("wx/include/wx.hrl").
-export([ask_conf/0, set_account/1, difficulty/1, speed/1, candidate/1, message/1, start_stop/0]). -export([ask_conf/0, set_account/1, difficulty/1, speed/1, candidate/1, message/1]).
-export([start_link/1]). -export([start_link/1]).
-export([init/1, terminate/2, code_change/3, -export([init/1, terminate/2, code_change/3,
handle_call/3, handle_cast/2, handle_info/2, handle_event/2]). handle_call/3, handle_cast/2, handle_info/2, handle_event/2]).
@@ -79,10 +79,6 @@ message(Terms) ->
wx_object:cast(?MODULE, {message, Terms}). wx_object:cast(?MODULE, {message, Terms}).
start_stop() ->
wx_object:cast(?MODULE, start_stop).
%%% Startup Functions %%% Startup Functions
@@ -191,9 +187,6 @@ handle_cast({candidate, Block}, State) ->
handle_cast({message, Terms}, State) -> handle_cast({message, Terms}, State) ->
NewState = do_message(Terms, State), NewState = do_message(Terms, State),
{noreply, NewState}; {noreply, NewState};
handle_cast(start_stop, State) ->
NewState = start_stop(State),
{noreply, NewState};
handle_cast(Unexpected, State) -> handle_cast(Unexpected, State) ->
ok = log(warning, "Unexpected cast: ~tp~n", [Unexpected]), ok = log(warning, "Unexpected cast: ~tp~n", [Unexpected]),
{noreply, State}. {noreply, State}.
@@ -284,7 +277,7 @@ do_message({pool_notification, #{info := #{msg := MSG}}}, State = #s{height = He
ok = wxStaticText:setLabel(CandT, Candidate), ok = wxStaticText:setLabel(CandT, Candidate),
State; State;
#{solution_accepted := #{seq := Seq}} -> #{solution_accepted := #{seq := Seq}} ->
Entry = io_lib:format("~nThe hive has produced a solution! Sequence: ~w", [Seq]), Entry = io_lib:format("~nSolution Accepted! You solved one! Sequence: ~w", [Seq]),
do_message2(Entry, State); do_message2(Entry, State);
Other -> Other ->
Entry = io_lib:format("~nUnexpected 'pool_notification': ~tp", [Other]), Entry = io_lib:format("~nUnexpected 'pool_notification': ~tp", [Other]),
@@ -296,28 +289,6 @@ do_message({connected, _}, State) ->
do_message({disconnected, _}, State) -> do_message({disconnected, _}, State) ->
Entry = "\nDisconnected!", Entry = "\nDisconnected!",
do_message2(Entry, State); do_message2(Entry, State);
do_message({error, #{info := #{info := #{error := get_failed, data := {error, #{code := 404}}, url := URL}}}}, State) ->
ID =
case uri_string:parse(URL) of
#{path := Path} ->
lists:last(string:split(Path, "/", trailing));
{error, Reason, Info} ->
ok = log(warning, "uri_string:parse/1 failed with: ~p: ~p", [Reason, Info]),
"UNKNOWN"
end,
Format =
"\nLookup for mining ID ~s failed."
"\nCheck that you have joined the hive and have your account ID configured correctly.",
Entry = io_lib:format(Format, [ID]),
do_message2(Entry, State);
do_message({error, #{info := #{info := #{error := get_failed, data := {error, #{code := 443}}}}}}, State) ->
Entry =
"\nThis system is not providing the needed TLS CA Certificate."
"\nlease contact the support community and let them know you have a 443 error with GajuMine.",
do_message2(Entry, State);
do_message({error, #{info := #{info := #{error := connect_failure, data := {error, failed}}, module := gmhc_eureka}}}, State) ->
Entry = "\nConnection terminated. Retrying.",
do_message2(Entry, State);
do_message(Terms, State) -> do_message(Terms, State) ->
tell(info, "~p", [Terms]), tell(info, "~p", [Terms]),
Entry = io_lib:format("~n~tp", [Terms]), Entry = io_lib:format("~n~tp", [Terms]),
+1 -1
View File
@@ -12,7 +12,7 @@
%%% @end %%% @end
-module(gmc_sup). -module(gmc_sup).
-vsn("0.3.6"). -vsn("0.2.5").
-behaviour(supervisor). -behaviour(supervisor).
-author("Craig Everett <craigeverett@qpq.swiss>"). -author("Craig Everett <craigeverett@qpq.swiss>").
-copyright("QPQ AG <craigeverett@qpq.swiss>"). -copyright("QPQ AG <craigeverett@qpq.swiss>").
+7 -7
View File
@@ -2,16 +2,16 @@
{type,gui}. {type,gui}.
{modules,[]}. {modules,[]}.
{prefix,"gmc"}. {prefix,"gmc"}.
{desc,"Mining client for the Gajumaru Root"}.
{author,"Craig Everett"}. {author,"Craig Everett"}.
{package_id,{"qpq","gajumine",{0,3,6}}}. {desc,"Mining client for the Gajumaru Root"}.
{deps,[{"uwiger","gmhive_client",{0,9,3}}, {package_id,{"qpq","gajumine",{0,2,5}}}.
{"uwiger","gmhive_protocol",{0,2,0}}, {deps,[{"uwiger","gmhive_client",{0,4,4}},
{"uwiger","gmcuckoo",{1,2,4}}, {"uwiger","gmcuckoo",{1,2,3}},
{"uwiger","gmhive_worker",{0,5,1}}, {"qpq","cuckoo_cpu",{0,3,0}},
{"qpq","cuckoo_cpu",{0,3,2}}, {"uwiger","gmhive_worker",{0,3,0}},
{"uwiger","gmconfig",{0,1,2}}, {"uwiger","gmconfig",{0,1,2}},
{"uwiger","gproc",{1,0,1}}, {"uwiger","gproc",{1,0,1}},
{"uwiger","gmhive_protocol",{0,1,1}},
{"uwiger","enoise",{1,3,0}}, {"uwiger","enoise",{1,3,0}},
{"uwiger","setup",{2,2,4}}, {"uwiger","setup",{2,2,4}},
{"otpr","hakuzaru",{0,6,1}}, {"otpr","hakuzaru",{0,6,1}},