Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(config-manager): generate script config from genesis #552

Merged
merged 4 commits into from
Aug 16, 2023

Conversation

homura
Copy link
Collaborator

@homura homura commented Aug 15, 2023

Description

Resolve #510

Example

import { generateGenesisScriptConfigs } from '@ckb-luoms/config-manager'
import { RPC } from '@ckb-lumos/rpc'

const rpc = new RPC('http://127.0.0.1:8114')
const genesisBlock = rpc.getBlockByNumber('0x0')

const scriptConfigs = generateGenesisScriptConfigs(genesisBlock)
console.log(
  scriptConfigs.SECP256K1_BLAKE160,
  scriptConfigs.SECP256K1_BLAKE160_MULTISIG,
  scriptConfigs.DAO,
)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

@homura homura requested a review from zhangyouxin August 15, 2023 13:02
@vercel
Copy link

vercel bot commented Aug 15, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
lumos-website ✅ Ready (Inspect) Visit Preview Aug 16, 2023 5:33am

@codecov
Copy link

codecov bot commented Aug 15, 2023

Codecov Report

Merging #552 (dca9766) into develop (54f8aff) will increase coverage by 0.26%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #552      +/-   ##
===========================================
+ Coverage    86.35%   86.62%   +0.26%     
===========================================
  Files          114      115       +1     
  Lines        22928    23045     +117     
  Branches      2312     2330      +18     
===========================================
+ Hits         19800    19962     +162     
+ Misses        3086     3040      -46     
- Partials        42       43       +1     
Files Changed Coverage Δ
packages/common-scripts/src/deploy.ts 88.48% <100.00%> (ø)
packages/config-manager/src/genesis.ts 100.00% <100.00%> (ø)
packages/config-manager/src/index.ts 100.00% <100.00%> (+25.00%) ⬆️

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54f8aff...dca9766. Read the comment docs.

CODE_HASH: utils.computeScriptHash(
genesisBlock.transactions[SIGHASH_OUTPUT_LOC[0]].outputs[
SIGHASH_OUTPUT_LOC[1]
].type!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input parameter is genesisBlock: Block, which is assuming user to pass in a genesis block here.

But we should handle a situation when user feeds a non-genesis block, here using genesisBlock.transactions.outputs[x].type! it will throw error like: invalid script.

It will be better to throw Not a genesis block, please check the input block number like, then add a test case to cover that

@homura homura changed the title fix(common-scripts): incorrect tx hash calculation feat(config-manager): generate script config from genesis Aug 16, 2023
@homura homura merged commit 1cb43fe into develop Aug 16, 2023
@homura homura deleted the generate-genesis-script-config branch August 16, 2023 06:03
@github-actions github-actions bot mentioned this pull request Aug 16, 2023
@github-actions github-actions bot mentioned this pull request Nov 28, 2023
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.

Is it possible to provide a function to generate the lumos config for dev net?
2 participants