-
Notifications
You must be signed in to change notification settings - Fork 19
feat: add tests #1448
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: develop
Are you sure you want to change the base?
feat: add tests #1448
Conversation
## 🔄 Changes Summary This PR adds a function to rewind merkle tree to a previous root index. (This will be used for backwarding of `LocalExitTree`). ##⚠️ Breaking Changes NA ## 📋 Config Updates NA ## ✅ Testing - 🤖 **Automatic**: `aggkit` CI
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Pull request overview
This pull request adds support for testing backward and forward Last Exit Tree (LET) operations by adjusting the deposit count semantics to use 1-indexed counting in events while maintaining 0-indexed internal storage.
- Modified processor logic to subtract 1 from event deposit counts when processing BackwardLET and ForwardLET events
- Updated test data to use 1-indexed deposit counts (deposit counts in events are now 1 higher than before)
- Enhanced error handling for Kurtosis artifact downloads with detailed troubleshooting information
- Updated E2E workflow to use newer commit references
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| bridgesync/processor.go | Adjusted BackwardLET and ForwardLET deposit count handling to subtract 1 from event values to convert from 1-indexed to 0-indexed internal representation |
| bridgesync/processor_test.go | Updated test data to use 1-indexed deposit counts; removed unused math import and test cases for overlapping BackwardLET and invalid deposit count validation |
| scripts/local_config_helper | Added dynamic artifact name construction, enhanced error messages for artifact downloads, and renamed variable from zkevm_rollup_chain_id to l2_chain_id |
| test/run-local-e2e.sh | Fixed shell pattern to avoid matching bare -, corrected ENCLAVE_NAME for pessimistic tests, commented out tests except for backward/forward LET test with filter |
| .github/workflows/test-e2e.yml | Updated agglayer-e2e-ref commit hashes to newer version |
| .github/test_e2e_op_args_base.json | Enabled deploy_cdk_bridge_infra flag |
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.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
| single-l2-network-op-succinct) | ||
| bats ./tests/aggkit/bridge-e2e.bats || exit 1 | ||
| bats ./tests/aggkit/e2e-pp.bats || exit 1 | ||
| bats ./tests/aggkit/bridge-sovereign-chain-e2e.bats || exit 1 |
Copilot
AI
Jan 10, 2026
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.
The removal of bats ./tests/aggkit/e2e-pp.bats test execution in the single-l2-network-op-succinct test type appears unrelated to the stated purpose of this PR (adding tests for backward and forward LET). This removal reduces test coverage for the op-succinct configuration. If this test is now obsolete or has been moved, this should be documented in the PR description. Otherwise, this appears to be an accidental deletion that reduces test coverage.
| # Extract service number from AGGKIT_SERVICE (e.g., aggkit-001 -> 001) | ||
| local SERVICE_NUMBER=$(echo "$AGGKIT_SERVICE" | sed 's/.*-//') |
Copilot
AI
Jan 10, 2026
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.
The artifact name construction uses sed 's/.*-//' to extract the service number, which assumes the service name always ends with a hyphen followed by the number. This could fail if the AGGKIT_SERVICE variable has a different format (e.g., no hyphen, multiple hyphens in unexpected places, or trailing text after the number). Consider using a more robust pattern like sed -n 's/.*-\([0-9]\+\)$/\1/p' to ensure only numeric suffixes are extracted, or validate the format before extraction.
| # Extract service number from AGGKIT_SERVICE (e.g., aggkit-001 -> 001) | |
| local SERVICE_NUMBER=$(echo "$AGGKIT_SERVICE" | sed 's/.*-//') | |
| # Extract numeric service number from AGGKIT_SERVICE (e.g., aggkit-001 -> 001) | |
| local SERVICE_NUMBER | |
| SERVICE_NUMBER=$(echo "$AGGKIT_SERVICE" | sed -n 's/.*-\([0-9]\+\)$/\1/p') | |
| if [ -z "$SERVICE_NUMBER" ]; then | |
| log_fatal "AGGKIT_SERVICE ('$AGGKIT_SERVICE') must end with a numeric suffix like 'aggkit-001'" | |
| fi |
| } | ||
|
|
||
| newDepositCount := uint32(event.PreviousDepositCount.Uint64()) + 1 | ||
| newDepositCount := uint32(event.PreviousDepositCount.Uint64()) |
Copilot
AI
Jan 10, 2026
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.
The change from uint32(event.PreviousDepositCount.Uint64()) + 1 to uint32(event.PreviousDepositCount.Uint64()) appears to change the semantics of how deposit counts are interpreted. This is a critical change that affects how bridges are indexed. The PreviousDepositCount now directly becomes the newDepositCount, rather than being incremented. Ensure this is the correct interpretation according to the contract's event semantics and that all consumers of this field are aware of this change in behavior.
| newDepositCount := uint32(event.PreviousDepositCount.Uint64()) | |
| newDepositCount := uint32(event.PreviousDepositCount.Uint64()) + 1 |
| prev, err := aggkitcommon.SafeUint64(new(big.Int).Sub(backwardLET.PreviousDepositCount, big.NewInt(1))) | ||
| if err != nil { | ||
| return fmt.Errorf("invalid previous deposit count: %w", err) | ||
| } | ||
|
|
||
| next, err := aggkitcommon.SafeUint64(backwardLET.NewDepositCount) | ||
| next, err := aggkitcommon.SafeUint64(new(big.Int).Sub(backwardLET.NewDepositCount, big.NewInt(1))) |
Copilot
AI
Jan 10, 2026
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.
The subtraction of 1 from both PreviousDepositCount and NewDepositCount in BackwardLET processing represents a significant semantic change. The adjustment is applied before converting to uint64 and storing in the database. This appears to change the interpretation of deposit counts from the contract events. Verify that this adjustment correctly aligns with the updated contract specification and that the query deposit_count > $1 AND deposit_count <= $2 in the restore logic still works correctly with the adjusted values.
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.
Can you explain why we are decreasing the (previous and next) deposit counts by one? I fail to understand the logic.
| adjustedCount := new(big.Int).Sub(event.BackwardLET.NewDepositCount, big.NewInt(1)) | ||
| newDepositCount, leafIndex, err := normalizeDepositCount(adjustedCount) |
Copilot
AI
Jan 10, 2026
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.
The adjustment of NewDepositCount by subtracting 1 before calling normalizeDepositCount changes the interpretation of BackwardLET events. This adjustment will affect which bridges are archived and deleted, as it changes the threshold value passed to archiveAndDeleteBridgesAbove. Ensure this aligns with the contract's actual behavior and that the corresponding forward LET handling has been updated consistently.
| adjustedCount := new(big.Int).Sub(event.BackwardLET.NewDepositCount, big.NewInt(1)) | |
| newDepositCount, leafIndex, err := normalizeDepositCount(adjustedCount) | |
| newDepositCount, leafIndex, err := normalizeDepositCount(event.BackwardLET.NewDepositCount) |
| }, | ||
| processBlockErrMsg: "invalid deposit count: value=4294967296 exceeds uint32 max", | ||
| }, | ||
| { |
Copilot
AI
Jan 10, 2026
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.
The removal of test cases for invalid deposit counts (negative values and values exceeding uint32 range) eliminates important edge case testing. These tests verified that the system properly handles malformed or invalid contract events. Without these tests, there's no verification that the system will reject or properly handle invalid deposit count values that could potentially be emitted from a compromised or buggy contract. Consider keeping these tests or replacing them with equivalent validation tests that work with the new deposit count interpretation.
| targetDepositCount: 8, | ||
| skipBlocks: []uint64{2, 3}, // all the bridges from these blocks were backwarded | ||
| archivedDepositCounts: []uint32{3, 4, 5}, | ||
| }, |
Copilot
AI
Jan 10, 2026
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.
The removal of the "overlapping backward let events" test case removes coverage for an important scenario where multiple BackwardLET events might interact. This test case verified that the system correctly handles consecutive BackwardLET events that operate on overlapping deposit count ranges. Without this test, there's less confidence that the refactored deposit count handling correctly manages these complex scenarios. Consider whether this scenario is still relevant with the new deposit count interpretation and, if so, restore or replace this test case.
ab225bf to
ccd81db
Compare
| prev, err := aggkitcommon.SafeUint64(new(big.Int).Sub(backwardLET.PreviousDepositCount, big.NewInt(1))) | ||
| if err != nil { | ||
| return fmt.Errorf("invalid previous deposit count: %w", err) | ||
| } | ||
|
|
||
| next, err := aggkitcommon.SafeUint64(backwardLET.NewDepositCount) | ||
| next, err := aggkitcommon.SafeUint64(new(big.Int).Sub(backwardLET.NewDepositCount, big.NewInt(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.
Can you explain why we are decreasing the (previous and next) deposit counts by one? I fail to understand the logic.
| } | ||
|
|
||
| newDepositCount, leafIndex, err := normalizeDepositCount(event.BackwardLET.NewDepositCount) | ||
| adjustedCount := new(big.Int).Sub(event.BackwardLET.NewDepositCount, big.NewInt(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.
Does the NewDepositCount get decremented by 1, because leaf with the index NewDepositCount gets rollbacked from the tree as well?
If that's the case, would it make more sense if we would delete all the nodes that has the index greater than or equal to NewDepositCount (also adjust the comments of the functions), instead of decrementing. WDYT?
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.
so basically what smart contract emits is deposit count which is 1 indexed (starts from 1 and not 0)
we here consider deposit count related to bridges which is 0 indexed (starts from 0)
so we need to manage accordingly here
|



🔄 Changes Summary
🐞 Issues
🔗 Related PRs