Skip to content

Commit

Permalink
bootstrap MG test for issue #923
Browse files Browse the repository at this point in the history
  • Loading branch information
plebhash committed May 24, 2024
1 parent 5fef39e commit 6c72fb1
Show file tree
Hide file tree
Showing 6 changed files with 589 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/config/jdc-quick-template-update/jdc-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Local Mining Device Downstream Connection
downstream_address = "127.0.0.1"
downstream_port = 34265

# Version support
max_supported_version = 2
min_supported_version = 2

# Minimum extranonce2 size for downstream
# Max value: 16 (leaves 0 bytes for search space splitting of downstreams)
# Max value for CGminer: 8
# Min value: 2
min_extranonce2_size = 8

# Withhold
withhold = false

# Auth keys for open encrypted connection downstream
authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
cert_validity_sec = 3600

# How many time the JDC try to reinitialize itself after a failure
retry = 10

tp_address = "127.0.0.1:8442"
tp_authority_pub_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"



coinbase_outputs = [
{ output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" },
]

[timeout]
unit = "secs"
value = 1

[[upstreams]]
authority_pubkey = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
pool_address = "127.0.0.1:34254"
jd_address = "127.0.0.1:34264"
pool_signature = "Stratum v2 SRI Pool"

[[upstreams]]
authority_pubkey = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
pool_address = "127.0.0.1:44255"
jd_address = "127.0.0.1:34264"
pool_signature = "Stratum v2 SRI Pool"

14 changes: 14 additions & 0 deletions test/config/pool-config-local-tp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
listen_address = "127.0.0.1:34254"
tp_address = "127.0.0.1:8442"
listen_jd_address = "127.0.0.1:34264"
authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
cert_validity_sec = 3600
test_only_listen_adress_plain = "0.0.0.0:34250"
# list of coinbase outputs used to build the coinbase tx
# ! right now only one output is supported, so comment all the ones you don't need !
coinbase_outputs = [
{ output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" },
]
# Pool signature (string to be included in coinbase tx)
pool_signature = "Stratum v2 SRI Pool"
146 changes: 146 additions & 0 deletions test/message-generator/mock/jds-mock-quick-templates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"version": "2",
"doc": [
"This test does",
"Mock a JDS",
"Start listen to the port 34264",
"Receive SetupConnection and reply SetupConnection.Success",
"(template1) Await for AllocateMiningJobToken and reply AllocateMiningJobToken.Success",
"(template2) Await for AllocateMiningJobToken and reply AllocateMiningJobToken.Success",
"(template1) Await for DeclareMiningJob and reply DeclareMiningJob.Success",
"(template2) Await for DeclareMiningJob and reply DeclareMiningJob.Success"
],
"jd_messages": [
{
"message": {
"type": "AllocateMiningJobTokenSuccess",
"mining_job_token": [0, 0, 0, 0, 0],
"coinbase_output_max_additional_size": 0,
"async_mining_allowed": false
},
"id": "allocate_mining_job_token_success_0"
},
{
"message": {
"type": "AllocateMiningJobTokenSuccess",
"mining_job_token": [0, 0, 0, 0, 1],
"coinbase_output_max_additional_size": 0,
"async_mining_allowed": false
},
"id": "allocate_mining_job_token_success_1"
},
{
"message": {
"type": "DeclareMiningJob.Success",
"request_id": 0,
"new_mining_job_token": [0, 0, 0, 0, 0]
},
"id": "declare_mining_job_success_0"
},
{
"message": {
"type": "DeclareMiningJob.Success",
"request_id": 1,
"new_mining_job_token": [0, 0, 0, 0, 0]
},
"id": "declare_mining_job_success_1"
}
],
"frame_builders": [
{
"type": "automatic",
"message_id": "allocate_mining_job_token_success_0"
},
{
"type": "automatic",
"message_id": "allocate_mining_job_token_success_1"
},
{
"type": "automatic",
"message_id": "declare_mining_job_success_0"
},
{
"type": "automatic",
"message_id": "declare_mining_job_success_1"
},
{
"type": "automatic",
"message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_tproxy"
}
],
"actions": [
{
"message_ids": ["setup_connection_success_tproxy"],
"role": "server",
"results": [
{
"type": "match_message_type",
"value": "0x00"
}
],
"actiondoc": "This action checks that a SetupConnection message is received, and sends back a SetupConnection.Success (setup_connection_success_tproxy)"
},
{
"message_ids": ["allocate_mining_job_token_success_0"],
"role": "server",
"results": [
{
"type": "match_message_type",
"value": "0x50"
}
],
"actiondoc": "This action checks that a AllocateMiningJobToken message is received, and sends back a AllocateMiningJobToken.Success (allocate_mining_job_token_success_0)"
},
{
"message_ids": ["allocate_mining_job_token_success_1"],
"role": "server",
"results": [
{
"type": "match_message_type",
"value": "0x50"
}
],
"actiondoc": "This action checks that a AllocateMiningJobToken message is received, and sends back a AllocateMiningJobToken.Success (allocate_mining_job_token_success_1)"
},
{
"message_ids": ["declare_mining_job_success_0"],
"role": "server",
"results": [
{
"type": "match_message_type",
"value": "0x57"
}
],
"actiondoc": "This action checks that a DeclareMiningJob message is received, and sends back a DeclareMiningJob.Success (declare_mining_job_success_0)"
},
{
"message_ids": ["declare_mining_job_success_1"],
"role": "server",
"results": [
{
"type": "match_message_type",
"value": "0x57"
}
],
"actiondoc": "This action checks that a DeclareMiningJob message is received, and sends back a DeclareMiningJob.Success (declare_mining_job_success_1)"
}
],
"setup_commands": [
],
"execution_commands": [
],
"cleanup_commands": [
{
"command": "sleep",
"args": ["10000000"],
"conditions": "None"
}
],
"role": "server",
"upstream": {
"ip": "127.0.0.1",
"port": 34264,
"pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72",
"secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
}
}
182 changes: 182 additions & 0 deletions test/message-generator/mock/tp-mock-quick-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"version": "2",
"doc": [
"This test does",
"Soft mocking of template provider that sends two templates (NewTemplate message) with very little time in between",
"Listen to port 8442",
"Awaits for other roles setup (5s)",
"Awaits for SetupConnection message (pool)",
"Responds with SetupConnection.Success (pool)",
"Awaits for SetupConnection message (jdc)",
"Responds with SetupConnection.Success (jdc)",
"Sends NewTemplate (new_template)",
"Sends SetNewPrevHash (set_new_prev_hash2)",
"Awaits for RequestTransactionData",
"Responds with RequestTransactionData.Success",
"Sleep for 100ms (very fast time between templates)",
"Sends NewTemplate (new_template2)",
"Sends SetNewPrevHash (set_new_prev_hash2)",
"Awaits for RequestTransactionData",
"Responds with RequestTransactionData.Success"
],
"template_distribution_messages": [
{
"message": {
"type": "NewTemplate",
"template_id": 29,
"future_template": true,
"version": 536870912,
"coinbase_tx_version": 2,
"coinbase_prefix": [3, 76, 163, 38, 0],
"coinbase_tx_input_sequence": 4294967295,
"coinbase_tx_value_remaining": 625000000,
"coinbase_tx_outputs_count": 0,
"coinbase_tx_outputs": [],
"coinbase_tx_locktime": 0,
"merkle_path": []
},
"id": "new_template"
},
{
"message": {
"type": "SetNewPrevHash",
"template_id": 29,
"prev_hash": [145, 77, 225, 26, 186, 5, 16, 125, 174, 40, 238, 200, 210, 191, 188, 87, 191, 246, 242, 221, 8, 20, 202, 200, 97, 139, 241, 73, 137, 201, 28, 0],
"header_timestamp": 1671039088,
"n_bits": 545259519,
"target": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,127]
},
"id": "set_new_prev_hash"
},
{
"message": {
"type": "NewTemplate",
"template_id": 30,
"future_template": true,
"version": 536870912,
"coinbase_tx_version": 2,
"coinbase_prefix": [3, 76, 163, 38, 0],
"coinbase_tx_input_sequence": 4294967295,
"coinbase_tx_value_remaining": 625000000,
"coinbase_tx_outputs_count": 0,
"coinbase_tx_outputs": [],
"coinbase_tx_locktime": 0,
"merkle_path": []
},
"id": "new_template2"
},
{
"message": {
"type": "SetNewPrevHash",
"template_id": 30,
"prev_hash": [145, 77, 225, 26, 186, 5, 16, 125, 174, 40, 238, 200, 210, 191, 188, 87, 191, 246, 242, 221, 8, 20, 202, 200, 97, 139, 241, 73, 137, 201, 28, 0],
"header_timestamp": 1671039088,
"n_bits": 545259519,
"target": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,127]
},
"id": "set_new_prev_hash2"
}
],
"frame_builders": [
{
"type": "automatic",
"message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_template_distribution"
},
{
"type": "automatic",
"message_id": "new_template"
},
{
"type": "automatic",
"message_id": "set_new_prev_hash"
},
{
"type": "automatic",
"message_id": "new_template2"
},
{
"type": "automatic",
"message_id": "set_new_prev_hash2"
}

],
"actions": [
{
"message_ids": [],
"role": "server",
"results": [
{
"type": "match_message_type",
"value": "0x00"
}
],
"actiondoc": "(pool) This action checks that a SetupConnection message is received"
},
{
"message_ids": ["setup_connection_success_template_distribution"],
"role": "server",
"results": [
{
"type": "match_message_type",
"value": "0x70"
}
],
"actiondoc": "(pool) This action sends SetupConnection.Success with flag 2 (TD protocol) and checks that a message SetCoinbaseDataSize is received"
},
{
"message_ids": [],
"role": "server",
"results": [
{
"type": "match_message_type",
"value": "0x00"
}
],
"actiondoc": "(jdc) This action checks that a SetupConnection message is received"
},
{
"message_ids": ["setup_connection_success_template_distribution"],
"role": "server",
"results": [
{
"type": "match_message_type",
"value": "0x70"
}
],
"actiondoc": "(jdc) This action sends SetupConnection.Success with flag 2 (TD protocol) and checks that a message SetCoinbaseDataSize is received"
},
{
"message_ids": ["new_template","set_new_prev_hash"],
"role": "server",
"results": [],
"actiondoc": "This action sends NewTemplate and SetNewPrevHash"
},
{
"message_ids": ["new_template2","set_new_prev_hash2"],
"role": "server",
"results": [
{
"type": "match_message_type",
"value": "0x76"
}
],
"actiondoc": "This action checks that new template2 and new prev hash2 is received"
}
],
"setup_commands": [],
"execution_commands": [],
"cleanup_commands": [
{
"command": "sleep",
"args": ["10"],
"conditions": "None"
}
],
"role": "server",
"upstream": {
"ip": "127.0.0.1",
"port": 8442,
"pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72",
"secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
}
}
Loading

0 comments on commit 6c72fb1

Please sign in to comment.