05Core Dev Bootcamp
Homework 1: Trace a Transaction Through All Phases
Objective
Use logging and debugging to trace a transaction through all four processing phases and document the state changes at each step.
Prerequisites
- A compiled rippled build (debug mode recommended)
- A running rippled instance in standalone mode
- Familiarity with rippled logging configuration
Tasks
Part 1: Enable Trace Logging
- Configure your rippled to enable trace-level logging for the transaction subsystem:
{
"log_level": "trace",
"log_channels": {
"Transactor": "trace",
"View": "trace"
}
}
Or use the command-line:
./rippled --standalone --conf=rippled.cfg
Then in another terminal:
./rippled log_level Transactor trace
./rippled log_level View trace
Part 2: Create Test Accounts
- Generate two test accounts using the
wallet_proposeRPC:
./rippled wallet_propose
- Fund both accounts using the genesis account in standalone mode.
- Record:
- Account 1 address and sequence number
- Account 2 address
- Initial balances for both accounts
Part 3: Submit a CheckCreate Transaction
- Create and sign a CheckCreate transaction:
{
"TransactionType": "CheckCreate",
"Account": "<Account1>",
"Destination": "<Account2>",
"SendMax": "100000000",
"Expiration": 800000000,
"Fee": "12",
"Sequence": <sequence>
}
- Submit the transaction using the
submitRPC.
Part 4: Analyze the Logs
Review the logs and identify entries for each phase:
Preflight Phase:
- What checks were logged?
- What was the result?
Preclaim Phase:
- What ledger entries were read?
- What checks were performed?
- What was the result?
doApply Phase:
- What ledger entries were created?
- What directories were modified?
- What owner counts changed?
Finalization:
- What was the final result code?
- What metadata was recorded?
Part 5: Document State Changes
Create a before/after comparison table:
| Object | Field | Before | After |
|---|---|---|---|
| Account1 AccountRoot | Balance | ? | ? |
| Account1 AccountRoot | OwnerCount | ? | ? |
| Account1 AccountRoot | Sequence | ? | ? |
| Check | (new) | N/A | ? |
| Account1 OwnerDir | Entries | ? | ? |
| Account2 OwnerDir | Entries | ? | ? |
Part 6: Verify with RPC
Use RPC commands to verify your analysis:
# Check account state
./rippled account_info <Account1>
# Check account objects
./rippled account_objects <Account1>
# Get transaction details
./rippled tx <transaction_hash>
Deliverables
- Log excerpts: Key log entries from each phase (with annotations)
- State change table: Completed before/after comparison
- Transaction metadata: The
metafield from thetxresponse - Analysis: Brief explanation of what happened in each phase
Bonus Challenge
Repeat the exercise with a transaction that fails:
- Create a CheckCreate to a non-existent account
- Trace through the phases
- Document where and why it failed
- Compare the logs to the successful case
Questions for Reflection
- At what point does the sequence number get consumed?
- At what point does the fee get deducted?
- If doApply fails with
tecINSUFFICIENT_RESERVE, what happens to the fee? - Why is the Check added to both account directories?