Closed zqzqz closed 6 years ago
hey, @zqzqz. Could you attach your wasm binary you're deploying?
Sure. Without any change in step-4, the wasm file:
My script:
var Web3 = require("web3");
var fs = require("fs");
// Connect to our local node
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
// NOTE: if you run Kovan node there should be an address you've got in the "Option 2: Run Kovan node" step
web3.eth.defaultAccount = "0x004ec07d2329997267ec62b4166639513386f32e";
// read JSON ABI
var abi = JSON.parse(fs.readFileSync("./target/json/TokenInterface.json"));
// convert Wasm binary to hex format
var codeHex = '0x' + fs.readFileSync("./target/pwasm_tutorial_contract.wasm").toString('hex');
var TokenContract = new web3.eth.Contract(abi, { data: codeHex, from: web3.eth.defaultAccount });
var TokenDeployTransaction = TokenContract.deploy({data: codeHex, arguments: [10000000]});
// Will create TokenContract with `totalSupply` = 10000000 and print a result
web3.eth.personal.unlockAccount(web3.eth.defaultAccount, "user").then(() => TokenDeployTransaction.send({gasLimit: 5000000, from: web3.eth.defaultAccount})).then(contract => {
console.log("Address of new contract: " + contract.options.address);
TokenContract = contract;
}).then(() => {
TokenContract.methods.transfer("0x7BA4324585CB5597adC283024819254345CD7C62", 200).send({gasLimit: 5000000, from: web3.eth.defaultAccount});
}).then(() => {
return TokenContract.methods.balanceOf("0x7BA4324585CB5597adC283024819254345CD7C62").call();
}).then((res) => {
console.log("balance: ", res);
}).catch((err) => console.error(err));
output:
Address of new contract: 0xcF4e066AE93e86b079d4897B8595745515e0CD61
balance: 0
(keep running)
After I added a simple simple function addBalance, the wasm file
and abi
I forgot to ask about version of Parity you use, sorry
➜ ~ parity --version
Parity
version Parity/v1.11.6-beta-4ba600f-20180709/x86_64-linux-gnu/rustc1.27.0
Copyright 2015, 2016, 2017, 2018 Parity Technologies (UK) Ltd
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
By Wood/Paronyan/Kotewicz/Drwięga/Volf
Habermeier/Czaban/Greeff/Gotchac/Redmann
And web3 is installed using npm install
, 1.0.0-beta.33
I just tried to use the last parity master and it works.. Looks like there is a bug is in the released Parity/v1.11.6-beta-4ba600f-20180709 version. I've tried Parity/v1.11.7-stable though - doesn't work too.
Could I ask you to try to deploy it using the latest version from master branch (https://github.com/paritytech/parity-ethereum) to confirm that this problem is related to the released versions specifically?
You can run it like so:
cargo run --manifest-path=../parity/Cargo.toml -- --jsonrpc-apis all --chain wasm-dev-chain.json --unlock=0x004ec07d2329997267ec62b4166639513386f32e --password=passwd -l="own_tx=trace,txqueue=trace,wasm=trace,contract=trace,executive=trace,client=trace,external_tx=trace,miner=trace"
Parity-Ethereum/v2.1.0-unstable-7e6a571-20180720/x86_64-linux-gnu/rustc1.27.1 run the same script: Parity error
Thread 'main' panicked at 'Integer overflow when casting U256', /home/zqz/.cargo/registry/src/github.com-1ecc6299db9ec823/ethereum-types-0.3.2/src/uint.rs:32
after
2018-07-22 02:29:59 main DEBUG own_tx Imported to the pool (hash 0x1328c2663fb36a76ef570705100d22082da7d904b78c36db432d42ecccc0bd91)
2018-07-22 02:29:59 main DEBUG txqueue [0x1328c2663fb36a76ef570705100d22082da7d904b78c36db432d42ecccc0bd91] Added to the pool.
2018-07-22 02:29:59 main DEBUG txqueue [0x1328c2663fb36a76ef570705100d22082da7d904b78c36db432d42ecccc0bd91] Sender: 0x004e…f32e, nonce: 43, gasPrice: 0, gas: 5000000, value: 0, dataLen: 15831))
2018-07-22 02:29:59 main TRACE miner update_sealing
2018-07-22 02:29:59 main TRACE miner requires_reseal: sealing enabled
2018-07-22 02:29:59 main TRACE miner requires_reseal: should_disable_sealing=false; forced=false, has_local=true, internal=Some(true), had_requests=false
2018-07-22 02:29:59 main TRACE miner update_sealing: preparing a block
2018-07-22 02:29:59 main TRACE miner prepare_block: No existing work - making new block
detailed traces
stack backtrace:
0: 0x56215a12d535 - backtrace::backtrace::libunwind::trace::h3b3b297fefc06662
at /home/zqz/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.5/src/backtrace/libunwind.rs:53
- backtrace::backtrace::trace::h436ee6f86d3cbd31
at /home/zqz/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.5/src/backtrace/mod.rs:42
1: 0x56215a12818e - backtrace::capture::Backtrace::new_unresolved::hfac3939059935835
at /home/zqz/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.5/src/capture.rs:88
2: 0x56215a1280cd - backtrace::capture::Backtrace::new::ha0ff212192fddb1c
at /home/zqz/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.5/src/capture.rs:63
3: 0x56215a1255c6 - panic_hook::panic_hook::hde7ce6475046d0e8
at util/panic_hook/src/lib.rs:62
4: 0x56215a126296 - panic_hook::set_with::{{closure}}::h7941dfaebbaa17e2
at util/panic_hook/src/lib.rs:35
5: 0x56215a2b9315 - std::panicking::rust_panic_with_hook::h55e258944e31bc6d
at libstd/panicking.rs:467
6: 0x562158f429cf - std::panicking::begin_panic::ha6acd288cf284c86
at /checkout/src/libstd/panicking.rs:397
7: 0x5621586d33c4 - ethereum_types::uint::U256::as_u64::h1ae20f467d7856b3
at /home/zqz/Documents/parity-ethereum/<panic macros>:3
8: 0x5621583fd0d1 - ethcore::miner::miner::Miner::prepare_block::hdceb3f2b91824538
at ethcore/src/miner/miner.rs:418
9: 0x562158404cc1 - <ethcore::miner::miner::Miner as ethcore::miner::MinerService>::update_sealing::hb1f39dab6dd86daa
at ethcore/src/miner/miner.rs:1084
10: 0x562158402e37 - ethcore::miner::miner::Miner::prepare_and_update_sealing::h4567baabc0a6ab06
at ethcore/src/miner/miner.rs:789
11: 0x5621584038ff - <ethcore::miner::miner::Miner as ethcore::miner::MinerService>::import_own_transaction::h78fcbdbd5f2c70ac
at ethcore/src/miner/miner.rs:889
12: 0x562156f67f39 - parity_ethereum::run::execute_impl::he940f83886a4bc2c
at /home/zqz/Documents/parity-ethereum/parity/run.rs:601
13: 0x562156f7070e - parity_ethereum::run::execute::h9d71e0c829be8089
at /home/zqz/Documents/parity-ethereum/parity/run.rs:908
14: 0x562156e2a9f3 - parity_ethereum::execute::ha6eba11fa0a28c5a
at /home/zqz/Documents/parity-ethereum/parity/lib.rs:199
15: 0x562156e27f71 - parity_ethereum::start::h8c33703d43b75718
at /home/zqz/Documents/parity-ethereum/parity/lib.rs:236
16: 0x562156ce25da - parity::main_direct::hc1a4c32b0aa4391e
at parity/main.rs:245
17: 0x562156ce5675 - parity::main::h5acc7ae5625eb7d0
at parity/main.rs:410
18: 0x562156e6ad5f - std::rt::lang_start::{{closure}}::h866c04b1c58f3d63
at /checkout/src/libstd/rt.rs:74
19: 0x56215a2b8da2 - std::rt::lang_start_internal::{{closure}}::h72602870b4a34363
at libstd/rt.rs:59
- std::panicking::try::do_call::hc2917ab2c572e22d
at libstd/panicking.rs:310
20: 0x56215a2e45f9 - __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:105
21: 0x56215a2c61e5 - std::panicking::try::h3777f1f99a655493
at libstd/panicking.rs:289
- std::panic::catch_unwind::hab6d1467193fc938
at libstd/panic.rs:374
- std::rt::lang_start_internal::h106bcdfb2e3beaf8
at libstd/rt.rs:58
22: 0x562156e6ad37 - std::rt::lang_start::h9bc5d929641ee29c
at /checkout/src/libstd/rt.rs:74
23: 0x562156ce58bc - main
24: 0x7fdda097882f - __libc_start_main
25: 0x562156caee78 - _start
26: 0x0 - <unknown>
that's weird. Have you tried master (run using cargo run)?
git clone git@github.com:paritytech/parity-ethereum.git && cd parity-ethereum
in directory parity-ethereum
cargo run --manifest-path=./Cargo.toml --jsonrpc-apis all --chain wasm-dev-chain.json -l="own_tx=trace,txqueue=trace,wasm=trace,contract=trace,executive=trace,client=trace,external_tx=trace,miner=trace"
I deleted the 'unlock' option. (password 'user' cannot unlock the account 0x004ec...) Does that matter?
2018-07-22 02:41:10 main INFO parity_ethereum::run Operating mode: active
user Unable to read password file. Ensure it exists and permissions are correct.
I deleted the 'unlock' option. (password 'user' cannot unlock the account 0x004ec...) It that matters?
It does. Check that you have a --password=passwd
and the passwd file contains just
user
Yes tutorial code works well on latest parity. Note that transfer method still cannot increase tokens of recipient. But my custom method can change the storage successfully. I suppose that is a minor logic error in step-4 example: we should distribute the defaultAccount some token before calling transfer. Thank you @fckt
Right, that was a mistake in the tutorial itself. Contract code from step-4 is not quite functional. Fixed it https://github.com/paritytech/pwasm-tutorial/commit/6f20567f097ea1f285ce44acc8d73142db474297
Thanks for a feedback, @zqzqz
environment
I exactly followed tutorial in step-4 to deploy and run the sample token contract. Using Parity development chain. I set both gasLimit in pwasm-dev-chain and transaction to really high (>> 5000000).
steps
expected result
actual result
Deploy works fine, it returns address. Though eth.estimateGas always throw rejection "transaction execution error"
Transfer transaction is sent and mined
The script
triggers neither promise resolve nor reject (no console.log executed). The thread just keep running. Balance doesn't increase. Return 0.
what I try
In the logic of token contract, it doesn't distribute any tokens to the owner (web.eth.defaultAccount). So is that means transfer transaction should be reverted? I am not sure about that so I added another simple function and called it. Some result.
I set gas and gasLimit to very high. Same result.
I tried both web3 1.0.0.Beta34 and web3 0.20.6. Same result.