Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove assumption that coinbase scriptSig prefix contains only BIP34 #1461

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions protocols/v2/roles-logic-sv2/src/channel_logic/channel_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ pub struct PoolChannelFactory {
inner: ChannelFactory,
job_creator: JobsCreators,
pool_coinbase_outputs: Vec<TxOut>,
pool_signature: String,
additional_coinbase_script_data: Vec<u8>,
// extended_channel_id -> SetCustomMiningJob
negotiated_jobs: HashMap<u32, SetCustomMiningJob<'static>, BuildNoHashHasher<u32>>,
}
Expand All @@ -1007,7 +1007,7 @@ impl PoolChannelFactory {
share_per_min: f32,
kind: ExtendedChannelKind,
pool_coinbase_outputs: Vec<TxOut>,
pool_signature: String,
additional_coinbase_script_data: Vec<u8>,
) -> Self {
let inner = ChannelFactory {
ids,
Expand All @@ -1034,7 +1034,7 @@ impl PoolChannelFactory {
inner,
job_creator,
pool_coinbase_outputs,
pool_signature,
additional_coinbase_script_data,
negotiated_jobs: HashMap::with_hasher(BuildNoHashHasher::default()),
}
}
Expand Down Expand Up @@ -1107,7 +1107,7 @@ impl PoolChannelFactory {
m,
true,
self.pool_coinbase_outputs.clone(),
self.pool_signature.clone(),
self.additional_coinbase_script_data.clone(),
)?;
self.inner.on_new_extended_mining_job(new_job)
}
Expand Down Expand Up @@ -1185,10 +1185,13 @@ impl PoolChannelFactory {
if self.negotiated_jobs.contains_key(&m.channel_id) {
let referenced_job = self.negotiated_jobs.get(&m.channel_id).unwrap();
let merkle_path = referenced_job.merkle_path.to_vec();
let pool_signature = self.pool_signature.clone();
let extended_job =
job_creator::extended_job_from_custom_job(referenced_job, pool_signature, 32)
.unwrap();
let additional_coinbase_script_data = self.additional_coinbase_script_data.clone();
let extended_job = job_creator::extended_job_from_custom_job(
referenced_job,
additional_coinbase_script_data,
32,
)
.unwrap();
let prev_blockhash = crate::utils::u256_to_block_hash(referenced_job.prev_hash.clone());
let bits = referenced_job.nbits;
self.inner.check_target(
Expand Down Expand Up @@ -1327,7 +1330,7 @@ pub struct ProxyExtendedChannelFactory {
inner: ChannelFactory,
job_creator: Option<JobsCreators>,
pool_coinbase_outputs: Option<Vec<TxOut>>,
pool_signature: String,
additional_coinbase_script_data: Vec<u8>,
// Id assigned to the extended channel by upstream
extended_channel_id: u32,
}
Expand All @@ -1342,7 +1345,7 @@ impl ProxyExtendedChannelFactory {
share_per_min: f32,
kind: ExtendedChannelKind,
pool_coinbase_outputs: Option<Vec<TxOut>>,
pool_signature: String,
additional_coinbase_script_data: Vec<u8>,
extended_channel_id: u32,
) -> Self {
match &kind {
Expand Down Expand Up @@ -1382,7 +1385,7 @@ impl ProxyExtendedChannelFactory {
inner,
job_creator,
pool_coinbase_outputs,
pool_signature,
additional_coinbase_script_data,
extended_channel_id,
}
}
Expand Down Expand Up @@ -1481,7 +1484,7 @@ impl ProxyExtendedChannelFactory {
m,
true,
pool_coinbase_outputs.clone(),
self.pool_signature.clone(),
self.additional_coinbase_script_data.clone(),
)?;
let id = new_job.job_id;
if !new_job.is_future() && self.inner.last_prev_hash.is_some() {
Expand Down Expand Up @@ -1917,7 +1920,7 @@ mod test {

// Initialize a Channel of type Pool
let out = TxOut {value: BLOCK_REWARD, script_pubkey: decode_hex("4104c6d0969c2d98a5c19ba7c36c7937c5edbd60ff2a01397c4afe54f16cd641667ea0049ba6f9e1796ba3c8e49e1b504c532ebbaaa1010c3f7d9b83a8ea7fd800e2ac").unwrap().into()};
let pool_signature = "".to_string();
let additional_coinbase_script_data = "".as_bytes().to_vec();
let creator = JobsCreators::new(7);
let share_per_min = 1.0;
// Create an ExtendedExtranonce of len 7:
Expand All @@ -1938,7 +1941,7 @@ mod test {
share_per_min,
channel_kind,
vec![out],
pool_signature,
additional_coinbase_script_data,
);

// Build a NewTemplate
Expand Down
Loading
Loading