Page MenuHomePhabricator

[Chronik] Add `ColoredTx` to `bitcoinsuite-slp`
ClosedPublic

Authored by tobias_ruck on Dec 22 2023, 00:16.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCa1ef9921f9aa: [Chronik] Add `ColoredTx` to `bitcoinsuite-slp`
Summary

This implements the coloring step §2 of ALP as well as the assignment of outputs of SLP, see the respective specs for details.

ColoredTx::color_tx takes a Tx as input, parses it as SLP or ALP, and assigns tokens to outputs according to the spec.

We keep track of the failed parsing and failed coloring attempts so we can later report them to the user.

Depends on D15030.

Test Plan

cargo -p bitcoinsuite-slp

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tobias_ruck updated this revision to Diff 43756.

clean up

Tail of the build log:

48 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

> chronik-client@0.9.0 integration-tests
> mocha -j1 -r ts-node/register test/integration/*.ts --reporter mocha-junit-reporter --reporter-options mochaFile=test_results/chronik-client-integration-tests-junit.xml --reporter-options testsuitesTitle=Chronik Client Integration Tests --reporter-options rootSuiteTitle=Chronik Client

Starting test_runner
Test runner started
2023-12-22T08:32:56.724000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20231222_083256/setup_scripts/chronik-client_blockchain_info_0
Setting chronik url to  http://127.0.0.1:30001
2023-12-22T08:32:58.977000Z TestFramework (INFO): Step 1: Mine 10 more blocks
2023-12-22T08:32:58.992000Z TestFramework (INFO): Received a stop message, exiting
2023-12-22T08:32:59.043000Z TestFramework (INFO): Stopping nodes
2023-12-22T08:32:59.649000Z TestFramework (INFO): Cleaning up /work/abc-ci-builds/chronik-client-integration-tests/test/tmp/test_runner_₿₵_🏃_20231222_083256/setup_scripts/chronik-client_blockchain_info_0 on exit
2023-12-22T08:32:59.649000Z TestFramework (INFO): Tests successful
Running Unit Tests for Test Framework Modules
setup_scripts/chronik-client_blockchain_info.py started
setup_scripts/chronik-client_blockchain_info.py passed, Duration: 3 s

TEST                                            | STATUS    | DURATION

setup_scripts/chronik-client_blockchain_info.py | ✓ Passed  | 3 s

ALL                                             | ✓ Passed  | 3 s (accumulated) 
Runtime: 3 s

-----------------------|---------|----------|---------|---------|-----------------------------------
File                   | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                 
-----------------------|---------|----------|---------|---------|-----------------------------------
All files              |    5.36 |     0.63 |    1.47 |    5.35 |                                   
 chronik-client        |     100 |      100 |     100 |     100 |                                   
  index.ts             |     100 |      100 |     100 |     100 |                                   
 chronik-client/proto  |     4.9 |     0.67 |    1.72 |    4.89 |                                   
  chronik.ts           |    5.44 |     0.84 |    1.81 |    5.42 | ...,3978-3985,3990-4027,4031-4036 
  chronikNode.ts       |    4.15 |     0.45 |    1.59 |    4.17 | ...,2682-2729,2740-2804,2808-2813 
 chronik-client/src    |    8.59 |        0 |       0 |    8.55 |                                   
  ChronikClient.ts     |    4.19 |        0 |       0 |    4.24 | 29-159,174-218,296-699            
  ChronikClientNode.ts |      40 |      100 |       0 |      40 | 23-42                             
  failoverProxy.ts     |    4.04 |        0 |       0 |    4.16 | 27-299                            
  hex.ts               |   31.57 |        0 |       0 |   33.33 | 30-34,38-42,46-59,63-65           
-----------------------|---------|----------|---------|---------|-----------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='156']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='2906']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='21']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='3282']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='8']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='541']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='154']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='2878']
##teamcity[blockClosed name='Code Coverage Summary']
Build chronik-client-integration-tests failed with exit code 1

I restarted the build, no idea why the integration tests returned an exit code 1

Fabien requested changes to this revision.Dec 22 2023, 22:20

Hard to be sure the tests are complete, it's a HUGE diff.

chronik/bitcoinsuite-slp/src/color.rs
432 ↗(On Diff #43760)

Shouldn't be continue instead of break ?

This revision now requires changes to proceed.Dec 22 2023, 22:20

Yeah, I get it's a bit big; but there's so much overlap between the different token versions that it'd be hard to put into separate diffs.

chronik/bitcoinsuite-slp/src/color.rs
432 ↗(On Diff #43760)

Continue would work fine too, but the self.outputs can't grow during the loop so break is a bit faster. output_idx is from a Range so it only increases

Fabien added inline comments.
chronik/bitcoinsuite-slp/src/color.rs
432 ↗(On Diff #43760)

output_idx is from a Range so it only increases

OK I was missing that, thanks for the explanation

This revision is now accepted and ready to land.Dec 25 2023, 09:27