Introduce CommitOnly variant of Inputs (#3419)
* Introduce CommitOnly variant of Inputs. Introduce CommitWrapper so we can sort commit only inputs correctly. * rememebr to resort if converting * write inputs based on variant and protocol version * read and write protocol version specific inputs * store full blocks in local db in v3 convert to v2 when relaying to v2 peers * add debug version_str for inputs * no assumptions about spent index sort order * add additional version debug logs * fix ser/deser tests for proto v3 * cleanup coinbase maturity * rework pool to better handle v2 conversion robustly * cleanup txpool add_to_pool * fix nrd kernel test * move init conversion earlier * cleanup * cleanup based on PR feedback
This commit is contained in:
@@ -141,10 +141,20 @@ fn test_transaction_pool_block_reconciliation() {
|
||||
pool.reconcile_block(&block).unwrap();
|
||||
|
||||
assert_eq!(pool.total_size(), 4);
|
||||
assert_eq!(pool.txpool.entries[0].tx, valid_transaction);
|
||||
assert_eq!(pool.txpool.entries[1].tx, pool_child);
|
||||
assert_eq!(pool.txpool.entries[2].tx, conflict_valid_child);
|
||||
assert_eq!(pool.txpool.entries[3].tx, valid_child_valid);
|
||||
// Compare the various txs by their kernels as entries in the pool are "v2" compatibility.
|
||||
assert_eq!(
|
||||
pool.txpool.entries[0].tx.kernels(),
|
||||
valid_transaction.kernels()
|
||||
);
|
||||
assert_eq!(pool.txpool.entries[1].tx.kernels(), pool_child.kernels());
|
||||
assert_eq!(
|
||||
pool.txpool.entries[2].tx.kernels(),
|
||||
conflict_valid_child.kernels()
|
||||
);
|
||||
assert_eq!(
|
||||
pool.txpool.entries[3].tx.kernels(),
|
||||
valid_child_valid.kernels()
|
||||
);
|
||||
|
||||
// Cleanup db directory
|
||||
clean_output_dir(db_root.into());
|
||||
|
||||
@@ -136,16 +136,16 @@ impl BlockChain for ChainAdapter {
|
||||
})
|
||||
}
|
||||
|
||||
fn validate_inputs(&self, inputs: Inputs) -> Result<Vec<OutputIdentifier>, PoolError> {
|
||||
fn validate_inputs(&self, inputs: &Inputs) -> Result<Vec<OutputIdentifier>, PoolError> {
|
||||
self.chain
|
||||
.validate_inputs(inputs)
|
||||
.map(|outputs| outputs.into_iter().map(|(out, _)| out).collect::<Vec<_>>())
|
||||
.map_err(|_| PoolError::Other("failed to validate inputs".into()))
|
||||
}
|
||||
|
||||
fn verify_coinbase_maturity(&self, tx: &Transaction) -> Result<(), PoolError> {
|
||||
fn verify_coinbase_maturity(&self, inputs: &Inputs) -> Result<(), PoolError> {
|
||||
self.chain
|
||||
.verify_coinbase_maturity(tx)
|
||||
.verify_coinbase_maturity(inputs)
|
||||
.map_err(|_| PoolError::ImmatureCoinbase)
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,12 @@ fn test_nrd_kernel_relative_height() -> Result<(), PoolError> {
|
||||
aggsig::sign_with_blinding(&keychain.secp(), &msg, &excess, Some(&pubkey)).unwrap();
|
||||
kernel.verify().unwrap();
|
||||
|
||||
// Generate a 2nd NRD kernel sharing the same excess commitment but with different signature.
|
||||
let mut kernel2 = kernel.clone();
|
||||
kernel2.excess_sig =
|
||||
aggsig::sign_with_blinding(&keychain.secp(), &msg, &excess, Some(&pubkey)).unwrap();
|
||||
kernel2.verify().unwrap();
|
||||
|
||||
let tx1 = test_transaction_with_kernel(
|
||||
&keychain,
|
||||
vec![10, 20],
|
||||
@@ -99,7 +105,7 @@ fn test_nrd_kernel_relative_height() -> Result<(), PoolError> {
|
||||
&keychain,
|
||||
vec![24],
|
||||
vec![18],
|
||||
kernel.clone(),
|
||||
kernel2.clone(),
|
||||
excess.clone(),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user