Skip to content

feat(wallet): reject broadcastTransaction when head block is too old#10

Open
xxo1shine wants to merge 1 commit intobase-codefrom
feature/broadcast-stale-head-block-check
Open

feat(wallet): reject broadcastTransaction when head block is too old#10
xxo1shine wants to merge 1 commit intobase-codefrom
feature/broadcast-stale-head-block-check

Conversation

@xxo1shine
Copy link
Copy Markdown
Owner

Add a pre-flight check in Wallet.broadcastTransaction() that compares the head block timestamp against wall clock time. If the lag exceeds the configurable threshold (default 30s, min 3s), the request is rejected with a new HEAD_BLOCK_TOO_OLD response code.

  • Add HEAD_BLOCK_TOO_OLD = 13 to Return.response_code in api.proto
  • Add NODE_MAX_HEAD_BLOCK_TIME_DEVIATION config key and CommonParameter field
  • Load and clamp the config value in Args.applyConfigParams()
  • Add commented default entry in config.conf
  • Add two WalletMockTest cases covering the reject and pass-through paths

What does this PR do?

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

Add a pre-flight check in Wallet.broadcastTransaction() that compares
the head block timestamp against wall clock time. If the lag exceeds
the configurable threshold (default 30s, min 3s), the request is
rejected with a new HEAD_BLOCK_TOO_OLD response code.

- Add HEAD_BLOCK_TOO_OLD = 13 to Return.response_code in api.proto
- Add NODE_MAX_HEAD_BLOCK_TIME_DEVIATION config key and CommonParameter field
- Load and clamp the config value in Args.applyConfigParams()
- Add commented default entry in config.conf
- Add two WalletMockTest cases covering the reject and pass-through paths

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant