Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bridge new methods #1497

Merged
merged 34 commits into from
Apr 14, 2021
Merged

Bridge new methods #1497

merged 34 commits into from
Apr 14, 2021

Conversation

marcos-iov
Copy link
Contributor

Description

New public methods added to brdige, only for queries

Motivation and Context

Implements RSK220

The activation is Iris

The methods are
getBtcBlockchainBestBlockHeader()
getBtcBlockchainBlockHeaderByHash(hash)
getBtcBlockchainBlockHeaderByHeight(height)
getBtcBlockchainParentBlockHeaderByHash(hash)

How Has This Been Tested?

Code tests were added for new methods in Bridge and BridgeSupport

A manuel test:

Install npm install rskclitools -g

In a working folder, execute

rskcli sethost mainnet
rskcli newaccount alice
rskcli execute bridge.js

where bridge.js is

async function execute(context, args) {
    console.log('get best block number');
    const best = await context.command('call').execute([ 'alice', '0x01000006', 'getBtcBlockchainBestChainHeight()' ], { verbose: true });
    console.log('get best block header');
    await context.command('call').execute([ 'alice', '0x01000006', 'getBtcBlockchainBestBlockHeader()', 'bytes' ], { verbose: true });
    const hash = '0x0000000000000000004ac5d97713216c1162bdfe1bc30862990c550a1994c5a7';
    console.log('get block header by hash');
    await context.command('call').execute([ 'alice', '0x01000006', 'getBtcBlockchainBlockHeaderByHash(bytes32)', hash,  'bytes' ], { verbose: true });
    console.log('get parent block header by hash');
    await context.command('call').execute([ 'alice', '0x01000006', 'getBtcBlockchainParentBlockHeaderByHash(bytes32)', hash,  'bytes' ], { verbose: true });
    console.log('get block header by height');
    await context.command('call').execute([ 'alice', '0x01000006', 'getBtcBlockchainBlockHeaderByHeight(uint256)', best - 1,  'bytes' ], { verbose: true });
};

module.exports = execute;

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • Tests for the changes have been added (for bug fixes / features)
  • Requires Activation Code (Hard Fork)
  • Other information:

@marcos-iov marcos-iov requested review from donequis and a team April 9, 2021 16:08
@marcos-iov marcos-iov mentioned this pull request Apr 9, 2021
8 tasks
@marcos-iov marcos-iov force-pushed the bridge-methods-refactor branch from 56cf94f to 8d61996 Compare April 9, 2021 18:12
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 9, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 27 Code Smells

88.0% 88.0% Coverage
0.0% 0.0% Duplication

josedahlquist
josedahlquist previously approved these changes Apr 12, 2021
@marcos-iov marcos-iov changed the title Bridge methods refactor Bridge methodsnew Apr 13, 2021
@marcos-iov marcos-iov changed the title Bridge methodsnew Bridge new methods Apr 13, 2021
@ajlopezrsk ajlopezrsk merged commit be45938 into master Apr 14, 2021
@delete-merged-branch delete-merged-branch bot deleted the bridge-methods-refactor branch April 14, 2021 16:06
@aeidelman aeidelman added this to the Iris 3.0.0 milestone Jul 7, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants