nervosnetwork / capsule Goto Github PK
View Code? Open in Web Editor NEWCapsule is an out-of-box development framework for creating smart contract on Nervos' CKB.
License: MIT License
Capsule is an out-of-box development framework for creating smart contract on Nervos' CKB.
License: MIT License
Describe the bug
For long ckt address, capsule returns with error: parse address: "invalid checksum
Screenshots
Here is the command and error return
capsule deploy --address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqtp5rgl5262g5m2w7r9n4wc0wywsgvgk9cwc2mu8
thread 'main' panicked at 'parse address: "invalid checksum"', /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/ckb-capsule-0.10.0/src/bin/capsule.rs:378:48
note: run withRUST_BACKTRACE=1
environment variable to display a backtrace
If I change the long address to short address ckt1qyqxrgx3lg4553fk5auxt82as7ugaqsc3vtszxgefk. The error disappered.
Additional context
Capsule 0.10.0
ckb-cli installed v1.4.0 (required v1.2.0)
Let's make a release before (possible) major changes.
Executing these tests on Capsule 0.9.0
with rustc 1.63.0
exhibits the following behavior.
From Lumos JavaScript:
{
codeHash: DATA_FILE_HASH_1,
hashType: "data1",
args: "0x"
};
But then from the rust code:
debug!("script.args().len(): {:#?}", script.args().len());
debug!("script.args().as_slice().len(): {:#?}", script.args().as_slice().len());
And the output is:
script.args().len(): 0
script.args().as_slice().len(): 4
Keep up the Great work ๐ช
Phroi
Write about how to update existing projects.
Describe the bug
capsule new test
cd test; capsule build
โฏ capsule build
Building contract test2
Updating crates.io index
warning: spurious network error (2 tries remaining): [7] Couldn't connect to server (Failed to connect to 127.0.0.1 port 7070 after 0 ms: Connection refused); class=Net (12)
warning: spurious network error (1 tries remaining): [7] Couldn't connect to server (Failed to connect to 127.0.0.1 port 7070 after 0 ms: Connection refused); class=Net (12)
error: failed to get `ckb-testtool` as a dependency of package `tests v0.1.0 (/code/tests)`
Note: need to purge cargo package cache in docker first. Otherwise, it will not use network.
Screenshots
If applicable, add screenshots to help explain your problem. (The command and the output)
Additional context
Please post the following informations:
capsule --version
ckb-cli --version
RUST_BACKTRACE=1 RUST_LOG=capsule=trace
environment, then post the output as a file.Describe the bug
Running capsule deploy:
capsule deploy --address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqwgx292hnvmn68xf779vmzrshpmm6epn4c0cgwga
Returns the following error message:
thread 'main' panicked at 'parse capacity: "decimal part too long: 14"', /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ckb-capsule-0.10.1/src/wallet/cli_types/live_cell_info.rs:48:14
Additional context
capsule --version
: Capsule 0.10.1ckb-cli --version
: ckb-cli 1.4.0 (31c858e 2023-07-18)RUST_BACKTRACE=1 RUST_LOG=capsule=trace
:$ RUST_BACKTRACE=1 RUST_LOG=capsule=trace capsule deploy --address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqwgx292hnvmn68xf779vmzrshpmm6epn4c0cgwga
thread 'main' panicked at 'parse capacity: "decimal part too long: 14"', /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ckb-capsule-0.10.1/src/wallet/cli_types/live_cell_info.rs:48:14
stack backtrace:
0: rust_begin_unwind
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:593:5
1: core::panicking::panic_fmt
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:67:14
2: core::result::unwrap_failed
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/result.rs:1651:5
3: ckb_capsule::wallet::cli_types::live_cell_info::<impl core::convert::From<ckb_capsule::wallet::cli_types::live_cell_info::LiveCellInfo> for ckb_capsule::wallet::cli_types::live_cell::LiveCell>::from
4: ckb_capsule::wallet::collector::Collector::collect_live_cells
5: ckb_capsule::wallet::wallet::Wallet::collect_live_cells
6: ckb_capsule::wallet::wallet::Wallet::complete_tx_inputs
7: ckb_capsule::deployment::deployment_process::DeploymentProcess::build_recipe
8: ckb_capsule::deployment::deployment_process::DeploymentProcess::prepare_recipe
9: ckb_capsule::deployment::manage::Manage::deploy
10: capsule::run_cli
11: capsule::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Keep up the great work ๐ช
Phroi
Describe the bug
When I deployed the example of contract my-sudt
to dev chain, I found an error of PoolRejectedTransactionByMinFeeRate
which told me the transaction fee is too low to send the transaction to CKB.
Additional context
Please post the following informations:
capsule --version
: Capsule 0.2.3 23f16bfckb-cli --version
: ckb-cli 0.35.0 (3875086 2020-08-11) RUST_BACKTRACE=1 RUST_LOG=capsule=trace
environment, then post the output as a file.โ my-sudt RUST_BACKTRACE=1 RUST_LOG=capsule=trace capsule deploy --address ckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37
Create directory "/Users/duanyangyang/Documents/ckb/contracts/my-sudt/migrations/dev"
[2020-09-23T07:06:50Z TRACE capsule::deployment::deployment_process] build cell tx with inputs: []
[2020-09-23T07:06:50Z TRACE capsule::wallet::collector] parse ckb-cli output: 2439
[2020-09-23T07:06:50Z DEBUG capsule::wallet::collector] collect live cells: target 1729000010000 address ckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37 tip_number 2439
[2020-09-23T07:06:51Z TRACE capsule::wallet::collector] parse ckb-cli output: {
"current_capacity": "19999957999.98142531 (CKB)",
"current_count": 8,
"live_cells": [
{
"capacity": "87814.0 (CKB)",
"data_bytes": 87688,
"index": {
"output_index": 0,
"tx_index": 1
},
"lock_hash": "0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947",
"mature": true,
"number": 104,
"output_index": 0,
"tx_hash": "0x92a1da0ff9183454b129ad58c2ba835511c6e5ea676e165a66cfccf6a4eaaf03",
"type_hashes": [
"0x00000000000000000000000000000000000000000000000000545950455f4944",
"0x1b2860b35b780a95308b5c5b0d4bf0d82731235aa210a299bb08bf8b91e523fb"
]
},
{
"capacity": "87814.0 (CKB)",
"data_bytes": 87688,
"index": {
"output_index": 0,
"tx_index": 1
},
"lock_hash": "0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947",
"mature": true,
"number": 267,
"output_index": 0,
"tx_hash": "0xf4417c1e51b12cbda9d869de1bdd6c47d0bba3314e4f613982bf83113f4be254",
"type_hashes": [
"0x00000000000000000000000000000000000000000000000000545950455f4944",
"0x74a5e631bbf8e5e671bdccae7135d82906905079f797628b749ae49f905d4be9"
]
},
{
"capacity": "137.0 (CKB)",
"data_bytes": 76,
"index": {
"output_index": 0,
"tx_index": 1
},
"lock_hash": "0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947",
"mature": true,
"number": 374,
"output_index": 0,
"tx_hash": "0x4f0d4951878302f9d7c43673c329c28d803df62ff84f6dfae702b2da5175510f",
"type_hashes": null
},
{
"capacity": "137.0 (CKB)",
"data_bytes": 76,
"index": {
"output_index": 0,
"tx_index": 1
},
"lock_hash": "0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947",
"mature": true,
"number": 461,
"output_index": 0,
"tx_hash": "0x95c3ec44c9cd7aeebb0acaeb6075499d8a24766c543270bfd2f85276357ee1e7",
"type_hashes": null
},
{
"capacity": "137.0 (CKB)",
"data_bytes": 76,
"index": {
"output_index": 0,
"tx_index": 1
},
"lock_hash": "0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947",
"mature": true,
"number": 530,
"output_index": 0,
"tx_hash": "0x68cb28a634a62d55808306322c2cf5724cf1bfeae4c925b8b61b7d3d4657c3a7",
"type_hashes": null
},
{
"capacity": "87814.0 (CKB)",
"data_bytes": 87688,
"index": {
"output_index": 0,
"tx_index": 1
},
"lock_hash": "0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947",
"mature": true,
"number": 580,
"output_index": 0,
"tx_hash": "0xa3c85d0b09aefa56c3463a52b3d98593729c73ef98f8c5b6d4e335dfe5d63578",
"type_hashes": [
"0x00000000000000000000000000000000000000000000000000545950455f4944",
"0x83365cd2fa506a152b4373c58c504c8b45e9f2273d1f3810207b0510b8522f3a"
]
},
{
"capacity": "137.0 (CKB)",
"data_bytes": 76,
"index": {
"output_index": 0,
"tx_index": 1
},
"lock_hash": "0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947",
"mature": true,
"number": 584,
"output_index": 0,
"tx_hash": "0x4a4f293f32c20df7230384b859c7f49cdc6f9eb65c8a3b1803fa9ddcf789f828",
"type_hashes": null
},
{
"capacity": "19999694009.98142531 (CKB)",
"data_bytes": 0,
"index": {
"output_index": 2,
"tx_index": 1
},
"lock_hash": "0x32e555f3ff8e135cece1351a6a2971518392c1e30375c1e006ad0ce8eac07947",
"mature": true,
"number": 655,
"output_index": 2,
"tx_hash": "0xb8a0bfc9fbb9a17f43cb55b7147a32dcf1d49c5ca00df5af662b2d62d03658bf",
"type_hashes": null
}
],
"total_capacity": "19999957999.98142531 (CKB)",
"total_count": 8
}
[2020-09-23T07:06:51Z TRACE capsule::wallet::collector] get cells: from 0 to 1000000 cells 8
[2020-09-23T07:06:51Z TRACE capsule::deployment::deployment_process] found change outputs from previous tx: [LiveCell { tx_hash: H256 ( [ 0xa8, 0x4a, 0xf0, 0xd2, 0x8b, 0xc0, 0x09, 0xf8, 0x6e, 0xed, 0xeb, 0x16, 0x9c, 0xe9, 0x48, 0xf0, 0x50, 0xbb, 0x7e, 0xaa, 0xfa, 0xcf, 0x86, 0x22, 0x3f, 0x50, 0x22, 0x5d, 0xe5, 0x61, 0x55, 0x15 ] ), index: 1, capacity: 1999967678098132531, mature: true }]
[2020-09-23T07:06:51Z TRACE capsule::deployment::deployment_process] build dep group tx with inputs: [LiveCell { tx_hash: H256 ( [ 0xa8, 0x4a, 0xf0, 0xd2, 0x8b, 0xc0, 0x09, 0xf8, 0x6e, 0xed, 0xeb, 0x16, 0x9c, 0xe9, 0x48, 0xf0, 0x50, 0xbb, 0x7e, 0xaa, 0xfa, 0xcf, 0x86, 0x22, 0x3f, 0x50, 0x22, 0x5d, 0xe5, 0x61, 0x55, 0x15 ] ), index: 1, capacity: 1999967678098132531, mature: true }]
Deployment plan:
---
migrated_capacity: 0.0 (CKB)
new_occupied_capacity: 17366.0 (CKB)
txs_fee_capacity: 0.0002 (CKB)
total_occupied_capacity: 17366.0 (CKB)
recipe:
cells:
- name: my_cell
index: 0
tx_hash: "0xa84af0d28bc009f86eedeb169ce948f050bb7eaafacf86223f50225de5615515"
occupied_capacity: 17229.0 (CKB)
data_hash: "0x69d2db332dd48103b57134265814d5291afabbc273415a07d11b2f2d64fad019"
type_id: ~
dep_groups:
- name: my_dep_group
tx_hash: "0x827312ad334f7ffa83ab2ddd876e2692a6741e0b7e82db0d631b7bab8669f5c6"
index: 0
occupied_capacity: 137.0 (CKB)
Confirm deployment? (Yes/No)
yes
Password:
(1/2) Sending tx a84af0d28bc009f86eedeb169ce948f050bb7eaafacf86223f50225de5615515
[2020-09-23T07:06:59Z DEBUG capsule::deployment::deployment_process] send transaction error: TransactionView { data: Transaction { raw: RawTransaction { version: Uint32(0x00000000), cell_deps: CellDepVec [CellDep { out_point: OutPoint { tx_hash: Byte32(0xace5ea83c478bb866edf122ff862085789158f5cbff155b7bb5f13058555b708), index: Uint32(0x00000000) }, dep_type: Byte(0x01) }], header_deps: Byte32Vec [], inputs: CellInputVec [CellInput { since: Uint64(0x0000000000000000), previous_output: OutPoint { tx_hash: Byte32(0xb8a0bfc9fbb9a17f43cb55b7147a32dcf1d49c5ca00df5af662b2d62d03658bf), index: Uint32(0x02000000) } }], outputs: CellOutputVec [CellOutput { capacity: Uint64(0x00add72491010000), lock: Script { code_hash: Byte32(0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8), hash_type: Byte(0x01), args: Bytes(0xc8328aabcd9b9e8e64fbc566c4385c3bdeb219d7) }, type_: ScriptOpt(None) }, CellOutput { capacity: Uint64(0x334e4dc70150c11b), lock: Script { code_hash: Byte32(0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8), hash_type: Byte(0x01), args: Bytes(0xc8328aabcd9b9e8e64fbc566c4385c3bdeb219d7) }, type_: ScriptOpt(None) }], outputs_data: BytesVec [] }, witnesses: BytesVec [Bytes(0x550000001000000055000000550000004100000066a774765fee56dd4b62319dcaf73b589afc9d569a3a7f72bb821dc6bbe6cb55635ab30239910201c537d22a096c8825ec546307e9c004647d04e3be5c83b7ce00)] }, hash: Byte32(0x676139fd022ee690c3f7cd778827ec008d8b25607eb0afc321fd8d90719baab0), witness_hash: Byte32(0xdf7f6cbaf6b926fd8ee1f9bdd3a0feda8cd29e4ced15b3d7311cba00f135a419) }
thread 'main' panicked at 'rpc call send_transaction: Jsonrpc(Error { code: ServerError(-1104), message: "PoolRejectedTransactionByMinFeeRate: Transaction fee rate must >= 17632 shannons/KB, got: 10000", data: Some(String("LowFeeRate(17632, 10000)")) })', /Users/runner/.cargo/git/checkouts/ckb-tool-dd87017d5063101c/b9b629c/tool/src/rpc_client.rs:103:9
stack backtrace:
0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
1: core::fmt::write
2: std::io::Write::write_fmt
3: std::panicking::default_hook::{{closure}}
4: std::panicking::default_hook
5: std::panicking::rust_panic_with_hook
6: rust_begin_unwind
7: core::panicking::panic_fmt
8: core::result::unwrap_failed
9: ckb_tool::rpc_client::RpcClient::send_transaction
10: capsule::wallet::wallet::Wallet::send_transaction
11: capsule::deployment::deployment_process::DeploymentProcess::execute_recipe
12: capsule::deployment::manage::Manage::deploy
13: capsule::run_cli
14: capsule::main
15: std::rt::lang_start::{{closure}}
16: std::rt::lang_start_internal
17: main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
In the current version, even we specific workspace_dir
, the new-contract still add a rust contract to the /Cargo.toml
.
Describe the bug
in capsule, I can use the code 'load_cell_data_hash(0, Source::Input)?' to get the hash of CellData from tx.inputs[0],
however, I failed to get the hash of CellData from tx.inputs[0] by using the same code in ckb-vm.
Ckb-vm is not allowed user to get the CellDataHash from tx.inputs.
Additional context
I use the typescript contract by c to check if I can get the CellDataHash in ckb chain:
int main() {
ckb_debug( "begin" );
uint8_t buffer[1000];
uint64_t len_data = 1;
int ret_data = ckb_load_cell_data(buffer, &len_data, 0, 0, CKB_SOURCE_INPUT);
if (ret_data != CKB_SUCCESS) {
return ret_data;
}
ckb_debug( "ckb_load_cell_data success" );
// get data hash
uint64_t len = BLAKE2B_BLOCK_SIZE;
unsigned char data_hash[BLAKE2B_BLOCK_SIZE];
int ret = ckb_load_cell_by_field( data_hash, &len, 0, 0, CKB_SOURCE_INPUT, CKB_CELL_FIELD_DATA_HASH);
if (ret != CKB_SUCCESS) {
return ret;
}
ckb_debug( "SUCCESS CKB_SOURCE_INPUT Datahash!" );
return 0;
}
It failed.
Adding some cfg(test)
we can support unit tests in contracts (compiling and running on host native arch).
It might even be possible to cross test
for riscv64gc-unknown-linux-gnu
(but probably not for riscv64imac-unknown-none-elf
).
Describe the bug
Build https://github.com/nervosnetwork/godwoken-scripts with 0.7.2:
โฏ capsule --version
Capsule 0.7.2
โฏ capsule build
Building contract state-validator
error: toolchain 'nightly-2021-08-16-x86_64-unknown-linux-gnu' is not installed
error: docker container exit with code Some(1)
The capsule.toml file: https://github.com/nervosnetwork/godwoken-scripts/blob/master/capsule.toml#L5
It might be the problem of the following:
[rust]
workspace_dir = "contracts"
toolchain = "nightly-2021-08-16"
The image should be download automatically.
Screenshots
If applicable, add screenshots to help explain your problem. (The command and the output)
Additional context
Please post the following informations:
capsule --version
ckb-cli --version
RUST_BACKTRACE=1 RUST_LOG=capsule=trace
environment, then post the output as a file.Describe the bug
A moleculec not found error occurs on c-sharedlib contracts. Molecule is not listed as a prerequisite of Capsule.
Screenshots
username@dev1:~$ capsule new project
New project "project"
Created file "capsule.toml"
Created file "deployment.toml"
Created file "README.md"
Created file "Cargo.toml"
Created file ".gitignore"
Initialized empty Git repository in /home/username/project/.git/
Created "/home/username/project"
Created tests
Created library `tests` package
New contract "project"
Created binary (application) `project` package
Rewrite Cargo.toml
Rewrite ckb_capsule.toml
Done
username@dev1:~$ cd project
username@dev1:~/project$ capsule new-contract sharedlib --template c-sharedlib
Setup C environment
Cloning into '/home/username/project/contracts/c/deps/ckb-c-stdlib'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 205 (delta 1), reused 4 (delta 1), pack-reused 196
Receiving objects: 100% (205/205), 108.79 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (93/93), done.
New contract "sharedlib"
Rewrite Makefile
Rewrite ckb_capsule.toml
Done
username@dev1:~/project$ capsule build
Building contract project
Updating crates.io index
Compiling cfg-if v0.1.10
Compiling cc v1.0.41
Compiling buddy-alloc v0.3.0
Compiling molecule v0.6.0
Compiling ckb-allocator v0.1.1
Compiling ckb-standalone-types v0.0.1-pre.1
Compiling ckb-std v0.6.3
Compiling project v0.1.0 (/code/contracts/project)
Finished dev [unoptimized + debuginfo] target(s) in 6.29s
Building contract sharedlib
curl -L -o build/blockchain.mol https://raw.githubusercontent.com/nervosnetwork/ckb/d75e4c56ffa40e17fd2fe477da3f98c5578edcd1/util/types/schemas/blockchain.mol
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2357 100 2357 0 0 21623 0 --:--:-- --:--:-- --:--:-- 21824
moleculec --language c --schema-file build/blockchain.mol > build/blockchain.h
/bin/sh: 1: moleculec: not found
make: *** [Makefile:30: build/blockchain.h] Error 127
error: process exit with code Some(2)
Additional context
Please post the following informations:
username@dev1:~/project$ capsule --version
Capsule 0.4.1 303dfcb
username@dev1:~/project$ ckb-cli --version
ckb-cli 0.35.0 (3875086 2020-08-11)username@dev1:~/project$
RUST_BACKTRACE=1 RUST_LOG=capsule=trace
environment, then post the output as a file.username@dev1:~/project$ capsule build
Building contract project
Updating crates.io index
Compiling cfg-if v0.1.10
Compiling cc v1.0.41
Compiling buddy-alloc v0.3.0
Compiling molecule v0.6.0
Compiling ckb-allocator v0.1.1
Compiling ckb-standalone-types v0.0.1-pre.1
Compiling ckb-std v0.6.3
Compiling project v0.1.0 (/code/contracts/project)
Finished dev [unoptimized + debuginfo] target(s) in 6.29s
Building contract sharedlib
curl -L -o build/blockchain.mol https://raw.githubusercontent.com/nervosnetwork/ckb/d75e4c56ffa40e17fd2fe477da3f98c5578edcd1/util/types/schemas/blockchain.mol
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2357 100 2357 0 0 21623 0 --:--:-- --:--:-- --:--:-- 21824
moleculec --language c --schema-file build/blockchain.mol > build/blockchain.h
/bin/sh: 1: moleculec: not found
make: *** [Makefile:30: build/blockchain.h] Error 127
error: process exit with code Some(2)
username@dev1:~/project$ capsule --version
Capsule 0.4.1 303dfcb
username@dev1:~/project$ ckb-cli --version
ckb-cli 0.35.0 (3875086 2020-08-11)username@dev1:~/project$ cd ..
username@dev1:~$ rm -rf project
username@dev1:~$ RUST_BACKTRACE=1 RUST_LOG=capsule=trace capsule new project
New project "project"
Created file "capsule.toml"
Created file "deployment.toml"
Created file "README.md"
Created file "Cargo.toml"
Created file ".gitignore"
Initialized empty Git repository in /home/username/project/.git/
Created "/home/username/project"
Created tests
Created library `tests` package
New contract "project"
Created binary (application) `project` package
Rewrite Cargo.toml
Rewrite ckb_capsule.toml
Done
username@dev1:~$ cd project/
username@dev1:~/project$ RUST_BACKTRACE=1 RUST_LOG=capsule=trace capsule new-contract sharedlib --template c-sharedlib
Setup C environment
Cloning into '/home/username/project/contracts/c/deps/ckb-c-stdlib'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 205 (delta 1), reused 4 (delta 1), pack-reused 196
Receiving objects: 100% (205/205), 108.79 KiB | 1.29 MiB/s, done.
Resolving deltas: 100% (93/93), done.
New contract "sharedlib"
Rewrite Makefile
Rewrite ckb_capsule.toml
Done
username@dev1:~/project$ RUST_BACKTRACE=1 RUST_LOG=capsule=trace capsule build
Building contract project
Updating crates.io index
Compiling cfg-if v0.1.10
Compiling cc v1.0.41
Compiling buddy-alloc v0.3.0
Compiling molecule v0.6.0
Compiling ckb-allocator v0.1.1
Compiling ckb-standalone-types v0.0.1-pre.1
Compiling ckb-std v0.6.3
Compiling project v0.1.0 (/code/contracts/project)
Finished dev [unoptimized + debuginfo] target(s) in 6.72s
Building contract sharedlib
curl -L -o build/blockchain.mol https://raw.githubusercontent.com/nervosnetwork/ckb/d75e4c56ffa40e17fd2fe477da3f98c5578edcd1/util/types/schemas/blockchain.mol
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2357 100 2357 0 0 5572 0 --:--:-- --:--:-- --:--:-- 5558
moleculec --language c --schema-file build/blockchain.mol > build/blockchain.h
/bin/sh: 1: moleculec: not found
make: *** [Makefile:30: build/blockchain.h] Error 127
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: process exit with code Some(2)
Stack backtrace:
0: ckb_capsule::util::cli::run
1: <ckb_capsule::recipe::c::C<R> as ckb_capsule::recipe::Recipe>::run_build
2: capsule::run_cli
3: capsule::main
4: std::sys_common::backtrace::__rust_begin_short_backtrace
5: std::rt::lang_start::{{closure}}
6: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/core/src/ops/function.rs:259
std::panicking::try::do_call
at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/panicking.rs:381
std::panicking::try
at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/panicking.rs:345
std::panic::catch_unwind
at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/panic.rs:382
std::rt::lang_start_internal
at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/rt.rs:51
7: main
8: __libc_start_main
9: _start', src/bin/capsule.rs:404:17
stack backtrace:
0: rust_begin_unwind
at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/std/src/panicking.rs:483
1: core::panicking::panic_fmt
at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/core/src/panicking.rs:85
2: core::option::expect_none_failed
at /rustc/7f7a1cbfd3b55daee191247770627afab09eece2/library/core/src/option.rs:1234
3: capsule::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Describe the bug
There are no binaries for the release v0.8.0
Executing these tests shows that Capsule 0.9.0
with rustc 1.63.0
suffer from:
VM Internal Error: MemOutOfBound
when executing any non trivial script.Transaction timeout
when executing always
success script.Note: creating and executing tests for these scripts will not manifest these issues without a full CKB VM environment.
The same scripts compiled with Capsule 0.7.3
don't have these issues.
Some research on these issues has been done already by Travis Lee Richardson and Jordan Mack.
Keep up the Great work ๐ช
Phroi
Should not load x86 docker images for cross
> cross build -p joyid-lock --release
Unable to find image 'ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main' locally
main: Pulling from cross-rs/x86_64-unknown-linux-gnu
edaedc954fb5: Pull complete
c6077a2cc41a: Pull complete
50ab2986c99f: Pull complete
678ffa738a4e: Pull complete
b421ee7848df: Pull complete
484a764f3dc4: Pull complete
67e6443952a5: Pull complete
5dc94db61e37: Pull complete
144f8786ac8f: Pull complete
80ac8dae6b94: Pull complete
dc4eb81c27c0: Pull complete
e4679d20334d: Pull complete
3ce4ce3641cc: Pull complete
fef558c2d27d: Pull complete
Digest: sha256:079d0fb10d7fb863e743fbd20876c91177209f812dd7f463c2a2b85b5059fd43
Status: Downloaded newer image for ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main
Compiling ckb-lib-rsa v0.1.0 (/home/dylan/ckb/contracts/joyid-contract/ckb-lib-rsa)
Compiling ckb-lib-secp256k1 v0.1.0 (/home/dylan/ckb/contracts/joyid-contract/ckb-lib-secp256k1)
Compiling ckb-lib-smt v0.1.0 (/home/dylan/ckb/contracts/joyid-contract/ckb-lib-smt)
Compiling ckb-lib-secp256r1 v0.1.0 (/home/dylan/ckb/contracts/joyid-contract/ckb-lib-secp256r1)
error[E0432]: unresolved import `ckb_std::dynamic_loading_c_impl`
--> ckb-lib-secp256r1/src/libsecp256r1.rs:2:14
|
2 | use ckb_std::dynamic_loading_c_impl::{CKBDLContext, Symbol};
| ^^^^^^^^^^^^^^^^^^^^^^ could not find `dynamic_loading_c_impl` in `ckb_std`
error[E0432]: unresolved import `ckb_std::dynamic_loading_c_impl`
The suggestion from xjd is adding Cross.toml file and upgrading ckb-std:
> cat Cross.toml
[build]
default-target = "riscv64imac-unknown-none-elf"
[target.riscv64imac-unknown-none-elf]
image = "nervos/ckb-riscv-gnu-toolchain:focal-20230214"
capsule --version
Capsule 0.10.1
ckb-cli --version
ckb-cli 1.4.0 (31c858e 2023-07-18)
Ctrl+C should be supported to terminate compiling process.
Add an option to use cargo instead of cross?
This would require natively installed riscv64-unknown-elf-gcc instead of cross and docker.
This can be an option in the config file and can be overridden with an environment variable.
Describe the bug
It seems ckb-cli v1.4.0
needs to use option --wait-for-sync
for rpc
subcommand, but in capsule v0.8.0 there is no use that matches this pattern. So it makes the failure of deploying contract using capsule.
Additional context
Please post the following informations:
Moved from: #50
https://docs.nervos.org/docs/labs/sudtbycapsule#install-capsule
โโ
Note: The current user must have permission to manage Docker instances. (How to manage Docker as a non-root user)[https://docs.docker.com/engine/install/linux-postinstall/].
Now you can proceed to install capsule, It is recommended to download the binary โโ
the download linked to the old version 0.1.3 , and it causes me to wrong result .
As per title, I'm wondering: within a Rust L1 script, what's the most idiomatic way to calculate script hash from a Script instance?
I'm asking here since GitHub issues are SEO friendly and very likely in the future there will be other L1 developers wondering the same ๐
Phroi
Describe the bug
capsule build
hangs on M1 Mac.
Screenshots
If applicable, add screenshots to help explain your problem. (The command and the output)
It just stopped here for more than 15 mins.
Additional context
/tmp/capsule
๐ 11:03:07 โฏ capsule new my-demo
New project "my-demo"
Created file "capsule.toml"
Created file "deployment.toml"
Created file "README.md"
Created file "Cargo.toml"
Created file ".gitignore"
Initialized empty Git repository in /private/tmp/capsule/my-demo/.git/
Created "/private/tmp/capsule/my-demo"
Created tests
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Created library `tests` package
New contract "my-demo"
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Created binary (application) `my-demo` package
Rewrite Cargo.toml
Rewrite capsule.toml
Done
/tmp/capsule took 2s
๐ 11:03:13 โฏ cd my-demo
my-demo on ๎ master [?] via ๐ฆ v1.59.0-nightly
๐ 11:03:20 โฏ capsule build
Building contract my-demo
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Updating crates.io index
Compiling memchr v2.4.1
Compiling cfg-if v1.0.0
Compiling cc v1.0.72
Compiling cty v0.2.2
Compiling buddy-alloc v0.4.1
Compiling molecule v0.7.2
Compiling ckb-standalone-types v0.1.2
Compiling cstr_core v0.2.4
Please post the following informations:
capsule --version
ckb-cli --version
RUST_BACKTRACE=1 RUST_LOG=capsule=trace
environment, then post the output as a file.my-demo on ๎ master [?] via ๐ฆ v1.59.0-nightly
๐ 11:18:23 โฏ capsule --version
Capsule 0.7.1
my-demo on ๎ master [?] via ๐ฆ v1.59.0-nightly
๐ 11:18:27 โฏ ckb-cli --version
ckb-cli 0.35.0 (3875086 2020-08-11)%
What's the best practices to setup the local development environment so that
My current approach:
This is not perfect, I still got errors like
found duplicate lang item `oom`
the lang item is first defined in crate `std` (which `test` depends on)
first definition in `std` loaded from /home/gitpod/.rustup/toolchains/nightly-2022-08-01-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-c28e44e30a7ed831.rlib
second definition in the local crate (`...`)
But at least, I have a working rustfmt and rust-analyzer in the project.
I know I should use the target riscv64-unknown-elf-gcc instead of the host default target, but I don't know how to setup all the required packages.
In integration tests:
...
Clean contract ...
chown: cannot access '/code/target': No such file or directory
...
Executing new-contract
with the --template
flag without an argument is successful, but an error should be presented.
username@dev1:~/dev$ capsule new-contract test1 --template
New contract "test1"
Created binary (application) `test1` package
Rewrite Cargo.toml
Rewrite ckb_capsule.toml
Done
Capsule Version: Capsule 0.4.2 dcfac5b
Although most of us like Rust, from time to time, C library might be needed here. We do want to provide a seamless integration with C library.
This issue covers 2 parts:
Last week I tried to compile rhai into our script, but one of its denpendecies named smartstring requires edition 2021. ๐
rhai seems to be a good choice for integrating some simple DSL into scripts, so I hope you guys could upgrade the docker image to support edition 2021 in the new future.
We need to check the deployment transactions before sent them; make sure there no type_id be destroyed. If a user intended to destroy type_id of a cell, the user must explicitly pass the type_id in the command line.
Describe the bug
In some projects, the capsule build --release
will raise this error.
jordanmack/nervos-ckb-nft@f38598c
Screenshots
jjy@LAPTOP-BRD86RAC:~/workspace/nervos-ckb-nft$ capsule build --name nft --release
Building contract nft
Compiling nft v0.1.0 (/code/contracts/nft)
LLVM ERROR: Incomplete scavenging after 2nd pass
error: could not compile `nft`
To learn more, run the command again with --verbose.
error: docker container exit with code Some(101)
Additional context
capsule --version
Capsule 0.4.1
Solution
This supposed to be an upstream issue, to edit the Cargo.toml
lto=false
can get around this in capsule projects.
There are some difference between running on the ckb-chain
and running on the capsule test, so hopefully it will have some hints when it runs on the capsule test.
Warning developers that the tx
might have problems with running on ckb-chain
can be helpful in identifying design issues which are easily overlooked.
It's not a necessary need but for icing on the cake. ^_^
$ capsule build --release
Building contract nft-validator
Compiling ckb-std v0.9.0
error[E0635]: unknown feature `llvm_asm`
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ckb-std-0.9.0/src/lib.rs:12:12
|
12 | #![feature(llvm_asm)]
| ^^^^^^^^
For more information about this error, try `rustc --explain E0635`.
error: could not compile `ckb-std` due to previous error
error: docker container exit with code Some(101)
$ capsule --version
Capsule 0.8.0
$ ckb-cli --version
ckb-cli 0.103.0 (1dd9cd7 2022-05-27)
Hi all, When I compile the ckb-contracts of force-bridge-eth using capsule build --release
, it returns some error message like:
unexpected parts after split whitespaces: 0
capsule check
------------------------------
docker installed
ckb-cli installed v0.101.3
------------------------------
Describe the bug
โฏ capsule build --help
capsule-build
Build contracts
USAGE:
capsule build [FLAGS] [OPTIONS]
FLAGS:
--debug-output Always enable debugging output
-h, --help Prints help information
--host Docker runs in host mode
--release Build contracts in release mode.
-V, --version Prints version information
OPTIONS:
-n, --name <name>... contract name
--host is missing.
Screenshots
If applicable, add screenshots to help explain your problem. (The command and the output)
Additional context
Please post the following informations:
capsule --version
ckb-cli --version
RUST_BACKTRACE=1 RUST_LOG=capsule=trace
environment, then post the output as a file.They should not be built together. They don't share the same dependencies.
Chain simulator
Helper functions
Debugger
env: Capsule 0.10.1 25fd7d4
cargo install cross --git https://github.com/cross-rs/cross
cargo install ckb-capsule --git https://github.com/quake/capsule.git --branch quake/ckb-0.111
contranct :https://github.com/gpBlockchain/ckb-test-contracts/blob/main/rust/acceptance-contracts/contracts/spawn_demo/src/spawn_out_of_memory.rs#L45
test_code: https://github.com/gpBlockchain/ckb-test-contracts/blob/main/rust/acceptance-contracts/tests/src/test_contract_type.rs#L119-L122
step:
capsule test test_contract_type::test_spawn_out_of_memory
running 1 test
thread 'test_contract_type::test_spawn_out_of_memory' panicked at 'pass verification: Error { kind: Script, inner: TransactionScriptError { source: Inputs[0].Lock, cause: VM Internal Error: MemOutOfBound } }', src/test_contract_type.rs:295:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test test_contract_type::test_spawn_out_of_memory - should panic ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 47 filtered out; finished in 0.13s
not found debug log in the test
Describe the bug
There is no way to specify the test that should be run using capsule test
. This would be helpful to filter the tests that are executed. This is supported in Cargo with cargo test <testname>
.
Additional context
username@dev1:~$ capsule --version
Capsule 0.4.4
It would be beneficial to have commands to delete and rename contracts after creation.
Capsule Version: Capsule 0.4.2 dcfac5b
Trying to use the precompiled binary gives the following errors on some popular Linux distros:
OpenSSL3
./capsule: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
GLIBC
./capsule: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./capsule)
./capsule: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by ./capsule)
./capsule: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./capsule)
OpenSSL can probably be ignored since OpenSSL 1.1.1 will hit EOL this year. However, Glibc cannot easily be updated and is still being used in several popular distros. I did some research and found the following distros are affected:
MX Linux v21.3 (newest)
Debian 11 (newest)
Ubuntu 20.04 LTS (supported until 2025)
MX Linux is currently the most popular Linux distro according to DistroWatch. Debian 11 serves as a base for many other distros. Ubuntu 20.04 LTS is the previous LTS version with support until 2025.
Building against Glibc 2.31 should fix the issue with the OSs listed above. OpenSSL can probably be ignored since it's near EOL, or static linking could be considered.
ckb-capsule
leverage ckb-cli
and docker
to manage pks and build environment, but sometimes those tools block users' experience.
In #77 , the new version of ckb-cli brokes the capsule's feature. In the end, we need to release a new version to be compatible with the new version ckb-cli
. What if a user upgrades the capsule to the latest version but stays with an old version of ckb-cli? The capsule command is still broken!
Capsule requires docker
to build binaries. It is for the reproducible build. But when the docker image is x86, you cannot build it on a non-x86 device. To improve the developer's UX, we should support build without docker.
Due to the above reasons, I suggest the following feature/refactoring.
docker
.ckb-capsule-rust
, ckb-capsule-c
, and ckb-capsule-lua
.
ckb-cli
handle the signing and sending.Currently, there is no way to run cargo clippy
with contract code. I think for contract code some mistakes is very dangerous, such as:
Correctness
sectionRust contracts built by capsule build
(esp. in non-release build) may not get the correct argc and argv arguments because the compiler may insert function prologue before our assembly code in _start
and change the sp
register.
One possible solution is to mark the _start
function #[naked]
.
Or the _start
function can be written in pure assembly and linked with rust code.
(By the way the program_entry
function should use extern "C"
so that it has a defined calling convention.)
Describe the bug
There are no binaries for the release v0.8.0
Pros:
cross build -v
, cross clippy
etc (#35).capsule build
can be a thin wrapper of cross
.It mostly already works, I had to make one small change to cross:
Add this configuration (Cross.toml
) to a capsule project:
[build]
default-target = "riscv64imac-unknown-none-elf"
[target.riscv64imac-unknown-none-elf]
# Both image works
# image = "thewawar/ckb-capsule:2022-08-01"
image = "nervos/ckb-riscv-gnu-toolchain:focal-20230214"
Then I can cross +nightly build -p some_contract
Describe the bug
10 - 14 lines
use ckb_std::{
debug,
high_level::{load_script},
ckb_types::{bytes::Bytes, prelude::*},
};
30-32 lines
// let tx_hash = load_tx_hash()?;
// debug!("tx hash is {:?}", tx_hash);
const demo = fs.readFileSync('./my-demo/build/release/my-demo')
function bytesToHex(bytes) {
let res = "0x";
for (let i = 0; i < bytes.length; i++) {
res += bytes[i].toString(16).padStart(2, "0");
}
return res;
}
const data = bytesToHex(demo)
const contractScript = {
"capacity": '2630200000000',
"lock":{
"args":"0xe5f98b05a4aefc6984acea200402ea74b2a389a2",
"codeHash":"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
"hashType":"type"
},
"data": data
}
https://pudge.explorer.nervos.org/transaction/0x7ffd3902e758228373c15c37a8bc8fea6745c3e10fc9d24eadc1a13f28924f39
Ouput[0] is the deployed contract.
6. use contract
This is signed tx, I use the deployed contract on Ouput[1].type
https://wetransfer.com/downloads/5c40df6b6b659fa1e836b06b9c27706420220830093317/7e52431b24fe0927e0ce18278cce7aea20220830093331/00a6e0?utm_campaign=WT_email_tracking&utm_content=general&utm_medium=download_button&utm_source=notify_recipient_email
Screenshots
If applicable, add screenshots to help explain your problem. (The command and the output)
Error screenshot
Additional context
Please post the following informations:
capsule --version
: 0.8.0ckb-cli --version
: I deploy tx by Neuron. RUST_BACKTRACE=1 RUST_LOG=capsule=trace
environment, then post the output as a file.Describe the bug
The contracts/c/build/
directory is not included in .gitignore
.
Screenshots
username@dev1:~/project$ git add .
username@dev1:~/project$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .gitignore
new file: .gitmodules
new file: Cargo.lock
new file: Cargo.toml
new file: README.md
new file: build/.gitkeep
new file: capsule.toml
new file: contracts/.gitkeep
new file: contracts/c/Makefile
new file: contracts/c/build/blockchain.h
new file: contracts/c/build/blockchain.mol
new file: contracts/c/build/debug/sharedlib.so
new file: contracts/c/build/debug/sharedlib.so.debug
new file: contracts/c/deps/ckb-c-stdlib
new file: contracts/c/src/sharedlib.c
new file: contracts/project/Cargo.toml
new file: contracts/project/src/entry.rs
new file: contracts/project/src/error.rs
new file: contracts/project/src/main.rs
new file: deployment.toml
new file: migrations/.gitkeep
new file: tests/Cargo.toml
new file: tests/src/lib.rs
new file: tests/src/tests.rs
Additional context
Please post the following informations:
capsule --version
ckb-cli --version
username@dev1:~/project$ capsule --version
Capsule 0.4.1 303dfcb
username@dev1:~/project$ ckb-cli --version
ckb-cli 0.35.0 (3875086 2020-08-11)username@dev1:~/project$
We should run docker with --user uid:gid
instead of chown
after building.
Describe the bug
try to build on a recent rust nightly version via rust-toolchain.toml
:
capsule new my-demo
cd my-demo
cat <<EOT >> rust-toolchain.toml
[toolchain]
channel = "nightly-2022-05-01"
targets = [ "riscv64imac-unknown-none-elf" ]
EOT
capsule build
got this error:
Building contract my-demo
info: syncing channel updates for 'nightly-2022-05-01-x86_64-unknown-linux-gnu'
info: latest update on 2022-05-01, rust version 1.62.0-nightly (7c4b47696 2022-04-30)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std' for 'riscv64imac-unknown-none-elf'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std' for 'riscv64imac-unknown-none-elf'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
Compiling ckb-std v0.9.0
error[E0635]: unknown feature `llvm_asm`
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ckb-std-0.9.0/src/lib.rs:12:12
|
12 | #![feature(llvm_asm)]
| ^^^^^^^^
For more information about this error, try `rustc --explain E0635`.
error: could not compile `ckb-std` due to previous error
error: docker container exit with code Some(101)
it looks like the default docker image is not compatible with rust version 1.62.0-nightly
Additional context
capsule --version
Capsule 0.7.3 7f78a78
btw, it works with rust nightly-2022-01-15
info: latest update on 2022-01-15, rust version 1.60.0-nightly (ad46af247 2022-01-14)
Describe the bug
After installing capsule 0.4.4, using:
# check environment
capsule check
# create project
capsule new my-demo
cd my-demo
capsule build
capsule test
Screenshots
Additional context
Capsule 0.4.4 87bd895, it reports very long error, a snippets like this:
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr"
........
= note: collect2: fatal error: ld terminated with signal 9 [Killed]
compilation terminated.
I think it might be the problem of OOM of LLVM, like this:
https://stackoverflow.com/questions/46259776/collect2-fatal-error-ld-terminated-with-signal-9-killed
The same problem is encountered by using Rust in docker without capsule (using capsule's docker container).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.