Skip to content

Add x-only public key helper and bytecode check#233

Merged
BlobMaster41 merged 13 commits intomainfrom
feat/upgrade-op-vm
Feb 18, 2026
Merged

Add x-only public key helper and bytecode check#233
BlobMaster41 merged 13 commits intomainfrom
feat/upgrade-op-vm

Conversation

@BlobMaster41
Copy link
Contributor

@BlobMaster41 BlobMaster41 commented Feb 17, 2026

Add a defensive check to ContractEvaluator to reject empty contract bytecode. Apply minor formatting and refactors (wrapping/parameter formatting, compact filter formatting, single-line error logging, Uint8Array buffer handling) across TransactionConverterForAPI, PublicKeysRepository, and ContractEvaluator. Update tsconfig lib to use "ESNext".

Description

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Performance improvement
  • Consensus change (changes that affect state calculation or validation)
  • Refactoring (no functional changes)
  • Documentation update
  • CI/CD changes
  • Dependencies update

Checklist

Build & Tests

  • npm install completes without errors
  • npm run build completes without errors
  • npm test passes all tests

Code Quality

  • Code follows the project's coding standards
  • No new compiler warnings introduced
  • Error handling is appropriate
  • Logging is appropriate for debugging and monitoring

Documentation

  • Code comments added for complex logic
  • Public APIs are documented
  • README updated (if applicable)

Security

  • No sensitive data (keys, credentials) committed
  • No new security vulnerabilities introduced
  • RPC endpoints properly authenticated
  • Input validation in place for external data

OPNet Node Specific

  • Changes are compatible with existing network state
  • Consensus logic changes are documented and tested
  • State transitions are deterministic
  • WASM VM execution is reproducible across nodes
  • P2P protocol changes are backward-compatible (or migration planned)
  • Database schema changes include migration path
  • Epoch finality and PoC/PoW logic unchanged (or documented if changed)

Testing

Consensus Impact

Related Issues


By submitting this PR, I confirm that my contribution is made under the terms of the project's license.

Replace createPublicKey+toXOnly usage with createXOnlyPublicKey in PublicKeysRepository to produce x-only pubkeys. Add a defensive check to ContractEvaluator to reject empty contract bytecode. Apply minor formatting and refactors (wrapping/parameter formatting, compact filter formatting, single-line error logging, Uint8Array buffer handling) across TransactionConverterForAPI, PublicKeysRepository, and ContractEvaluator. Update tsconfig lib to use "ESNext".
@BlobMaster41 BlobMaster41 added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file clarity enhancement New feature or request bug Something isn't working labels Feb 17, 2026
Bump package version to 1.0.0-beta.1 and update multiple dependencies and dev tooling.

Notable dependency updates:
- @btc-vision/bip32 -> ^7.1.2
- @btc-vision/bitcoin -> ^7.0.0-rc.4
- @btc-vision/ecpair -> ^4.0.5
- @btc-vision/op-vm changed from local file reference to ^1.0.0-rc.0
- @btc-vision/transaction -> ^1.8.0-rc.3

Tooling updates:
- @eslint/js -> ^10.0.1
- eslint -> ^10.0.0
- @typescript-eslint/* -> ^8.56.0
- typescript-eslint -> ^8.56.0

Also applied a minor import formatting change in src/src/vm/runtime/ContractEvaluator.ts to reflow a multi-line import for readability.
Copy link
Contributor

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 a helper function for x-only public key creation, adds defensive bytecode validation, updates dependencies, and applies formatting improvements across the codebase. The changes focus on improving code quality and maintainability in the OPNet Node Bitcoin smart contracts system.

Changes:

  • Replace createPublicKey + toXOnly with createXOnlyPublicKey for x-only public key generation in PublicKeysRepository
  • Add empty bytecode validation check in ContractEvaluator to reject contracts with no bytecode beyond the version byte
  • Update dependency versions including @btc-vision packages, ESLint, and typescript-eslint
  • Simplify tsconfig.json lib configuration to use only "ESNext"
  • Apply formatting improvements (line wrapping, parameter formatting) across multiple files

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tsconfig.json Simplified lib array to use only "ESNext" instead of multiple ES versions and "dom"
src/src/vm/runtime/ContractEvaluator.ts Added empty bytecode check and improved parameter formatting for load/call methods
src/src/db/repositories/PublicKeysRepository.ts Replaced toXOnly(createPublicKey) with createXOnlyPublicKey in p2op method, improved formatting
src/src/api/data-converter/TransactionConverterForAPI.ts Improved ternary expression formatting for originalTransactionId
package.json Updated version to 1.0.0-beta.1 and bumped multiple dependencies

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

BlobMaster41 and others added 8 commits February 16, 2026 22:51
Add error chaining ({ cause: e }) to many thrown Errors to preserve original exceptions and improve debugging. Update ESLint config to use combined configs, allowDefaultProject for projectService, and disable 'no-useless-assignment'. Update package.json dependencies/devDependencies (add various libp2p, bson, chalk, express, multiformats, uint8arraylist, @typescript-eslint/utils, etc.; remove some unused dev deps). Minor code cleanups: reformat imports in PublicKeysRepository, add bson Document type import to StorageInterfaces, and small formatting adjustments. Update tsconfig.json to include DOM lib and reformat compilerOptions/paths.
Replace internal @libp2p/interface/src imports with public @libp2p/interface type imports (Connection, ConnectionGater, IdentifyResult, MultiaddrConnection) in P2PManager and ReusableStreamManager to rely on the official package surface and avoid importing internal paths. Remove DOM from tsconfig libs to restrict ambient DOM types. Also apply minor formatting/whitespace cleanup in PublicKeysRepository.
Collapse the mongodb import into a single line and adjust minor whitespace around the p2tr assignment. These are purely formatting changes (no functional modifications) to tidy the file.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Anakun <96896824+BlobMaster41@users.noreply.github.com>
Update TransactionInput tests to expect Uint8Array instances instead of Buffer and use the toHex helper for hex comparisons. Added import from '@btc-vision/bitcoin', adjusted witness test name and various assertions to reflect the code returning Uint8Array (byte lengths) and ensure consistent hex checks across the file.
Copy link
Contributor

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

Copilot reviewed 23 out of 24 changed files in this pull request and generated 1 comment.


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

Change key normalization to only remove a leading '0x' by checking startsWith('0x') and using slice(2) instead of replace('0x', ''). This avoids accidentally removing '0x' sequences occurring elsewhere in the string and preserves keys that don't have the prefix. Updates applied in PublicKeysRepository.ts before public-key validation and result handling.
Replace occurrences of .replace('0x','') with a safer check that only removes the "0x" prefix when present (uses startsWith('0x') ? slice(2) : str) across multiple modules. This avoids accidentally removing an interior "0x" and corrupting hex inputs, and standardizes hex handling for checksums, proofs, public keys, and buffers. Updated files include API routes, Merkle/Epoch processing, DB repositories, PoC networking/config, utilities, and VM validators to ensure consistent, correct hex parsing and subsequent length validations.
@BlobMaster41 BlobMaster41 requested a review from Copilot February 18, 2026 00:32
@BlobMaster41 BlobMaster41 merged commit 511ffe7 into main Feb 18, 2026
11 checks passed
@BlobMaster41 BlobMaster41 deleted the feat/upgrade-op-vm branch February 18, 2026 00:32
Copy link
Contributor

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

Copilot reviewed 34 out of 35 changed files in this pull request and generated no new comments.


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working clarity dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants