Repository navigation
Contract fixes: zero merkle root guard, in-place pending removal, snapshotted confirmation count in failure event - #185
Merged
Conversation
…mitted Merkl Closes terngunan#97
…ve_from_pend Closes terngunan#98
…global confi Closes terngunan#99
|
@josunday002 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Contract fixes: zero merkle root guard, in-place pending removal, snapshotted confirmation count in failure event
What was solved
#97 — reconciliation: Missing non-zero validation for submitted Merkle roots allows recording empty or null roots
Add a non-zero validation guard to
submit_merkle_rootin the reconciliation contract so all-zero Merkle roots are rejected, and add a unit test asserting the panic on a zero root while confirming valid non-zero roots still succeed.Addressed:
settliq_contracts/contracts/reconciliation/src/lib.rs, add a check insubmit_merkle_rootthat panics with a clear message (e.g. "merkle root must not be zero") whenmerkle_root == BytesN::from_array(&env, &[0u8; 32]).settliq_contracts/contracts/reconciliation/src/test.rsthat submits an all-zero 32-byte array and asserts the call panics/rejects.#98 — admin_timelock: Quadratic memory allocation in remove_from_pending when modifying pending changes list
Refactor
remove_from_pendingin the admin_timelock contract to mutate the existingPendingListvector in place usingfirst_index_of+remove(orswap_remove) instead of allocating a second vector and copying every non-matching ID. Add unit tests in the contract's test module that schedule and apply/cancel multiple changes and assertlist_pendingreflects the correct state.Addressed:
remove_from_pendinginsettliq_contracts/contracts/admin_timelock/src/lib.rsto locate the target index viafirst_index_ofand remove in place (e.g.pending.remove(pos)orswap_remove) rather than building a newVecand copying all non-matching IDs.apply_changeandcancel_change.settliq_contracts/contracts/admin_timelock/src/test.rsthat schedule multiple changes, apply/cancel some, and verifylist_pendingstate.#99 — stellar_confirmations: fail_confirmation publishes global confirmation count instead of the payment's snapshotted threshold
Fix
fail_confirmationin thestellar_confirmationscontract so theConfirmationFailedEventpublishes the payment's snapshotted required confirmation count (DataKey::PaymentRequiredConfs(payment_id)) instead of the current globalConfirmationCount, falling back to the global value only when no snapshot exists. Add a unit test that updates the global threshold after one confirmation, fails the payment, and asserts the event payload reflects the snapshotted threshold.Addressed:
fail_confirmation, read the required count fromDataKey::PaymentRequiredConfs(payment_id)(persistent storage) and fall back toDataKey::ConfirmationCount(instance storage) only when no snapshot is present.ConfirmationFailedEvent.requiredmust report the payment's snapshotted required confirmations.ConfirmationCountwhen no confirmations were recorded (no snapshot).Changes
settliq_contracts/contracts/reconciliation/src/test.rs(modify)settliq_contracts/contracts/stellar_confirmations/src/lib.rs(modify)settliq_contracts/contracts/reconciliation/src/lib.rs(modify)settliq_contracts/contracts/admin_timelock/src/lib.rs(modify)settliq_contracts/contracts/stellar_confirmations/src/test.rs(modify)Approach
Issues
Closes #97
Closes #98
Closes #99