Skip to content

Commit

Permalink
Fix grpcurl enforcer status check, update btc conf
Browse files Browse the repository at this point in the history
* Fix grpcurl request to check on enforcer. Use
  cusf.mainchain.v1.ValidatorService.GetChainTip

* Add signet setting to bitcoin.conf
  • Loading branch information
CryptAxe committed Nov 5, 2024
1 parent 199fac7 commit b4bade9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cusf_launcher/scene/main_window.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ layout_mode = 2
[connection signal="configuration_complete" from="Configuration" to="." method="_on_configuration_complete"]
[connection signal="btc_new_block_count" from="RPCClient" to="." method="_on_rpc_client_btc_new_block_count"]
[connection signal="btc_rpc_failed" from="RPCClient" to="." method="_on_rpc_client_btc_rpc_failed"]
[connection signal="cusf_drivechain_new_block_count" from="RPCClient" to="." method="_on_rpc_client_cusf_drivechain_new_block_count"]
[connection signal="cusf_drivechain_responded" from="RPCClient" to="." method="_on_rpc_client_cusf_drivechain_responded"]
[connection signal="cusf_drivechain_rpc_failed" from="RPCClient" to="." method="_on_rpc_client_cusf_drivechain_rpc_failed"]
[connection signal="thunder_cli_failed" from="RPCClient" to="." method="_on_rpc_client_thunder_cli_failed"]
[connection signal="thunder_new_block_count" from="RPCClient" to="." method="_on_rpc_client_thunder_new_block_count"]
Expand Down
1 change: 1 addition & 0 deletions cusf_launcher/script/configuration.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ signetchallenge=00141f61d57873d70d28bd28b3c9f9d6bf818b5a0d6a
zmqpubsequence=tcp://0.0.0.0:29000
txindex=1
server=1
signet=1
'''

signal configuration_complete
Expand Down
13 changes: 6 additions & 7 deletions cusf_launcher/script/main_window.gd
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ func kill_started_pid() -> void:


func check_running_status() -> void:
# TODO re - enable
return

$RPCClient.rpc_bitcoin_getblockcount()
$RPCClient.grpc_enforcer_getmainblockcount()
$RPCClient.grpc_enforcer_gettip()
$RPCClient.cli_thunder_getblockcount()


Expand Down Expand Up @@ -168,16 +165,18 @@ func _on_button_start_l1_pressed() -> void:
var user_dir : String = OS.get_user_data_dir()

# Start bitcoin
var ret : int = OS.create_process(str(user_dir, "/L1-bitcoin-patched-latest-x86_64-unknown-linux-gnu/qt/bitcoin-qt"), ["--connect=0", "--signet"])
var ret : int = OS.create_process(str(user_dir, "/L1-bitcoin-patched-latest-x86_64-unknown-linux-gnu/qt/bitcoin-qt"), [])
if ret == -1:
printerr("Failed to start bitcoin")
return
else:
started_pid.push_back(ret)
print("started bitcoin with pid: ", ret)

await get_tree().create_timer(5).timeout

# Start bip300-301 enforcer
ret = OS.create_process(str(user_dir, "/bip300301-enforcer-latest-x86_64-unknown-linux-gnu/bip300301_enforcer-0.1.0-x86_64-unknown-linux-gnu"), ["--node-rpc-addr=127.0.01:38332", "--node-rpc-user=user", "--node-rpc-pass=password", "--node-zmq-addr-sequence=tcp://0.0.0.0:29000"])
ret = OS.create_process(str(user_dir, "/bip300301-enforcer-latest-x86_64-unknown-linux-gnu/bip300301_enforcer-0.1.0-x86_64-unknown-linux-gnu"), ["--node-rpc-addr=localhost:38332", "--node-rpc-user=user", "--node-rpc-pass=password", "--node-zmq-addr-sequence=tcp://0.0.0.0:29000"])
if ret == -1:
printerr("Failed to start enforcer")
return
Expand Down Expand Up @@ -227,7 +226,7 @@ func _on_rpc_client_btc_rpc_failed() -> void:
$MarginContainer/VBoxContainer/HBoxContainerPageAndPageButtons/PanelContainerPages/OverviewPage/GridContainer/PanelContainerL1/VBoxContainer/LabelL1RunStatusBTC.text = "Failed to contact BTC!"


func _on_rpc_client_cusf_drivechain_new_block_count(height: int) -> void:
func _on_rpc_client_cusf_drivechain_responded() -> void:
$MarginContainer/VBoxContainer/HBoxContainerPageAndPageButtons/PanelContainerPages/OverviewPage/GridContainer/PanelContainerL1/VBoxContainer/LabelL1RunStatusEnforcer.text = "Drivechain Enforcer Running!"


Expand Down
1 change: 0 additions & 1 deletion cusf_launcher/script/resource_downloader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const URL_300301_ENFORCER_LIN : String = "https://releases.drivechain.info/bip3
const URL_300301_ENFORCER_WIN : String = "https://releases.drivechain.info/bip300301-enforcer-latest-x86_64-pc-windows-gnu.zip"
const URL_300301_ENFORCER_OSX : String = "https://releases.drivechain.info/bip300301-enforcer-latest-x86_64-apple-darwin.zip"

# TODO this is the wrong version for the enforcer, but I'm not sure what is correct anymore.
const URL_BITCOIN_PATCHED_LIN : String = "https://releases.drivechain.info/L1-bitcoin-patched-latest-x86_64-unknown-linux-gnu.zip"
const URL_BITCOIN_PATCHED_WIN : String = "https://releases.drivechain.info/L1-bitcoin-patched-latest-x86_64-w64-mingw32.zip"
const URL_BITCOIN_PATCHED_OSX : String = "https://releases.drivechain.info/L1-bitcoin-patched-latest-x86_64-apple-darwin.zip"
Expand Down
23 changes: 10 additions & 13 deletions cusf_launcher/script/rpc_client.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const DEFAULT_CUSF_DRIVECHAIN_RPC_PORT : int = 50051

const DEBUG_REQUESTS : bool = true

const GRPC_CUSF_DRIVECHAIN_GET_HEIGHT : String = "validator.Validator/GetMainBlockHeight"
const GRPC_CUSF_DRIVECHAIN_GET_TIP : String = "cusf.mainchain.v1.ValidatorService.GetChainTip"

# Signals that should be emitted regularly if connections are working
signal btc_new_block_count(height : int)
signal cusf_drivechain_new_block_count(height : int)
signal cusf_drivechain_responded()
signal thunder_new_block_count(height : int)

# Signals that indicate connection failure to one of the backend softwares
Expand All @@ -25,13 +25,12 @@ var core_auth_cookie : String = "user:password"

@onready var http_rpc_btc_get_block_count: HTTPRequest = $BitcoinCoreRPC/HTTPRPCBTCGetBlockCount


func rpc_bitcoin_getblockcount() -> void:
make_rpc_request(DEFAULT_BITCOIN_RPC_PORT, "getblockcount", [], http_rpc_btc_get_block_count)


func grpc_enforcer_getmainblockcount() -> void:
make_grpc_request(GRPC_CUSF_DRIVECHAIN_GET_HEIGHT)
func grpc_enforcer_gettip() -> void:
make_grpc_request(GRPC_CUSF_DRIVECHAIN_GET_TIP)


func cli_thunder_getblockcount() -> void:
Expand All @@ -56,12 +55,8 @@ func make_grpc_request(request : String) -> void:
var user_dir = OS.get_user_data_dir()
var output = []
var ret : int = OS.execute(str(user_dir, "/grpcurl"),
["--plaintext",
"--import-path",
user_dir,
"--proto",
str(user_dir, "/validator.proto"),
"[::1]:50051",
["-plaintext",
"localhost:50051",
request],
output,
true)
Expand All @@ -70,8 +65,10 @@ func make_grpc_request(request : String) -> void:
print("ret ", ret)
print("output ", output)

# TODO check ret code
cusf_drivechain_rpc_failed.emit()
if ret != 0:
cusf_drivechain_rpc_failed.emit()
else:
cusf_drivechain_responded.emit()


func make_rpc_request(port : int, method: String, params: Variant, http_request: HTTPRequest) -> void:
Expand Down

0 comments on commit b4bade9

Please sign in to comment.