Skip to content

Commit

Permalink
Merge pull request #640 from Fi3/FixJDS
Browse files Browse the repository at this point in the history
Fix jds
  • Loading branch information
Fi3 authored Oct 12, 2023
2 parents 2ab397f + 8f36b28 commit dc428ee
Show file tree
Hide file tree
Showing 44 changed files with 190 additions and 2,036 deletions.
21 changes: 0 additions & 21 deletions .codecov.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ impl<'a, T> std::convert::TryFrom<Seq0255<'a, T>> for Vec<T> {
}
}

#[cfg(feature = "prop_test")]
impl<'a, T> std::convert::TryFrom<Seq064K<'a, T>> for Vec<T> {
type Error = &'static str;
fn try_from(v: Seq064K<'a, T>) -> Result<Self, Self::Error> {
Expand Down
6 changes: 6 additions & 0 deletions protocols/v2/roles-logic-sv2/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ impl TryFrom<CoinbaseOutput> for Script {

fn try_from(value: CoinbaseOutput) -> Result<Self, Self::Error> {
match value.output_script_type.as_str() {
"TEST" => {
let pub_key_hash = PublicKey::from_str(value.output_script_value.as_str())
.map_err(|_| Error::InvalidOutputScript)?
.pubkey_hash();
Ok(Script::new_p2pkh(&pub_key_hash))
}
"P2PK" => {
let compressed_pub_key =
bip32_extended_to_compressed(value.output_script_value.as_str())?;
Expand Down
66 changes: 0 additions & 66 deletions roles/jd-client/jdc-config-example.toml

This file was deleted.

66 changes: 0 additions & 66 deletions roles/jd-client/jdc-config.toml

This file was deleted.

15 changes: 5 additions & 10 deletions roles/jd-server/jds-config-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
authority_public_key = "2di19GHYQnAZJmEpoUeP7C3Eg9TCcksHr23rZCC83dvUiZgiDL"
authority_secret_key = "2Z1FZug7mZNyM63ggkm37r4oKQ29khLjAvEx43rGkFN47RcJ2t"
cert_validity_sec = 3600
test_only_listen_adress_plain = "0.0.0.0:34250"
listen_address = "0.0.0.0:34254"

# 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 !
Expand All @@ -17,13 +15,10 @@ coinbase_outputs = [
#{ output_script_type = "P2TR", output_script_value = "vpub5XzEwP9YWe4cKKZAmbiBUxC7eL5HaZhbquBYzP3vDSDJJegb7CSCRphAPmwpGHzAyH1as9MRnXFWDcZozXA1K3sQqyKdTagooPfCVDhiwnr" },
]

# Template Provider config
# Local TP (this is pointing to localhost so you must run a TP locally for this configuration to work)
# tp_address = "127.0.0.1:8442"
# Hosted testnet TP
tp_address = "89.116.25.191:8442"
# Hosted regtest TP
# tp_address = "75.119.150.111:8442"

# SRI Pool JD config
listen_jd_address = "127.0.0.1:34264"

core_rpc_url = "http://127.0.0.1"
core_rpc_port = 18332
core_rpc_user = "username"
core_rpc_pass = "password"
19 changes: 5 additions & 14 deletions roles/jd-server/jds-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@
authority_public_key = "2di19GHYQnAZJmEpoUeP7C3Eg9TCcksHr23rZCC83dvUiZgiDL"
authority_secret_key = "2Z1FZug7mZNyM63ggkm37r4oKQ29khLjAvEx43rGkFN47RcJ2t"
cert_validity_sec = 3600
test_only_listen_adress_plain = "0.0.0.0:34250"
listen_address = "0.0.0.0:34254"

# 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 !
# For P2PK, P2PKH, P2WPKH, P2TR a BIP32 extended public key is needed
coinbase_outputs = [
#{ output_script_type = "P2PK", output_script_value = "vpub5XzEwP9YWe4cKKZAmbiBUxC7eL5HaZhbquBYzP3vDSDJJegb7CSCRphAPmwpGHzAyH1as9MRnXFWDcZozXA1K3sQqyKdTagooPfCVDhiwnr" },
#{ output_script_type = "P2PKH", output_script_value = "vpub5XzEwP9YWe4cKKZAmbiBUxC7eL5HaZhbquBYzP3vDSDJJegb7CSCRphAPmwpGHzAyH1as9MRnXFWDcZozXA1K3sQqyKdTagooPfCVDhiwnr" },
#{ output_script_type = "P2SH", output_script_value = "..." },
#{ output_script_type = "P2WSH", output_script_value = "..." },
{ output_script_type = "P2WPKH", output_script_value = "vpub5XzEwP9YWe4cKKZAmbiBUxC7eL5HaZhbquBYzP3vDSDJJegb7CSCRphAPmwpGHzAyH1as9MRnXFWDcZozXA1K3sQqyKdTagooPfCVDhiwnr" },
#{ output_script_type = "P2TR", output_script_value = "vpub5XzEwP9YWe4cKKZAmbiBUxC7eL5HaZhbquBYzP3vDSDJJegb7CSCRphAPmwpGHzAyH1as9MRnXFWDcZozXA1K3sQqyKdTagooPfCVDhiwnr" },
]

# Template Provider config
# Local TP (this is pointing to localhost so you must run a TP locally for this configuration to work)
# tp_address = "127.0.0.1:8442"
# Hosted testnet TP
tp_address = "89.116.25.191:8442"
# Hosted regtest TP
# tp_address = "75.119.150.111:8442"

# SRI Pool JD config
listen_jd_address = "127.0.0.1:34264"

core_rpc_url = "http://127.0.0.1"
core_rpc_port = 18332
core_rpc_user = "username"
core_rpc_pass = "password"
2 changes: 0 additions & 2 deletions roles/jd-server/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ impl std::fmt::Display for JdsError {
}
}

pub type JdsResult<T> = Result<T, JdsError>;

impl From<std::io::Error> for JdsError {
fn from(e: std::io::Error) -> JdsError {
JdsError::Io(e)
Expand Down
22 changes: 3 additions & 19 deletions roles/jd-server/src/lib/job_declarator/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ impl ParseClientJobDeclarationMessages for JobDeclaratorDownstream {
message: AllocateMiningJobToken,
) -> Result<SendTo, Error> {
let token = self.tokens.next();
// Token is saved in JobDeclaratorDownstream as u32
self.token_to_job_map.insert(token, None);
let message_success = AllocateMiningJobTokenSuccess {
request_id: message.request_id,
// From u32 token is transformed into B0255 in
// AllocateMiningJobTokenSuccess message
mining_job_token: token.to_le_bytes().to_vec().try_into().unwrap(),
// Mock value of coinbase_max_additional_size. Must be changed
coinbase_output_max_additional_size: 100,
async_mining_allowed: true,
coinbase_output: self.coinbase_output.clone().try_into().unwrap(),
Expand All @@ -66,15 +62,6 @@ impl ParseClientJobDeclarationMessages for JobDeclaratorDownstream {

fn handle_declare_mining_job(&mut self, message: DeclareMiningJob) -> Result<SendTo, Error> {
if self.verify_job(&message) {
// gT
//let mut short_hash_list: Vec<ShortTxId> = Vec::new();
//let tx_short_hashlist_vec = message.tx_short_hash_list.to_vec();
//for inner in message.tx_short_hash_list.inner_as_ref( {
// let mut inner_vec: Vec<u8> = inner.to_vec();
// let slice: &mut [u8] = inner_vec.as_mut_slice();
// let short_hash_id: ShortTxId= slice.try_into().unwrap();
// short_hash_list.push(short_hash_id);
//};
let short_hash_list: Vec<ShortTxId> = message
.tx_short_hash_list
.inner_as_ref()
Expand All @@ -83,7 +70,7 @@ impl ParseClientJobDeclarationMessages for JobDeclaratorDownstream {
.collect();
let nonce = message.tx_short_hash_nonce;
let mempool = self.mempool.safe_lock(|x| x.clone()).unwrap();
// TODO perhaps the coinbase does not get included

let mut unidentified_txs: Vec<ShortTxId> = Vec::new();
let mut identified_txs: Vec<(
stratum_common::bitcoin::Txid,
Expand All @@ -97,11 +84,8 @@ impl ParseClientJobDeclarationMessages for JobDeclaratorDownstream {
}
}

if !unidentified_txs.is_empty() {
// TODO ask downstream with the message ProvideMissingTransactions
// and add these transactions to the job the client is working onto
todo!()
}
// TODO
if !unidentified_txs.is_empty() {}

self.identified_txs = Some(identified_txs);
self.number_of_unidentified_txs = unidentified_txs.len() as u32;
Expand Down
Loading

0 comments on commit dc428ee

Please sign in to comment.