Skip to content

Commit

Permalink
Fix MG tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3 committed Nov 26, 2024
1 parent 798106a commit 4102974
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 14 deletions.
20 changes: 16 additions & 4 deletions protocols/v2/roles-logic-sv2/src/channel_logic/channel_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,12 @@ impl ChannelFactory {
};

let (downstream_target, extranonce) = self
.get_channel_specific_mining_info(&m)
.get_channel_specific_mining_info(
&m,
additional_coinbase_script_data
.map(|s| s.len())
.unwrap_or(0),
)
.ok_or(Error::ShareDoNotMatchAnyChannel)?;
let extranonce_1_len = self.extranonces.get_range0_len();
let extranonce_2 = extranonce[extranonce_1_len..].to_vec();
Expand All @@ -934,7 +939,8 @@ impl ChannelFactory {
coinbase_tx_suffix,
&extranonce[..],
&merkle_path[..],
additional_coinbase_script_data.unwrap_or(&[]),
// we don't have to pass the additional data since it is in the extranonce
&[],
)
.ok_or(Error::InvalidCoinbase)?
.try_into()
Expand Down Expand Up @@ -1037,7 +1043,11 @@ impl ChannelFactory {
}
}
/// Returns the downstream target and extranonce for the channel
fn get_channel_specific_mining_info(&self, m: &Share) -> Option<(mining_sv2::Target, Vec<u8>)> {
fn get_channel_specific_mining_info(
&self,
m: &Share,
additional_coinbase_script_data_len: usize,
) -> Option<(mining_sv2::Target, Vec<u8>)> {
match m {
Share::Extended(share) => {
let channel = self.extended_channels.get(&m.get_channel_id())?;
Expand All @@ -1046,7 +1056,9 @@ impl ChannelFactory {
let extranonce = [&extranonce_prefix[..], &share.extranonce.to_vec()[..]]
.concat()
.to_vec();
if extranonce.len() != self.extranonces.get_len() {
if extranonce.len()
!= self.extranonces.get_len() + additional_coinbase_script_data_len
{
error!(
"Extranonce is not of the right len expected {} actual {}",
self.extranonces.get_len(),
Expand Down
2 changes: 1 addition & 1 deletion test/config/pool-config-sri-tp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ 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"
pool_signature = "Stratum v2 SRI"
2 changes: 1 addition & 1 deletion test/config/pool-mock-tp-standard-coverage.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ 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"
pool_signature = "Stratum v2 SRI"
2 changes: 1 addition & 1 deletion test/config/pool-mock-tp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ 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"
pool_signature = "Stratum v2 SRI"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"user_identity": "",
"nominal_hash_rate": 10,
"max_target": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
"min_extranonce_size": 16
"min_extranonce_size": 8
},
"replace_fields": [["request_id", "ARBITRARY"]],
"id": "open_extended_mining_channel"
Expand Down Expand Up @@ -54,7 +54,7 @@
[
[
"extranonce_size",
{"U16": 16}
{"U16": 8}
]
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
[
[
"coinbase_tx_prefix",
{"B064K": [2, 0, 0, 0, 0, 1, 1, 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, 0, 0, 0, 255, 255, 255, 255, 56, 3, 76, 163, 38, 0, 83, 116, 114, 97, 116, 117, 109, 32, 118, 50, 32, 83, 82, 73, 32, 80, 111, 111, 108]}
{"B064K": [2, 0, 0, 0, 0, 1, 1, 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, 0, 0, 0, 255, 255, 255, 255, 32, 3, 76, 163, 38, 0]}
],

[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"type": "SubmitSharesStandard",
"channel_id": 1,
"sequence_number": 0,
"job_id": 0,
"job_id": 1,
"nonce": 927894720,
"ntime": 1671039088,
"version": 536870912
Expand All @@ -66,8 +66,8 @@
"type": "SubmitSharesStandard",
"channel_id": 1,
"sequence_number": 0,
"job_id": 0,
"nonce": 1751,
"job_id": 1,
"nonce": 1752,
"ntime": 1671116742,
"version": 536870912
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"message": {
"id": 0,
"method": "mining.submit",
"params": ["username", "0", "0000000000000000", "641577b0", "7a600640"]
"params": ["username", "0", "0000000000", "641577b0", "7a600640"]
},
"id": "mining.submit"
}
Expand Down

0 comments on commit 4102974

Please sign in to comment.