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

fix: assert failure on non-policy asset consolidation in CreateTransactionInternal #1277

Merged
merged 6 commits into from
Oct 27, 2023

Conversation

delta1
Copy link
Member

@delta1 delta1 commented Oct 18, 2023

same diff as #1258 but for master branch

@psgreco
Copy link
Contributor

psgreco commented Oct 18, 2023

UTACK ed90585 (same changes as #1258 )

…ctionInternal

Squash of 2 commits from ElementsProject#1258

- correct application of non_policy_effective_value to policy output in KnapsackSolver
- replace bad fee amount assert with error log and graceful failure in CWallet::CreateTransactionInternal

(cherry picked from commit 0f92a38)

Update src/wallet/coinselection.cpp

Co-authored-by: Byron Hambly <[email protected]>
(cherry picked from commit cf0f561)
@jamesdorfman
Copy link
Contributor

@delta1 there's a test failure in [ASan + LSan + UBSan + integer, no depends] [jammy] in the new regression test added here.

20/246 - 
wallet_elements_regression_1259.py --legacy-wallet
 failed, Duration: 1 s
stdout:
2023-10-18T16:32:27.728000Z TestFramework (INFO): Initializing test directory /tmp/cirrus-ci-build/ci/scratch/test_runner/test_runner_₿_🏃_20231018_163042/wallet_elements_regression_1259_223
2023-10-18T16:32:28.615000Z TestFramework (ERROR): Unexpected exception caught during testing
Traceback (most recent call last):
  File "/tmp/cirrus-ci-build/ci/scratch/build/elements-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 132, in main
    self.run_test()
  File "/tmp/cirrus-ci-build/ci/scratch/build/elements-x86_64-pc-linux-gnu/test/functional/wallet_elements_regression_1259.py", line 38, in run_test
    self.nodes[0].generate(COINBASE_MATURITY + 1)
  File "/tmp/cirrus-ci-build/ci/scratch/build/elements-x86_64-pc-linux-gnu/test/functional/test_framework/test_node.py", line 317, in generate
    return self.generatetoaddress(nblocks=nblocks, address=self.get_deterministic_priv_key().address, maxtries=maxtries, **kwargs)
TypeError: TestNode.generatetoaddress() missing 1 required keyword-only argument: 'invalid_call'

@delta1 delta1 added the hacktoberfest-accepted Accepted for participation in Hacktoberfest. label Oct 23, 2023
@delta1
Copy link
Member Author

delta1 commented Oct 23, 2023

Pushed the fix to the functional test for the generate calls, which has exposed a deeper issue in the changes since the 22 branch:

AssertionError: Unexpected stderr elementsd: wallet/spend.cpp:1272: bool wallet::CreateTransactionInternal(wallet::CWallet&, const std::vector<wallet::CRecipient>&, CTransactionRef&, CAmount&, int&, bilingual_str&, const wallet::CCoinControl&, FeeCalculation&, bool, wallet::BlindDetails*, const wallet::IssuanceDetails*): Assertion `change_and_fee >= 0' failed. 

@jamesdorfman
Copy link
Contributor

ACK 441c751.

Pushed a commit on top of it which fixes the coin selection bug that was causing the rest of the test to fail.

Adds a functional test to cover the issue uncovered in ElementsProject#1259, where
calling fundrawtransaction with many non-policy inputs and no policy
recipients results in an assertion failure and a crash.

Fixed in ElementsProject#1258.

(cherry picked from commit a8b0ed6)
@delta1
Copy link
Member Author

delta1 commented Oct 23, 2023

Thanks @jamesdorfman, testing now after fixing a bug I introduced in the test.

@delta1
Copy link
Member Author

delta1 commented Oct 23, 2023

Pushed to fix lint issues

@delta1
Copy link
Member Author

delta1 commented Oct 23, 2023

ACK 04cba29

@jamesdorfman jamesdorfman force-pushed the issues-1259 branch 7 times, most recently from d8cc516 to ab8ad42 Compare October 27, 2023 03:02
@jamesdorfman jamesdorfman changed the title fix: assert failure on non-policy asset consolidation in CreateTransactionInteral fix: assert failure on non-policy asset consolidation in CreateTransactionInternal Oct 27, 2023
Copy link
Member Author

@delta1 delta1 left a comment

Choose a reason for hiding this comment

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

tACK 406ce9a

ran unit and functional tests successfully

Comment on lines +18 to +22
"-blindedaddresses=1",
"-initialfreecoins=2100000000000000",
"-con_blocksubsidy=0",
"-con_connect_genesis_outputs=1",
"-txindex=1",
Copy link
Member Author

@delta1 delta1 Oct 27, 2023

Choose a reason for hiding this comment

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

I think these args should match the conf files from the tutorial. can be done as part of #1278

'8f1560e209f6bcac318569a935a0b2513c54f326ee4820ccd5b8c1b1b4632373': 0,
'4fa41f2929d4bf6975a55967d9da5b650b6b9bfddeae4d7b54b04394be328f7f': 99
}
assert self.nodes[0].gettransaction(reissuance_txid)['amount'] == expected_amt
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 think we could use some asserts of the balances before and after this whole process. not a showstopper though.

test/functional/test_runner.py Outdated Show resolved Hide resolved
@psgreco psgreco merged commit 20c5630 into ElementsProject:master Oct 27, 2023
4 of 13 checks passed
@delta1 delta1 deleted the issues-1259 branch October 27, 2023 16:55
jamesdorfman added a commit to jamesdorfman/elements that referenced this pull request May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Accepted for participation in Hacktoberfest.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants