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

Prevent transactions in blocks from going below balance. #136

Merged
merged 9 commits into from
Dec 14, 2020

Conversation

Bushstar
Copy link
Member

Tracks changes to account when including transactions in a blocks, this prevents an account trying to spend more than it has which is an invalid state and would be rejected. After block creation some transactions left in the mempool may then be invalid due to our bespoke account layer, we iterate over the mempool and remove any transactions that fail CheckTxInputs.

@Bushstar Bushstar force-pushed the account-mining-solution branch from fed3155 to 932a670 Compare December 11, 2020 20:19
assert_equal(node.getblockcount(), blockcount + 1)

# Account should now be empty
assert_equal(node.getaccount(account), [])
Copy link
Contributor

Choose a reason for hiding this comment

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

Can also check the count of transactions?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add it. We would expect five TXs in the block plus coinbase. This test will also be extended to include other account TXs.

bool accountConflict{false};

// Check if any custom TXs are in mempool with conflict
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); ++it) {
Copy link
Contributor

@ShengguangXiao ShengguangXiao Dec 13, 2020

Choose a reason for hiding this comment

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

Use auto instead of indexed_transaction_set::const_iterator

CAmount txfee = 0;

// Check custom TX consensus types are now not in conflict with account layer
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); ++it) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use auto instead of indexed_transaction_set::const_iterator

@monstrobishi monstrobishi merged commit dc4a139 into master Dec 14, 2020
@monstrobishi monstrobishi deleted the account-mining-solution branch December 14, 2020 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants