Skip to content

Commit

Permalink
fix reference local spec file
Browse files Browse the repository at this point in the history
  • Loading branch information
Officeyutong committed Dec 2, 2024
1 parent 6b18315 commit 56d3604
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 25 deletions.
File renamed without changes.
261 changes: 261 additions & 0 deletions dev-spec.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
name = "ckb_dev"

[genesis]
version = 0
parent_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
timestamp = 0
compact_target = 0x20010000
uncles_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
nonce = "0x0"

[genesis.genesis_cell]
message = "1708649862081"

[genesis.genesis_cell.lock]
code_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
args = "0x"
hash_type = "data"

# An array list paths to system cell files, which is absolute or relative to
# the directory containing this config file.
[[genesis.system_cells]]
file = { bundled = "specs/cells/secp256k1_blake160_sighash_all" }
create_type_id = true
capacity = 100_000_0000_0000
[[genesis.system_cells]]
file = { bundled = "specs/cells/dao" }
create_type_id = true
capacity = 16_000_0000_0000
[[genesis.system_cells]]
file = { bundled = "specs/cells/secp256k1_data" }
create_type_id = false
capacity = 1_048_617_0000_0000
[[genesis.system_cells]]
file = { bundled = "specs/cells/secp256k1_blake160_multisig_all" }
create_type_id = true
capacity = 100_000_0000_0000
# [[genesis.system_cells]]
# file = { file = "sudt" }
# create_type_id = true
# [[genesis.system_cells]]
# file = { file = "xudt" }
# create_type_id = true
# [[genesis.system_cells]]
# file = { file = "omnilock" }
# create_type_id = true
# [[genesis.system_cells]]
# file = { bundled = "specs/cells/anyone_can_pay" }
# create_type_id = true
# [[genesis.system_cells]]
# file = { file = "always_success" }
# create_type_id = true
# [[genesis.system_cells]]
# file = { file = "spore/spore" }
# create_type_id = false
# [[genesis.system_cells]]
# file = { file = "spore/spore_cluster" }
# create_type_id = false
# [[genesis.system_cells]]
# file = { file = "spore/spore_cluster_agent" }
# create_type_id = false
# [[genesis.system_cells]]
# file = { file = "spore/spore_cluster_proxy" }
# create_type_id = false
# [[genesis.system_cells]]
# file = { file = "spore/spore_extension_lua" }
# create_type_id = false

[genesis.system_cells_lock]
code_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
args = "0x"
hash_type = "data"

# Dep group cells
[[genesis.dep_groups]]
name = "secp256k1_blake160_sighash_all"
files = [
{ bundled = "specs/cells/secp256k1_data" },
{ bundled = "specs/cells/secp256k1_blake160_sighash_all" },
]
[[genesis.dep_groups]]
name = "secp256k1_blake160_multisig_all"
files = [
{ bundled = "specs/cells/secp256k1_data" },
{ bundled = "specs/cells/secp256k1_blake160_multisig_all" },
]

# For first 11 block
[genesis.bootstrap_lock]
code_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
args = "0x"
hash_type = "type"

# Burn
[[genesis.issued_cells]]
capacity = 8_400_000_000_00000000
lock.code_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
lock.args = "0x62e907b15cbf27d5425399ebf6f0fb50ebb88f18"
lock.hash_type = "data"

#### account-list ####
# issue for account private key: 0x6109170b275a09ad54877b82f7d9930f88cab5717d484fb4741ae9d1dd078cd6
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x8e42b1999f265a0078503c4acec4d5e134534297"
lock.hash_type = "type"

# issue for account private key: 0x9f315d5a9618a39fdc487c7a67a8581d40b045bd7a42d83648ca80ef3b2cb4a1
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x758d311c8483e0602dfad7b69d9053e3f917457d"
lock.hash_type = "type"

# issue for account private key: 0x59ddda57ba06d6e9c5fa9040bdb98b4b098c2fce6520d39f51bc5e825364697a
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x9d1edebedf8f026c0d597c4c5cd3f45dec1f7557"
lock.hash_type = "type"

# issue for account private key: 0xf4a1fc19468b51ba9d1f0f5441fa3f4d91e625b2af105e1e37cc54bf9b19c0a1
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0xe65f823bc5a48a38515690604e503dba4eb15d61"
lock.hash_type = "type"

# issue for account private key: 0x0334ddff3b1e19af5c5fddda8dbcfb235416eaaba11cfca8acf63ad46e9f55b2
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x9665e6bc1966ec2bfcca4f11782d2b906f38438f"
lock.hash_type = "type"

# issue for account private key: 0x6f358d92f408511707803d292efa148236a2e114d73a472be2a07e0ba49200c7
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x0df9552f53d51a378aba267bc858dada447e8400"
lock.hash_type = "type"

# issue for account private key: 0xbde2f19c98dc5ab4cc98f73c573757a9f1782dc44398022a23f77ca752ad8fbe
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x683188bb29502ba6e702b7c650cc80707c3f8b4b"
lock.hash_type = "type"

# issue for account private key: 0x7c1280118923ea96529909638dac9bd258251a222783f91dedbf82de15526fd2
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x532bfb946e4b108d14758ca38e6e3b4af6801996"
lock.hash_type = "type"

# issue for account private key: 0x1fe1356d47224f34788eb099c4f67ab28a477a5a85d6ff4e54c240c11a0c693c
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x3982ac2f4893dfcac091ef795bb778cc2a25edd9"
lock.hash_type = "type"

# issue for account private key: 0xc3255dd2bbc3accc69c82bdb2c927ab4a681146331d5e01990890fb3cd732b47
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x5aab386e8a9f4f869776674c7181ea76fef75b55"
lock.hash_type = "type"

# issue for account private key: 0x8c3f8a6a6847a31af93000a31629f0c674e0cbb1b7cb71bdfbf4fb9dd828a518
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0xf6ca1c08a40ab3d00e2299930cf0f8c298a1a90d"
lock.hash_type = "type"

# issue for account private key: 0x11e34fc1bad213b1ce3071501a18c39e5dbf1ea2e66ac05059c36a5d1e7a56cf
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x5cb8098824329c3a2e731641ae4e90ba0a3ec396"
lock.hash_type = "type"

# issue for account private key: 0x0a0ecce6f15c444e6d0013d6eb79c87babff2c76447f3a2f6b28023490170c1f
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x516932280d5ff3108119fe2361d0868f1998dcc4"
lock.hash_type = "type"

# issue for account private key: 0x006250e940dbce94ad9329ac16c109acf7de98c7e4738013bdd3105d4f004d8a
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x7a83042ddabeb27294fe62588df7acc627d4181f"
lock.hash_type = "type"

# issue for account private key: 0xfc8142dc0a6c1dc9102696e7ca730b8c05e233549ea924fafa477f5086d94ac3
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x1416fe8e3e1d659a235f5f35b30f7cfbdf9fd77c"
lock.hash_type = "type"

# issue for account private key: 0x711aa98da3e9643170de94d6b16d3a30edf4bb231aa793aaac0fc7373c0f6322
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0xf246d3f9d94aab2688babb4802879056d9bf5810"
lock.hash_type = "type"

# issue for account private key: 0x76f51bf03e38b7f4a3c2cd8b088103e746f0e425fb0c5e0f8b22061f41c790cc
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x4ec295923dde1b522835007f9260e8ba398dc7cb"
lock.hash_type = "type"

# issue for account private key: 0x1ef1c9cbf031d7bc181c039cebb4f2914dbad689ab268e192fe22ea314d9b4a4
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0xd7ab64e757d1177a955a5c997a6ba7feab49161b"
lock.hash_type = "type"

# issue for account private key: 0xa5808e79c243d8e026a034273ad7a5ccdcb2f982392fd0230442b1734c98a4c2
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x9ba28269270223ba366a29dc96401910540894a4"
lock.hash_type = "type"

# issue for account private key: 0xace08599f3174f4376ae51fdc30950d4f2d731440382bb0aa1b6b0bd3a9728cd
[[genesis.issued_cells]]
capacity = 42_000_000_00000000
lock.code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8"
lock.args = "0x4118c8c16749bf126b22468d030bf9de7da3717b"
lock.hash_type = "type"
#### account-list ####


[params]
initial_primary_epoch_reward = 1_917_808_21917808
secondary_epoch_reward = 613_698_63013698
max_block_cycles = 10_000_000_000
cellbase_maturity = 0
primary_epoch_reward_halving_interval = 8760
epoch_duration_target = 14400
genesis_epoch_length = 1000
# For development and testing purposes only.
# Keep difficulty be permanent if the pow is Dummy. (default: false)
permanent_difficulty_in_dummy = true
starting_block_limiting_dao_withdrawing_lock = 0

