fix(signing): decouple multisign's tx_list borrow from Transaction's lifetime - #359
Open
soloking1412 wants to merge 1 commit into
Open
fix(signing): decouple multisign's tx_list borrow from Transaction's lifetime#359soloking1412 wants to merge 1 commit into
soloking1412 wants to merge 1 commit into
Conversation
…lifetime tx_list's borrow lifetime and T's Transaction<'a, F> data lifetime shared one type parameter, so a T inferred as 'static (routine for transactions built from string literals in an async block) forced the tx_list borrow to 'static as well. Give the borrow its own lifetime and take a slice instead of &Vec<T>, per Option A in the issue. Closes XRPLF#306
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
High Level Overview of Change
multisign's signature conflated two independent lifetimes under one parameter'a: the borrow lifetime oftx_listandT's ownTransaction<'a, F>data lifetime. Whenever a caller'sTgot inferred as'static(routine when a transaction is built from string literals inside an async block), the borrow oftx_listwas forced to'statictoo, leavingBox::leakas the only way to call the function. Implements Option A from #306: give the borrow its own lifetime and take a slice instead of&Vec<T>.'bis the short borrow lifetime;'aremainsT's own data lifetime, now free to be inferred independently. The function body only iteratestx_listonce and clones out each tx's first signer — it never stores the reference past the call, so a short, independent borrow is sufficient.&Vec<T>→&[T]is also more idiomatic and existing&veccall sites keep working via the standard slice coercion.Context of Change
Filed as #306 after
Box::leakshowed up as the only way to satisfy the borrow checker in the multisign integration test added by #298.Type of Change
Before / After
tests/transactions/multisign_payment.rspreviously had to leak the signer-signed-copiesVecto get a&'static Vec<_>:Now it's a plain local borrow:
Test Plan
cargo test --release: 1314 passed, including the existing unit test insrc/transaction/multisign.rs::test.cargo check --tests --features std,json-rpc,helpers,cli,websocket,integration: compiles clean, confirmingtests/transactions/multisign_payment.rsno longer needsBox::leakand matches CI's feature set (this test requires a livexrpldnode to actually execute, so it wasn't run end-to-end here — only compiled).cargo clippy --all-targets --features std,json-rpc,helpers,cli,websocket,integrationandcargo fmt --check: clean on both changed files.Closes #306