-
Notifications
You must be signed in to change notification settings - Fork 361
[v0.3.5 phaseI III]:newConsensusType-outpostsL2 #504
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
base: feature/v12
Are you sure you want to change the base?
Conversation
01d8c18
to
a0570bc
Compare
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata newFrontier | ||
) external onlyGlobalExitRootRemover { | ||
_resetTree(newDepositCount, newFrontier); | ||
// emit event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth to call GER to udpate local exit tree
073e24c
to
a7c8ba3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨
542db88
to
c199a56
Compare
c199a56
to
1654927
Compare
function _isValidSubtreeFrontier( | ||
uint256 subTreeLeafCount, | ||
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata subTreeFrontier, | ||
bytes32[_DEPOSIT_CONTRACT_TREE_DEPTH] calldata currentTreeProof | ||
) internal pure returns (bool) { | ||
// Verify subtree frontier consistency with the proof | ||
uint256 index = subTreeLeafCount; | ||
uint256 height = 0; | ||
|
||
// Check each height where subtree frontier should have elements | ||
while (index != 0 && height < _DEPOSIT_CONTRACT_TREE_DEPTH) { | ||
if ((index & 1) == 1) { | ||
// At this height, subtree has an element that must match proof sibling | ||
if (subTreeFrontier[height] != currentTreeProof[height]) { | ||
return false; // Frontier element doesn't match proof | ||
} | ||
} | ||
// If bit is 0, subtree doesn't have element at this height (skip check) | ||
|
||
height++; | ||
index >>= 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guess this is the first approach, it should be marked as darft the PR
steps will be like::
Take the frist bit ( in reversed order) is different from both deposit counts.
Once that happen, proof inside that "branch" provide the merkle proof using the leftover frontier to get to the previous branch roort
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of picking the first bit in reverse order, I am picking the last one in normal order, I don't see what you mean.
1654927
to
0d0eb68
Compare
0d0eb68
to
f83ecf9
Compare
Introduces `_rollbackTree` to revert the Merkle tree state, with guards against invalid rollback operations. Implements permissioned functions to set claims and update local exit and balance trees, emitting events to signal changes. Extends tests to ensure proper permissions, event emissions, and correct functionality. Enhances contract security by restricting sensitive actions to authorized roles, leveraging robust revert conditions to maintain consistency. Relates to issue #123
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Also use leave struct at forwardLER
Introduces `_rollbackTree` to revert the Merkle tree state, with guards against invalid rollback operations. Implements permissioned functions to set claims and update local exit and balance trees, emitting events to signal changes. Extends tests to ensure proper permissions, event emissions, and correct functionality. Enhances contract security by restricting sensitive actions to authorized roles, leveraging robust revert conditions to maintain consistency. Relates to issue #123
Added checks wip
16975fc
to
242fcc4
Compare
Add Emergency Recovery Functions to Sovereign Bridge
📋 Overview
This PR introduces critical emergency recovery capabilities to the
BridgeL2SovereignChain
contract, enabling administrative intervention in edge cases and recovery scenarios for sovereign chain bridges when for any reason, Pessimistic Proof (PP) computation fails or tree states become inconsistent.✨ New Features
🔧 Emergency Administrative Functions
setMultipleClaims(uint256[] globalIndexes)
unsetMultipleClaims
backwardLET(uint256 newDepositCount, bytes32[32] newFrontier, bytes32 nextLeaf, bytes32[32] proof)
nextLeaf
exists at positionnewDepositCount
in current treenewFrontier
consistency with Merkle proof siblingsforwardLET(bytes32[] newLeaves, bytes32 expectedStateRoot)
_addLeaf()
for efficient bulk operationsexpectedStateRoot
setLocalBalanceTree(uint32[] originNetwork, address[] originTokenAddress, uint256[] amount)
🏗️ Infrastructure Changes
_isValidSubtreeFrontier()
in DepositContractBase🔒 Security Model
Access Control
onlyGlobalExitRootRemover
modifierCryptographic Security
backwardLET
uses rigorous mathematical validationforwardLET
validates final state against expected rootRisk Mitigation
backwardLET
prevents unauthorized forward movement📊 Events Added
BackwardLET(uint256 newDepositCount, bytes32 newRoot)
ForwardLET(uint256 newDepositCount, bytes32 newRoot)
SetClaim(uint32 leafIndex, uint32 sourceNetwork)
SetLocalBalanceTree(uint32 indexed originNetwork, address indexed originTokenAddress, uint256 newAmount)
🚨 Custom Errors Added
InvalidDepositCount()
: Invalid deposit count for tree operationsInvalidInclusionProof()
: Merkle proof validation failedInvalidLeavesLength()
: Empty or invalid leaves arrayInvalidExpectedRoot()
: Computed root doesn't match expectedInvalidSubtreeFrontier()
: Frontier inconsistent with proof siblings🧪 Testing
Comprehensive Test Coverage
backwardLET
forwardLET
🎯 Use Cases
These functions address critical recovery scenarios:
backwardLET
forwardLET
setMultipleClaims
🔄 Function Lifecycle
Typical Recovery Flow:
backwardLET
to return to known good stateforwardLET
to replay valid operationssetLocalBalanceTree
to correct token balancessetMultipleClaims
to restore valid claims📝 Migration Notes
setLocalExitTree
function (replaced bybackwardLET
/forwardLET
)🔧 Technical Details
Subtree Inclusion Algorithm
backwardLET
implements a sophisticated validation:nextLeaf
exists atnewDepositCount
positionnewFrontier
matches proof siblings at appropriate heightsOptimization Features
forwardLET
uses existing_addLeaf
for efficiencyVersion:
BRIDGE_SOVEREIGN_VERSION = "v10.2.2"
- Updated to reflect new emergency recovery capabilitiesTesting: 100% test coverage for all new functionality
Security: Cryptographically secure with comprehensive input validation