[params.hardfork]
ckb2023 = 0


[pow]
func = "Dummy"
14 changes: 12 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.js"></script>
<script type="module">
import LightClient from "./light-client-js/dist/index.js";

const devConfig = await (await fetch("./dev-config.toml")).text();
const devSpec = await (await fetch("./dev-spec.toml")).text();

console.log(LightClient);
window.initWorkers = async () => {
$("#init-button").addClass("loading");
const client = new LightClient();
window.client = client;
await client.start();

await client.start(
{
type: "DevNet",
config: devConfig,
spec: devSpec
}
);

$("#init-button").removeClass("loading");
};
</script>
Expand Down
8 changes: 5 additions & 3 deletions light-client-js/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ClientFindCellsResponse, ClientFindTransactionsGroupedResponse, ClientFindTransactionsResponse, ClientIndexerSearchKeyLike, ClientIndexerSearchKeyTransactionLike, ClientTransactionResponse } from "@ckb-ccc/core/client";
import { FetchResponse, JsonRpcLocalNode, JsonRpcRemoteNode, JsonRpcScriptStatus, LocalNode, localNodeTo, RemoteNode, remoteNodeTo, ScriptStatus, scriptStatusFrom, scriptStatusTo, transformFetchResponse } from "./types";
import { FetchResponse, JsonRpcLocalNode, JsonRpcRemoteNode, JsonRpcScriptStatus, LocalNode, localNodeTo, NetworkFlag, RemoteNode, remoteNodeTo, ScriptStatus, scriptStatusFrom, scriptStatusTo, transformFetchResponse } from "./types";
import { ClientBlock, ClientBlockHeader, Hex, hexFrom, HexLike, Num, numFrom, NumLike, numToHex, TransactionLike } from "@ckb-ccc/core/barrel";
import { JsonRpcBlockHeader, JsonRpcTransformers } from "@ckb-ccc/core/advancedBarrel";
const DEFAULT_BUFFER_SIZE = 50 * (1 << 20);
Expand All @@ -26,8 +26,10 @@ class LightClient {
}
/**
* Start the light client.
* @param networkFlag Network flag for light-client-wasm. If you use DevNet, spec and config are necessary.
* @param logLevel Log Level for light-client-db-worker and light-client-wasm
*/
async start(logLevel: "debug" | "info" = "info") {
async start(networkFlag: NetworkFlag, logLevel: "debug" | "info" = "info") {
this.dbWorker.postMessage({
inputBuffer: this.inputBuffer,
outputBuffer: this.outputBuffer,
Expand All @@ -36,7 +38,7 @@ class LightClient {
this.lightClientWorker.postMessage({
inputBuffer: this.inputBuffer,
outputBuffer: this.outputBuffer,
netName: "dev",
networkFlag,
logLevel: logLevel
});
await new Promise<void>((res, rej) => {
Expand Down
2 changes: 1 addition & 1 deletion light-client-js/src/lightclient.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ onmessage = async (evt) => {
const data = evt.data as LightClientWorkerInitializeOptions;

wasmModule.set_shared_array(data.inputBuffer, data.outputBuffer);
await wasmModule.light_client(data.netName, data.logLevel);
await wasmModule.light_client(data.networkFlag, data.logLevel);
self.postMessage({});
loaded = true;
return;
Expand Down
6 changes: 4 additions & 2 deletions light-client-js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface DbWorkerInitializeOptions extends WorkerInitializeOptions {
}

interface LightClientWorkerInitializeOptions extends WorkerInitializeOptions {
netName: string;
networkFlag: NetworkFlag;
};

interface LightClientFunctionCall {
Expand Down Expand Up @@ -150,6 +150,7 @@ export function localNodeTo(input: JsonRpcLocalNode): LocalNode {
version: input.version
})
}
type NetworkFlag = { type: "MainNet" } | { type: "TestNet" } | { type: "DevNet"; spec: string; config: string; };

export type {
LightClientFunctionCall,
Expand All @@ -162,5 +163,6 @@ export type {
JsonRpcRemoteNode,
RemoteNode,
LocalNode,
JsonRpcLocalNode
JsonRpcLocalNode,
NetworkFlag
}
Loading

0 comments on commit 56d3604

Please sign in to comment.