mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-10-26 20:40:51 +03:00
Made it able to RAM plot with bladebit2 (#13833)
This commit is contained in:
parent
f9f7448171
commit
b37f2009bd
@ -619,8 +619,6 @@ class WebSocketServer:
|
||||
final_words = ["Renamed final file"]
|
||||
elif plotter == "bladebit":
|
||||
final_words = ["Finished plotting in"]
|
||||
elif plotter == "bladebit2":
|
||||
final_words = ["Finished plotting in"]
|
||||
elif plotter == "madmax":
|
||||
temp_dir = config["temp_dir"]
|
||||
final_dir = config["final_dir"]
|
||||
@ -662,17 +660,17 @@ class WebSocketServer:
|
||||
p = request.get("p") # Pool pubkey
|
||||
c = request.get("c") # Pool contract address
|
||||
|
||||
command_args: List[str] = []
|
||||
command_args.append(f"-n{n}")
|
||||
command_args.append(f"-d{d}")
|
||||
command_args.append(f"-r{r}")
|
||||
command_args: List[str] = ["-n", str(n), "-d", d, "-r", str(r)]
|
||||
|
||||
if f is not None:
|
||||
command_args.append(f"-f{f}")
|
||||
command_args.append("-f")
|
||||
command_args.append(str(f))
|
||||
if p is not None:
|
||||
command_args.append(f"-p{p}")
|
||||
command_args.append("-p")
|
||||
command_args.append(str(p))
|
||||
if c is not None:
|
||||
command_args.append(f"-c{c}")
|
||||
command_args.append("-c")
|
||||
command_args.append(str(c))
|
||||
|
||||
return command_args
|
||||
|
||||
@ -687,15 +685,11 @@ class WebSocketServer:
|
||||
x = request["x"] # Exclude final directory
|
||||
override_k = request["overrideK"] # Force plot sizes < k32
|
||||
|
||||
command_args: List[str] = []
|
||||
command_args.append(f"-k{k}")
|
||||
command_args.append(f"-t{t}")
|
||||
command_args.append(f"-2{t2}")
|
||||
command_args.append(f"-b{b}")
|
||||
command_args.append(f"-u{u}")
|
||||
command_args: List[str] = ["-k", str(k), "-t", t, "-2", t2, "-b", str(b), "-u", str(u)]
|
||||
|
||||
if a is not None:
|
||||
command_args.append(f"-a{a}")
|
||||
command_args.append("-a")
|
||||
command_args.append(str(a))
|
||||
if e is True:
|
||||
command_args.append("-e")
|
||||
if x is True:
|
||||
@ -706,22 +700,26 @@ class WebSocketServer:
|
||||
return command_args
|
||||
|
||||
def _bladebit_plotting_command_args(self, request: Any, ignoreCount: bool) -> List[str]:
|
||||
w = request.get("w", False) # Warm start
|
||||
m = request.get("m", False) # Disable NUMA
|
||||
no_cpu_affinity = request.get("no_cpu_affinity", False)
|
||||
plot_type = request["plot_type"]
|
||||
assert plot_type == "ramplot" or plot_type == "diskplot"
|
||||
|
||||
command_args: List[str] = []
|
||||
|
||||
if w is True:
|
||||
command_args.append("-w")
|
||||
if m is True:
|
||||
command_args.append("-m")
|
||||
if no_cpu_affinity is True:
|
||||
command_args.append("--no-cpu-affinity")
|
||||
if plot_type == "ramplot":
|
||||
w = request.get("w", False) # Warm start
|
||||
m = request.get("m", False) # Disable NUMA
|
||||
no_cpu_affinity = request.get("no_cpu_affinity", False)
|
||||
|
||||
return command_args
|
||||
if w is True:
|
||||
command_args.append("--warmstart")
|
||||
if m is True:
|
||||
command_args.append("--nonuma")
|
||||
if no_cpu_affinity is True:
|
||||
command_args.append("--no-cpu-affinity")
|
||||
|
||||
def _bladebit2_plotting_command_args(self, request: Any, ignoreCount: bool) -> List[str]:
|
||||
return command_args
|
||||
|
||||
# if plot_type == "diskplot"
|
||||
w = request.get("w", False) # Warm start
|
||||
m = request.get("m", False) # Disable NUMA
|
||||
no_cpu_affinity = request.get("no_cpu_affinity", False)
|
||||
@ -739,20 +737,21 @@ class WebSocketServer:
|
||||
no_t1_direct = request.get("no_t1_direct", False)
|
||||
no_t2_direct = request.get("no_t2_direct", False)
|
||||
|
||||
command_args: List[str] = []
|
||||
|
||||
if w is True:
|
||||
command_args.append("-w")
|
||||
command_args.append("--warmstart")
|
||||
if m is True:
|
||||
command_args.append("-m")
|
||||
command_args.append("--nonuma")
|
||||
if no_cpu_affinity is True:
|
||||
command_args.append("--no-cpu-affinity")
|
||||
|
||||
command_args.append(f"-t{t1}")
|
||||
command_args.append("-t")
|
||||
command_args.append(t1)
|
||||
if t2:
|
||||
command_args.append(f"-2{t2}")
|
||||
command_args.append("-2")
|
||||
command_args.append(t2)
|
||||
if u:
|
||||
command_args.append(f"-u{u}")
|
||||
command_args.append("-u")
|
||||
command_args.append(str(u))
|
||||
if cache:
|
||||
command_args.append("--cache")
|
||||
command_args.append(str(cache))
|
||||
@ -810,6 +809,13 @@ class WebSocketServer:
|
||||
plotter: str = request.get("plotter", "chiapos")
|
||||
command_args: List[str] = ["chia", "plotters", plotter]
|
||||
|
||||
if plotter == "bladebit":
|
||||
# plotter command must be either
|
||||
# 'chia plotters bladebit ramplot' or 'chia plotters bladebit diskplot'
|
||||
plot_type = request["plot_type"]
|
||||
assert plot_type == "diskplot" or plot_type == "ramplot"
|
||||
command_args.append(plot_type)
|
||||
|
||||
command_args.extend(self._common_plotting_command_args(request, ignoreCount))
|
||||
|
||||
if plotter == "chiapos":
|
||||
@ -818,8 +824,6 @@ class WebSocketServer:
|
||||
command_args.extend(self._madmax_plotting_command_args(request, ignoreCount, index))
|
||||
elif plotter == "bladebit":
|
||||
command_args.extend(self._bladebit_plotting_command_args(request, ignoreCount))
|
||||
elif plotter == "bladebit2":
|
||||
command_args.extend(self._bladebit2_plotting_command_args(request, ignoreCount))
|
||||
|
||||
return command_args
|
||||
|
||||
|
@ -153,7 +153,7 @@ def get_bladebit_install_info(plotters_root_path: Path) -> Optional[Dict[str, An
|
||||
return info
|
||||
|
||||
|
||||
progress_bladebit1 = {
|
||||
progress_bladebit_ram = {
|
||||
"Finished F1 sort": 0.01,
|
||||
"Finished forward propagating table 2": 0.06,
|
||||
"Finished forward propagating table 3": 0.12,
|
||||
@ -175,7 +175,7 @@ progress_bladebit1 = {
|
||||
}
|
||||
|
||||
|
||||
progress_bladebit2 = {
|
||||
progress_bladebit_disk = {
|
||||
# "Running Phase 1": 0.01,
|
||||
"Finished f1 generation in ": 0.01,
|
||||
"Completed table 2 in ": 0.06,
|
||||
@ -210,26 +210,9 @@ def plot_bladebit(args, chia_root_path, root_path):
|
||||
print(f"Error: {version_or_exception}")
|
||||
return
|
||||
|
||||
version = None
|
||||
if args.plotter == "bladebit":
|
||||
version = 1
|
||||
if found and version_or_exception[0] != "1":
|
||||
print(
|
||||
f"You're trying to run bladebit version 1"
|
||||
f" but currently version {'.'.join(version_or_exception)} is installed"
|
||||
)
|
||||
return
|
||||
elif args.plotter == "bladebit2":
|
||||
version = 2
|
||||
if found and version_or_exception[0] != "2":
|
||||
print(
|
||||
f"You're trying to run bladebit version 2"
|
||||
f" but currently version {'.'.join(version_or_exception)} is installed"
|
||||
)
|
||||
return
|
||||
|
||||
if version is None:
|
||||
print(f"Unknown version of bladebit: {args.plotter}")
|
||||
if found and int(version_or_exception[0]) < 2:
|
||||
print(f"Version {'.'.join(version_or_exception)} is detected.")
|
||||
print("bladebit < 2 is not supported any more.")
|
||||
return
|
||||
|
||||
bladebit_executable_path = get_bladebit_executable_path(root_path)
|
||||
@ -251,75 +234,77 @@ def plot_bladebit(args, chia_root_path, root_path):
|
||||
args.connect_to_daemon,
|
||||
)
|
||||
)
|
||||
plot_type = "ramplot" if args.plot_type == "ramplot" else "diskplot"
|
||||
call_args = [
|
||||
os.fspath(bladebit_executable_path),
|
||||
"-t",
|
||||
"--threads",
|
||||
str(args.threads),
|
||||
"-n",
|
||||
"--count",
|
||||
str(args.count),
|
||||
"-f",
|
||||
"--farmer-key",
|
||||
bytes(plot_keys.farmer_public_key).hex(),
|
||||
]
|
||||
if plot_keys.pool_public_key is not None:
|
||||
call_args.append("-p")
|
||||
call_args.append("--pool-key")
|
||||
call_args.append(bytes(plot_keys.pool_public_key).hex())
|
||||
if plot_keys.pool_contract_address is not None:
|
||||
call_args.append("-c")
|
||||
call_args.append("--pool-contract")
|
||||
call_args.append(plot_keys.pool_contract_address)
|
||||
if args.warmstart:
|
||||
call_args.append("-w")
|
||||
call_args.append("--warm-start")
|
||||
if args.id is not None and args.id != b"":
|
||||
call_args.append("-i")
|
||||
call_args.append("--plot-id")
|
||||
call_args.append(args.id.hex())
|
||||
if args.verbose:
|
||||
call_args.append("-v")
|
||||
if args.nonuma:
|
||||
call_args.append("-m")
|
||||
if args.memo is not None and args.memo != b"":
|
||||
if "memo" in args and args.memo is not None and args.memo != b"":
|
||||
call_args.append("--memo")
|
||||
call_args.append(args.memo)
|
||||
if version > 1:
|
||||
call_args.append("diskplot")
|
||||
if args.buckets:
|
||||
call_args.append("-b")
|
||||
call_args.append(str(args.buckets))
|
||||
if args.tmpdir:
|
||||
call_args.append("-t1")
|
||||
call_args.append(str(args.tmpdir))
|
||||
if args.tmpdir2:
|
||||
call_args.append("-t2")
|
||||
call_args.append(str(args.tmpdir2))
|
||||
if args.nonuma:
|
||||
call_args.append("--no-numa")
|
||||
if args.no_cpu_affinity:
|
||||
call_args.append("--no-cpu-affinity")
|
||||
if args.cache is not None:
|
||||
if args.verbose:
|
||||
call_args.append("--verbose")
|
||||
|
||||
call_args.append(plot_type)
|
||||
|
||||
if "buckets" in args and args.buckets:
|
||||
call_args.append("--buckets")
|
||||
call_args.append(str(args.buckets))
|
||||
if "tmpdir" in args and args.tmpdir:
|
||||
call_args.append("--temp1")
|
||||
call_args.append(str(args.tmpdir))
|
||||
if "tmpdir2" in args and args.tmpdir2:
|
||||
call_args.append("--temp2")
|
||||
call_args.append(str(args.tmpdir2))
|
||||
if "cache" in args and args.cache is not None:
|
||||
call_args.append("--cache")
|
||||
call_args.append(str(args.cache))
|
||||
if args.f1_threads:
|
||||
if "f1_threads" in args and args.f1_threads:
|
||||
call_args.append("--f1-threads")
|
||||
call_args.append(str(args.f1_threads))
|
||||
if args.fp_threads:
|
||||
if "fp_threads" in args and args.fp_threads:
|
||||
call_args.append("--fp-threads")
|
||||
call_args.append(str(args.fp_threads))
|
||||
if args.c_threads:
|
||||
if "c_threads" in args and args.c_threads:
|
||||
call_args.append("--c-threads")
|
||||
call_args.append(str(args.c_threads))
|
||||
if args.p2_threads:
|
||||
if "p2_threads" in args and args.p2_threads:
|
||||
call_args.append("--p2-threads")
|
||||
call_args.append(str(args.p2_threads))
|
||||
if args.p3_threads:
|
||||
if "p3_threads" in args and args.p3_threads:
|
||||
call_args.append("--p3-threads")
|
||||
call_args.append(str(args.p3_threads))
|
||||
if args.alternate:
|
||||
if "alternate" in args and args.alternate:
|
||||
call_args.append("--alternate")
|
||||
if args.no_t1_direct:
|
||||
if "no_t1_direct" in args and args.no_t1_direct:
|
||||
call_args.append("--no-t1-direct")
|
||||
if args.no_t2_direct:
|
||||
if "no_t2_direct" in args and args.no_t2_direct:
|
||||
call_args.append("--no-t2-direct")
|
||||
|
||||
call_args.append(args.finaldir)
|
||||
|
||||
try:
|
||||
progress = progress_bladebit1 if version == 1 else progress_bladebit2
|
||||
progress = progress_bladebit_ram if plot_type == "ramplot" else progress_bladebit_disk
|
||||
asyncio.run(run_plotter(chia_root_path, args.plotter, call_args, progress))
|
||||
except Exception as e:
|
||||
print(f"Exception while plotting: {e} {type(e)}")
|
||||
|
@ -88,7 +88,7 @@ madmax_plotter_options = [
|
||||
Options.FINAL_DIR,
|
||||
]
|
||||
|
||||
bladebit_plotter_options = [
|
||||
bladebit_ram_plotter_options = [
|
||||
Options.NUM_THREADS,
|
||||
Options.PLOT_COUNT,
|
||||
Options.FARMERKEY,
|
||||
@ -97,12 +97,13 @@ bladebit_plotter_options = [
|
||||
Options.ID,
|
||||
Options.BLADEBIT_WARMSTART,
|
||||
Options.BLADEBIT_NONUMA,
|
||||
Options.BLADEBIT_NO_CPU_AFFINITY,
|
||||
Options.VERBOSE,
|
||||
Options.CONNECT_TO_DAEMON,
|
||||
Options.FINAL_DIR,
|
||||
]
|
||||
|
||||
bladebit2_plotter_options = [
|
||||
bladebit_disk_plotter_options = [
|
||||
Options.NUM_THREADS,
|
||||
Options.PLOT_COUNT,
|
||||
Options.FARMERKEY,
|
||||
@ -437,8 +438,13 @@ def call_plotters(root_path: Path, args):
|
||||
|
||||
build_parser(subparsers, root_path, chia_plotter_options, "chiapos", "Create a plot with the default chia plotter")
|
||||
build_parser(subparsers, root_path, madmax_plotter_options, "madmax", "Create a plot with madMAx")
|
||||
build_parser(subparsers, root_path, bladebit_plotter_options, "bladebit", "Create a plot with bladebit")
|
||||
build_parser(subparsers, root_path, bladebit2_plotter_options, "bladebit2", "Create a plot with bladebit2")
|
||||
|
||||
bladebit_parser = subparsers.add_parser("bladebit", help="Create a plot with bladebit")
|
||||
subparsers_bb = bladebit_parser.add_subparsers(dest="plot_type", required=True)
|
||||
build_parser(subparsers_bb, root_path, bladebit_ram_plotter_options, "ramplot", "Create a plot using RAM")
|
||||
build_parser(subparsers_bb, root_path, bladebit_disk_plotter_options, "diskplot", "Create a plot using disk")
|
||||
|
||||
subparsers.add_parser("version", help="Show plotter versions")
|
||||
|
||||
deprecation_warning = (
|
||||
"[DEPRECATED] 'chia plotters install' is no longer available. Use install-plotter.sh/ps1 instead."
|
||||
@ -446,7 +452,9 @@ def call_plotters(root_path: Path, args):
|
||||
install_parser = subparsers.add_parser("install", help=deprecation_warning)
|
||||
install_parser.add_argument("install_plotter", type=str, nargs="*")
|
||||
|
||||
subparsers.add_parser("version", help="Show plotter versions")
|
||||
deprecation_warning_bb2 = "[DEPRECATED] 'chia plotters bladebit2' was integrated to 'chia plotters bladebit'"
|
||||
bladebit2_parser = subparsers.add_parser("bladebit2", help=deprecation_warning_bb2)
|
||||
bladebit2_parser.add_argument("bladebit2_plotter", type=str, nargs="*")
|
||||
|
||||
args = plotters.parse_args(args)
|
||||
|
||||
@ -456,12 +464,14 @@ def call_plotters(root_path: Path, args):
|
||||
plot_chia(args, chia_root_path)
|
||||
elif args.plotter == "madmax":
|
||||
plot_madmax(args, chia_root_path, root_path)
|
||||
elif args.plotter.startswith("bladebit"):
|
||||
elif args.plotter == "bladebit":
|
||||
plot_bladebit(args, chia_root_path, root_path)
|
||||
elif args.plotter == "version":
|
||||
show_plotters_version(chia_root_path)
|
||||
elif args.plotter == "install":
|
||||
print(deprecation_warning)
|
||||
elif args.plotter == "bladebit2":
|
||||
print(deprecation_warning_bb2)
|
||||
|
||||
|
||||
def get_available_plotters(root_path) -> Dict[str, Any]:
|
||||
|
Loading…
Reference in New Issue
Block a user