Skip to content

Conversation

@bgm-malbeclabs
Copy link
Collaborator

Summary of Changes

  • Describe what changed in the PR
  • Explain why the change is necessary
  • Note any metrics that were exposed in this PR
  • Is there supporting documentation or external resources that explain the change?
  • Is a CHANGELOG.md update needed?

Testing Verification

  • Show evidence of testing the change

Copy link

Copilot AI left a 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 PR introduces an end-to-end test script for the validator debt lifecycle in the DoubleZero system. The script automates testing of the complete debt flow from initialization through collection on a local Solana fork.

Changes:

  • Added a comprehensive bash script that orchestrates the full validator debt workflow: initialization, calculation, finalization, and debt collection
  • Implemented environment variable controls for selective step execution and epoch override
  • Included verification, logging utilities, and summary views for test observability

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

set -eu

# Constants
MAINNET_BETA_DEBT_ACCOUNTANT_KEY=acLisxTpNkoctPZoqssyo58pcdnHzJyRFhod7Wxkz5a
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The constant name suggests this is a mainnet-beta key, but it's being used in a local test environment. Consider renaming to TEST_DEBT_ACCOUNTANT_KEY or LOCAL_DEBT_ACCOUNTANT_KEY to clarify this is for testing purposes and avoid confusion with production keys.

Suggested change
MAINNET_BETA_DEBT_ACCOUNTANT_KEY=acLisxTpNkoctPZoqssyo58pcdnHzJyRFhod7Wxkz5a
TEST_DEBT_ACCOUNTANT_KEY=acLisxTpNkoctPZoqssyo58pcdnHzJyRFhod7Wxkz5a

Copilot uses AI. Check for mistakes.
sleep 2
done

log_error "Solana fork did not start within 60 seconds."
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The error message states '60 seconds' but this conflicts with the actual timeout calculation: 60 iterations × 2 seconds sleep = 120 seconds. Update the message to '120 seconds' for accuracy.

Suggested change
log_error "Solana fork did not start within 60 seconds."
log_error "Solana fork did not start within 120 seconds."

Copilot uses AI. Check for mistakes.
echo "$ $VALIDATOR_DEBT_CLI calculate-validator-debt --epoch $DZ_EPOCH -ul --dz-ledger-url http://localhost:8899"

# Note: This requires the DZ Ledger to be running or a mock.
# In local testing, we might need to use --post-to-ledger-only or --dry-run
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The comment mentions '--post-to-ledger-only' as a potential flag but this flag is never used in the actual command invocation. Either implement this flag in the fallback logic or remove it from the comment to avoid confusion.

Suggested change
# In local testing, we might need to use --post-to-ledger-only or --dry-run
# In local testing, we might need to use --dry-run

Copilot uses AI. Check for mistakes.
Comment on lines 327 to 329
# In god-mode, we need to wait for a minute between initializations
# so let's run the steps

Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

This comment is unclear and incomplete. It mentions waiting 'for a minute between initializations' and references 'god-mode', but neither concept is explained or implemented here. Either clarify what god-mode means and why a wait is needed, or remove the misleading comment.

Suggested change
# In god-mode, we need to wait for a minute between initializations
# so let's run the steps

Copilot uses AI. Check for mistakes.
Comment on lines 335 to 336
log_info "Waiting 5 seconds for transaction to confirm..."
sleep 5
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The hardcoded 5-second sleep is a magic number that may be insufficient for transaction confirmation in some environments. Consider extracting this to a configurable constant at the top of the file (e.g., TRANSACTION_CONFIRMATION_WAIT=5) and adding a comment explaining why this specific duration was chosen.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants