Skip to content

Commit

Permalink
fix: remove signers from tenure change tx (#17)
Browse files Browse the repository at this point in the history
* fix: remove signers from tenure change tx

* test: remove extras from test payloads
  • Loading branch information
rafaelcr authored Jan 24, 2024
1 parent 8e44b2d commit 9e2aa26
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 27 deletions.
4 changes: 0 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,6 @@ export interface TxPayloadTenureChange {
cause: TenureChangeCause;
/** (Hex string) The ECDSA public key hash of the current tenure */
pubkey_hash: string;
/** (Hex string) A Schnorr signature from at least 70% of the Stackers */
signature: string;
/** (Hex string) A bitmap of which Stackers signed */
signers: string;
}

export enum TenureChangeCause {
Expand Down
14 changes: 1 addition & 13 deletions src/stacks_tx/deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,14 +470,6 @@ impl TransactionTenureChange {
let mut pubkey_hash = [0u8; 20];
fd.read_exact(&mut pubkey_hash)?;

// ThresholdSignature { R: [0u8; 33], z: [0u8; 32] }
let mut signature = [0u8; 65];
fd.read_exact(&mut signature)?;

let signers_len: u32 = fd.read_u32::<BigEndian>()?;
let mut signers: Vec<u8> = vec![0u8; signers_len as usize];
fd.read_exact(&mut signers)?;

Ok(TransactionTenureChange {
tenure_consensus_hash,
prev_tenure_consensus_hash,
Expand All @@ -486,8 +478,6 @@ impl TransactionTenureChange {
previous_tenure_blocks,
cause,
pubkey_hash,
signature,
signers,
})
}
}
Expand Down Expand Up @@ -729,8 +719,6 @@ pub struct TransactionTenureChange {
pub previous_tenure_blocks: u32,
pub cause: TenureChangeCause,
pub pubkey_hash: [u8; 20],
pub signature: [u8; 65],
pub signers: Vec<u8>,
}

#[repr(u8)]
Expand Down Expand Up @@ -807,7 +795,7 @@ mod tests {
// tx prefix (before payload):
// let input = b"00000000010400982f3ec112a5f5928a5c96a914bd733793b896a5000000000000053000000000000002290000c85889dad0d5b08a997a93a28a7c93eb22c324e5f8992dc93e37865ef4f3e0d65383beefeffc4871a2facbc4b590ddf887c80de6638ed4e2ec0e633d1e130f23030100000000";

let input = b"808000000004001dc27eba0247f8cc9575e7d45e50a0bc7e72427d000000000000001d000000000000000000011dc72b6dfd9b36e414a2709e3b01eb5bbdd158f9bc77cd2ca6c3c8b0c803613e2189f6dacf709b34e8182e99d3a1af15812b75e59357d9c255c772695998665f010200000000076f2ff2c4517ab683bf2d588727f09603cc3e9328b9c500e21a939ead57c0560af8a3a132bd7d56566f2ff2c4517ab683bf2d588727f09603cc3e932828dcefb98f6b221eef731cabec7538314441c1e0ff06b44c22085d41aae447c1000000010014ff3cb19986645fd7e71282ad9fea07d540a60e0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798000000000000000000000000000000000000000000000000000000000000000000000000";
let input = b"808000000004001dc27eba0247f8cc9575e7d45e50a0bc7e72427d000000000000001d000000000000000000011dc72b6dfd9b36e414a2709e3b01eb5bbdd158f9bc77cd2ca6c3c8b0c803613e2189f6dacf709b34e8182e99d3a1af15812b75e59357d9c255c772695998665f010200000000076f2ff2c4517ab683bf2d588727f09603cc3e9328b9c500e21a939ead57c0560af8a3a132bd7d56566f2ff2c4517ab683bf2d588727f09603cc3e932828dcefb98f6b221eef731cabec7538314441c1e0ff06b44c22085d41aae447c1000000010014ff3cb19986645fd7e71282ad9fea07d540a60e";

let bytes = decode_hex(input).unwrap();
let bytes_len = bytes.len();
Expand Down
6 changes: 0 additions & 6 deletions src/stacks_tx/neon_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,12 +682,6 @@ impl NeonJsSerialize for TransactionTenureChange {
let pubkey_hash = cx.string(encode_hex(&self.pubkey_hash));
obj.set(cx, "pubkey_hash", pubkey_hash)?;

let signature = cx.string(encode_hex(&self.signature));
obj.set(cx, "signature", signature)?;

let signers = cx.string(encode_hex(&self.signers));
obj.set(cx, "signers", signers)?;

Ok(())
}
}
Expand Down
6 changes: 2 additions & 4 deletions tests/tx-decode-3.0.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
} from '../index.js';

test('stacks3.0 - decode tx - tenure change', () => {
const tenureChangeTx = '808000000004001dc27eba0247f8cc9575e7d45e50a0bc7e72427d000000000000001d000000000000000000011dc72b6dfd9b36e414a2709e3b01eb5bbdd158f9bc77cd2ca6c3c8b0c803613e2189f6dacf709b34e8182e99d3a1af15812b75e59357d9c255c772695998665f010200000000076f2ff2c4517ab683bf2d588727f09603cc3e9328b9c500e21a939ead57c0560af8a3a132bd7d56566f2ff2c4517ab683bf2d588727f09603cc3e932828dcefb98f6b221eef731cabec7538314441c1e0ff06b44c22085d41aae447c1000000010014ff3cb19986645fd7e71282ad9fea07d540a60e0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798000000000000000000000000000000000000000000000000000000000000000000000000';
const tenureChangeTx = '808000000004001dc27eba0247f8cc9575e7d45e50a0bc7e72427d000000000000001d000000000000000000011dc72b6dfd9b36e414a2709e3b01eb5bbdd158f9bc77cd2ca6c3c8b0c803613e2189f6dacf709b34e8182e99d3a1af15812b75e59357d9c255c772695998665f010200000000076f2ff2c4517ab683bf2d588727f09603cc3e9328b9c500e21a939ead57c0560af8a3a132bd7d56566f2ff2c4517ab683bf2d588727f09603cc3e932828dcefb98f6b221eef731cabec7538314441c1e0ff06b44c22085d41aae447c1000000010014ff3cb19986645fd7e71282ad9fea07d540a60e';
const decoded = decodeTransaction(tenureChangeTx);
expect(decoded).toEqual({
"tx_id": "0xc8d48b288a780bc98602c1ed137f80d8bf4a6c60fb50cc569bee33ee7563501b",
"tx_id": "0xd443c1edb6bbcbdb702884a688b3ed09cc2d81e391f09c4d91ac881806979620",
"version": TransactionVersion.Testnet,
"chain_id": 0x80000000,
"auth": {
Expand Down Expand Up @@ -46,8 +46,6 @@ test('stacks3.0 - decode tx - tenure change', () => {
"previous_tenure_blocks": 1,
"cause": TenureChangeCause.BlockFound,
"pubkey_hash": "0x14ff3cb19986645fd7e71282ad9fea07d540a60e",
"signature": "0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f817980000000000000000000000000000000000000000000000000000000000000000",
"signers": "0x"
}
});
});
Expand Down

0 comments on commit 9e2aa26

Please sign in to comment.