Skip to content

Conversation

@random-zebra
Copy link

Extracted from #2267.
This is a collection of small refactorings around the validation code, which will make future additions easier to review.
See individual commit's description.

@random-zebra random-zebra force-pushed the 202103-mix-refactoring branch from 9a1948e to 23e8c3e Compare March 31, 2021 20:17
@random-zebra random-zebra force-pushed the 202103-mix-refactoring branch from 23e8c3e to a361805 Compare March 31, 2021 23:05
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about this, why this is needed?

In the FundTransaction flow, the user is providing the tx in hex format and the node is parsing it. If there would be an extra payload or sapling data inside the tx, this line GetSerializeSize(tx) + extraSize will sum them twice as GetSerializeSize calls internally to the tx serialization method which is already taking into account the two fields.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the FundTransaction flow, the user is providing the tx in hex format and the node is parsing it.

Mhm... there is some confusion.
This is the wallet function. There is no hex format, or parsing, directly involved here.
A generic caller to CWallet::FundTransaction provides the transaction to be funded, as a CMutableTransaction tx (not an hex string).

The outputs of this mutable tx are used to fill vecSend, passed to CWallet::CreateTransaction.
With the input data, CreateTransaction creates a mutable transaction object txNew.

Since, in order to select enough inputs, the transaction fee must be known, the serialized size is calculated inside CreateTransaction.
This calculation is obviously done on the newly created CMutableTransaction (the txNew object), which has no extra payload accounted for.

Also, while currently CWallet::FundTransaction is called exclusively from the RPC command fundrawtransaction (after parsing the user provided hex), soon there will be more RPCs (which involve no parsing of raw txes) relying on this wallet function.

this line GetSerializeSize(tx) + extraSize will sum them twice

No. You can easily verify, trying to remove this on #2267.
The tests will fail due to fee too low.
Also note that txNew is being serialized (not the mutable tx passed to FundTransaction).

@random-zebra random-zebra force-pushed the 202103-mix-refactoring branch from a361805 to be31458 Compare April 5, 2021 19:59
@random-zebra random-zebra force-pushed the 202103-mix-refactoring branch from be31458 to 0b9a21f Compare April 5, 2021 21:32
@furszy furszy self-requested a review April 6, 2021 21:42
@random-zebra random-zebra force-pushed the 202103-mix-refactoring branch from 0b9a21f to 65b6bd3 Compare April 7, 2021 10:40
Since we will need the current tip index in CheckProRegTx to check for
duplicate unique-properties in the deterministic mn list.
the boolean argument fJustCheck in ProcessSpecialTxsInBlock will be used
later, after the connection to the deterministic manager
Also don't expose it (as it is only called by
ContextualCheckZerocoinTx) and cleanup logs with __func__
@random-zebra random-zebra force-pushed the 202103-mix-refactoring branch 3 times, most recently from e263d9c to 3490971 Compare April 7, 2021 13:56
@random-zebra random-zebra force-pushed the 202103-mix-refactoring branch from 3490971 to b408de3 Compare April 7, 2021 14:33
Copy link

@furszy furszy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking better now 👌 , nice work.
ACK b408de3 .

@random-zebra random-zebra requested a review from Fuzzbawls April 8, 2021 11:46
@random-zebra
Copy link
Author

Would be good to complete the review and merge this one (opened 2 weeks ago), so we can keep going with the DMN stuff.

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code ACK b408de3

@random-zebra
Copy link
Author

Merging...

@random-zebra random-zebra merged commit f461766 into PIVX-Project:master Apr 11, 2021
furszy added a commit that referenced this pull request Apr 13, 2021
c27bbed [Cleanup] functions impl: branch on new line (random-zebra)
8850b3e [Refactoring] Make CEvoDB mutex public (random-zebra)
304fc46 Take memory used by CEvoDB/CDBTransaction into account when flushing (random-zebra)
ed0d4f9 Track memory usage in CDBTransaction and CEvoDB (random-zebra)
f259774 Implement CDBTransactionIterator (Alexander Block)
51920cb Change CDBTransaction to compare keys by their serialized form (Alexander Block)
7094a60 Support passing CDataStream as key into CDBWrapper/CDBBatch/CDBIterator (Alexander Block)
cdd44d4 [Cleanup] Drop unneeded casts (random-zebra)
65b8ddc [DB] Specialize CScopedDBTransaction for evo database (random-zebra)
34a7541 [Refactoring] Properly add explicit specifier where appropriate (random-zebra)
6a36968 Implement 2-stage commit for CEvoDB to avoid inconsistencies (Alexander Block)
e6c7efe [Refactoring] Let Commit() return void (random-zebra)
fec56b0 [DB] Ensure evoDB consistency by storing best block hash (random-zebra)
be85c9a [Refactoring] migrate evoDb to unique pointer (random-zebra)
cab50d3 [Tests] Fix functional test suite with new directory 'evodb' (random-zebra)
ad7f5d7 [DB][BUG] Add virtual destructor for KeyValueHolder (random-zebra)
d6c56d1 Introduce CEvoDB for all evo related things, e.g. DIP3 (Alexander Block)
2496933 Implement CDBTransaction and CScopedDBTransaction (Alexander Block)
da6a2c1 [Build] CMake: Introduce evo headers (random-zebra)
f3a7cfb [Trivial] Remove unused variable in ProcessNewBlock (random-zebra)

Pull request description:

  Extracted from #2267.
  This introduces the new database, used for all DMN-related things, and updates the dbWrapper.

  Builds on top of:
  - [x] #2269
  - [x] #2270

ACKs for top commit:
  Fuzzbawls:
    Code ACK c27bbed
  furszy:
    Code ACK c27bbed.

Tree-SHA512: a93b0c96759b9493659d2e5c69d2fa9d7dbcb260b7f7ec4d2e7db2d1f2a4561f9548bbe4db07272792b5d6dbf33fd8e7c84f04d958781e6d9bb3fb1fdcbf2ea1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants