GithubHelp home page GithubHelp logo

zilliqa / kaya Goto Github PK

View Code? Open in Web Editor NEW
39.0 11.0 13.0 19.75 MB

RPC Server for Zilliqa

Home Page: https://www.zilliqa.com

License: GNU General Public License v3.0

JavaScript 100.00%
zilliqa scilla testrpc

kaya's Introduction

Zilliqa

Overview

Zilliqa is a scalable smart contract platform that aims to tackle the congestion issue plaguing the blockchain industry. Zilliqa utilises a unique sharded architecture to achieve parallel processing of transactions while maintaining a large number of public nodes. Hence, Zilliqa is a blockchain capable of reaching high throughput and processing more complex computations while remaining decentralised and secure.

NOTE: The master branch is not for production as development is currently being worked constantly, please use the tag releases if you wish to work on the version of Zilliqa client that is running live on the Zilliqa blockchain.

Zilliqa Mainnet

The current live version on the Zilliqa Mainnet is Zilliqa v9.2.3 and Scilla v0.13.3.

URL(s)
API URL https://api.zilliqa.com/
Block Explorer Viewblock
DEVEX

Developer Testnet

The current live version on the Developer Testnet is Zilliqa v9.2.5 and Scilla v0.13.3.

URL(s)
API URL https://dev-api.zilliqa.com/
Block Explorer Viewblock
DEVEX
Faucet Link

Zilliqa Improvement Proposal (ZIP)

The Zilliqa Improvement Proposals (ZIPs) are the core protocol standards for the Zilliqa platform.To view or contribute to ZIP, please visit https://github.com/Zilliqa/zip

Available Features

The current release has the following features implemented:

In the coming months, we plan to have the following features:

  • Further unit and integration tests
  • Enhancement of existing features
  • More operating system support
  • And much more...

Minimum System Requirements

To run Zilliqa, we recommend the minimum system requirements specified in our Mining page.

Build from Source Code

Starting with Zilliqa v8.6.0, the officially supported operating system is Ubuntu 22.04.

If you'd like to experiment with a different distro (including the previously supported Ubuntu 18.04), please make sure to install gcc >= 11.

Run the following to install the build dependencies:

sudo apt-get update
sudo apt-get install autoconf \
    build-essential \
    ccache \
    clang-format \
    clang-tidy \
    git \
    lcov \
    libcurl4-openssl-dev \
    libssl-dev \
    libtool \
    libxml2-utils \
    ninja-build \
    ocl-icd-opencl-dev \
    pkg-config \
    python3-dev \
    python3-pip \
    libgmp-dev \
    bison \
    gawk
git submodule update --init --recursive

Run the following to install latest version of cmake. CMake version >= 3.19 must be used:

wget https://github.com/Kitware/CMake/releases/download/v3.19.3/cmake-3.19.3-Linux-x86_64.sh
mkdir -p "${HOME}"/.local
bash ./cmake-3.19.3-Linux-x86_64.sh --skip-license --prefix="${HOME}"/.local/
export PATH=$HOME/.local/bin:$PATH
cmake --version
rm cmake-3.19.3-Linux-x86_64.sh

To install, clone vcpkg to a separate location (do not use brew on macos):

$ git clone https://github.com/Microsoft/vcpkg.git /path/to/vcpkg
$ cd /path/to/vcpkg && git checkout 2022.09.27 && ./bootstrap-vcpkg.sh
$ cd /path/to/zilliqa
$ export VCPKG_ROOT=/path/to/vcpkg

As part of building our source code, we patch websocketpp 0.8.2 to compile on C++20; please see the license: https://github.com/zaphoyd/websocketpp/blob/master/COPYING.

Build Zilliqa from the source:

# build Zilliqa binary
$ ./build.sh

If you want to contribute by submitting code changes in a pull request perform the build with clang-format and clang-tidy enabled by doing:

$ ./build.sh style

Build Scilla for Smart Contract Execution

The Zilliqa client works together with Scilla for executing smart contracts. Please refer to the Scilla repository for build and installation instructions.

Boot Up a Local Testnet for Development

  1. Run the local testnet script in build directory:

    $ cd build && ./tests/Node/pre_run.sh && ./tests/Node/test_node_lookup.sh && ./tests/Node/test_node_simple.sh
  2. Logs of each node can be found at ./local_run

  3. To terminate Zilliqa:

    $ pkill zilliqa

Start a local network development environment

This is similar to the above, but deploys a local testnet to a local minikube cluster.

You can find documentation on how to do this on your local machine in docs/localdev.md.

You can find scripts which will set up an Ubuntu 22.04 machine in the cloud (or install necessary dependencies on your machine) in docs/setup/README.md.

Further Enquiries

Link(s)
Development discussion (discord)
Bug report
Security contact security 🌐 zilliqa.com
Security bug bounty HackerOne bug bounty

kaya's People

Contributors

amritkumar avatar bb111189 avatar blockchain-trainer avatar bogdan avatar dependabot[bot] avatar edison0xyz avatar exarus avatar kenchangh avatar mickys avatar mvlabat avatar vkomenda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kaya's Issues

Contracts correctness test

To test the kaya on a few example contracts to ensure correctness:

  • HelloWorld
  • Crowdfunding
  • FungibleToken
  • Bookstore
  • Zil-game

Wrong contract address computation

This issue is composed of two parts, as follows:

1. Use hex encoding

In

kaya/logic.js

Line 47 in fe84564

const computeContractAddr = (sender) => {
, hex is not passed to the update method. This will result in the wrong hash.

2. Update user nonce after computing address

This is related to Zilliqa/Zilliqa#675. In the core protocol implementation, we now use the current nonce, not the TX nonce. So,

kaya/logic.js

Line 158 in fe84564

walletCtrl.increaseNonce(senderAddress);
should be shifted down, somewhere after computeContractAddr is called.

-p port option does not change port

The -p command line option to change the port does not seem to have any effect.

E.g., starting Kaya like so: kaya-cli -p 4123

Will still result in the Kaya server using port the default port 4200.

ZILLIQA KAYA RPC SERVER (ver: 0.2.6)
Server listening on 127.0.0.1:4200
Running from local interpreter

Kaya-cli creating relative path ../data

When running kaya-cli, the app seems to create a new directory relative to the path the app was started: ../data

The directory is not removed after the app closes, so it should be relatively easy to confirm the issue.

The reason this is a problem is 1) it creates a directory in a place you, as a user, probably don't want a random directory to be created, and 2) depending from which directory you open kaya-cli, the app could fail to launch.

$ cd /Users/ronalddanger
$ kaya-cli
ZILLIQA KAYA RPC SERVER (ver: 0.2.6)
Server listening on 127.0.0.1:4200
Running from local interpreter
================================================================================
fs.js:119
    throw err;
    ^

Error: EACCES: permission denied, mkdir ‘../data/‘
    at Object.mkdirSync (fs.js:773:3)
    at Object.prepareDirectories (/usr/local/lib/node_modules/kaya-cli/src/utilities.js:177:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/kaya-cli/src/app.js:90:7)
    at Module._compile (internal/modules/cjs/loader.js:738:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)
    at Module.require (internal/modules/cjs/loader.js:667:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/kaya-cli/src/server.js:26:13)
    at Module._compile (internal/modules/cjs/loader.js:738:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
    at internal/main/run_main_module.js:21:11

Incorrect log when createTransaction for calling transition

When Kaya is running in terminal, if I use Zilliqa Javascript Library to implement createTransaction, calling transition method in the contract ( NOT deploying new contract, code parameter is omitted). The TX is invoked successfully however on Kaya terimal window, it says

Contract Address Deployed: 17843f270b8fc8717e684e76b1d44cfd52421b59

Should it be changed to Contract called: with incoming message?

Error after install kaya-cli as npm package

Hello,

I'm using Node v11.10.1 installed by nvm. I have installed kaya-cli npm install -g kaya-cli.

When I run kaya-cli from terminal, I got the error.

kaya-cli
internal/modules/cjs/loader.js:615
    throw err;
    ^

Error: Cannot find module 'tslib'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:613:15)
    at Function.Module._load (internal/modules/cjs/loader.js:539:25)
    at Module.require (internal/modules/cjs/loader.js:667:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/developers/.nvm/versions/node/v11.10.1/lib/node_modules/kaya-cli/node_modules/@zilliqa-js/util/dist/index.js:3:15)
    at Module._compile (internal/modules/cjs/loader.js:738:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)

Can someone help me with this issue?

NOTE:

@edisonljh I think I found the issue, you need to add tslib as dev dependency to the package.json. I tried and it works

I can start the server by kaya-cli

 kaya-cli
ZILLIQA KAYA RPC SERVER (ver: 0.2.6)
Server listening on 127.0.0.1:4200
Running from local interpreter
================================================================================
Available Accounts
================================================================================
(1) f949cd77cd1ad980492ba3f7afc208c969dede62    (1000000 ZILs)  (Nonce: 0)
(2) 1ab8b643ec6f62ee9dfcc8b2e222f809a5a7258a    (1000000 ZILs)  (Nonce: 0)
(3) d165816d56a9b6cb4552db468cb3121440967953    (1000000 ZILs)  (Nonce: 0)
(4) 5aaa209d65a527170d018902d420daf13cd7ea08    (1000000 ZILs)  (Nonce: 0)
(5) 7eb6c1d20542b1452f47323112fe72838d0070a9    (1000000 ZILs)  (Nonce: 0)
(6) 5dd43414d6aa2d1370598a0ede5775b211fb2023    (1000000 ZILs)  (Nonce: 0)
(7) 541cd8739bb6948ff9116fbbeeaf46d992121e71    (1000000 ZILs)  (Nonce: 0)
(8) a78ca865d1bbaf2af472d990f004369ea150d9e9    (1000000 ZILs)  (Nonce: 0)
(9) 96755f2f9fc8499319fe68a5d07eb746a70baed9    (1000000 ZILs)  (Nonce: 0)
(10) 5c4068f17d0dd6304c2cf5b3d68db769021352ae   (1000000 ZILs)  (Nonce: 0)

 Private Keys
================================================================================
(1) 7bf8089b7a524e3f4ef507249d8d0de3447920a13db96d1e55098eaef132497a
(2) d43ad75a3f9d4482a7a6c752d4f013aecead26772aac6ebe47904a9479adaf29
(3) eb63c6f310b7da3f2cfbc701da0db24d95c40b966abc84838e039af4d08cf65f
(4) 33d5b71040f2da508b74dfa43046d8a3d89d94c3186e23e7ad4aea8123e6a2ef
(5) fb2b984bef959ae7cc451a190a26c49ce7e06203faf64302d73cd931c3f434a6
(6) cc0ffb6ce56f46ccd60e5fb7630e17017bd8552886d1e3c60dff31857f931c77
(7) 28f7d7ea73c8d3d8629755ee05e2d5b17aa8b11951cc880bca3986ed53037f31
(8) ff76411c725d5f8dfe7595b9b48de039bb21bda2367b731fc87bf6dd11bdbcbb
(9) dbfbd90973003a62fde579564b81fe62f58d1a3f7b4ebde1bb3b43ed8fbc680e
(10) 05acfdc0259303d35f8f61f55b181ad4cdcd2b547a277f116ac637d8f35ad8f1
================================================================================

Build Docker Image for Kaya RPC

Requirements:

  • Be able to support local Scilla development. This means that you need to compile the Scilla binaries within the docker files. You can refer to a reference implementation here
  • Flag to toggle between local and remote mode
  • Ability to specify the port for docker
  • Able to toggle between verbose mode and normal mode. As well as fixtures. You need to be able to pass options to the Kaya RPC. (this might require some changes on the main Kaya RPC codebase)

Reference:

NPM Installation error with incompatible python vresions

Installation error reported:

> [email protected] preinstall /Users/<user>/Desktop/testing_folder/kaya/node_modules/scrypt
> node node-scrypt-preinstall.js
> [email protected] install /Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents
> node install
node-pre-gyp WARN Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.4/fse-v1.2.4-node-v67-darwin-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v67 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /Users/<user>/.pyenv/shims/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack     at ChildProcess.emit (events.js:188:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:978:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:395:11)
gyp ERR! stack     at Socket.emit (events.js:188:13)
gyp ERR! stack     at Pipe._handle.close (net.js:610:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/Cellar/node/11.6.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" "--module_name=fse" "--module_path=/Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents
gyp ERR! node -v v11.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/11.6.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:188:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:978:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
node-pre-gyp ERR! System Darwin 18.2.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/11.6.0/bin/node" "/Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents
node-pre-gyp ERR! node -v v11.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/Cellar/node/11.6.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/Users/<user>/Desktop/testing_folder/kaya/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
> [email protected] install /Users/<user>/Desktop/testing_folder/kaya/node_modules/scrypt
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /Users/<user>/.pyenv/shims/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack     at ChildProcess.emit (events.js:188:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:978:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:395:11)
gyp ERR! stack     at Socket.emit (events.js:188:13)
gyp ERR! stack     at Pipe._handle.close (net.js:610:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/Cellar/node/11.6.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/<user>/Desktop/testing_folder/kaya/node_modules/scrypt
gyp ERR! node -v v11.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/<user>/.npm/_logs/2019-02-16T21_03_31_296Z-debug.log

Unable to replicate on my machine. Will appreciate if anyone can find a workaround if you face the same issue.

Invalid Tx Json from example

I'm attempting to use the starter provided here and I keep getting invalid tx json. The error responses have not helped me troubleshoot the error on the kaya side:

[LOGIC] : Processing transaction...
Error: Msg is not well-formed
Possible fix: Did you specify the correct chain Id and msg version?
[LOGIC] : Payload well-formed? false
Error: Msg is not well-formed
Possible fix: Did you specify the correct chain Id and msg version?
[App.js] : Sending response back to client
[App.js] : Method specified GetBalance
[App.js] : Getting balance for 7bb3b0e8a59f3f61d9bff038f4aeb42cae2ecce8
[Wallet] : Getting balance for 7bb3b0e8a59f3f61d9bff038f4aeb42cae2ecce8
[App.js] : Sending response back to client
[App.js] : Method specified GetMinimumGasPrice
[App.js] : Sending response back to client
[App.js] : Method specified GetBalance
[App.js] : Getting balance for 7bb3b0e8a59f3f61d9bff038f4aeb42cae2ecce8
[Wallet] : Getting balance for 7bb3b0e8a59f3f61d9bff038f4aeb42cae2ecce8
[App.js] : Sending response back to client
[App.js] : Method specified CreateTransaction

I'm running with fixtures, and the only change I made to QuickStart.ts from the linked repo was adding a destination address that was provided by the fixtures file (QuickStart.ts/line40):

    const tx = await zilliqa.blockchain.createTransaction(
      zilliqa.transactions.new({
        version: VERSION,
        toAddr: "381f4008505e940ad7681ec3468a719060caf796",
        amount: new BN(units.toQa("888", units.Units.Zil)), // Sending an amount in Zil (888) and converting the amount to Qa
        gasPrice: myGasPrice, // Minimum gasPrice veries. Check the `GetMinimumGasPrice` on the blockchain
        gasLimit: Long.fromNumber(1)
      })
    );

➜ zilliqajs-starter git:(master) ✗ ts-node src/QuickStart.ts
Your account address is:
0x7bb3b0e8a59f3f61d9bff038f4aeb42cae2ecce8
Your account balance is:
{ balance: '1000000000000000000', nonce: 0 }
Current Minimum Gas Price: 1000000000
My Gas Price 1000000000
Sufficient Gas Price?
true
{ message: 'Invalid Tx Json' }

As a result I am not able to progress with development. Is there something I am missing? None of the examples I've seen have provided any clues. Can you confirm that this will provide a valid Kaya RPC version:

const CHAIN_ID = 2;
const MSG_VERSION = 1;
const VERSION = bytes.pack(CHAIN_ID, MSG_VERSION);

Automated Testing

As long as it is automated, its good! Help appreciated.

P.S: I already have a list of postman templates to test the APIs internally.

Sync with the interpreter API

Testrpc relies on local scilla interpreter. Developers will have to compile it themselves, and some people might run into problems. This testrpc should ideally work "out-of-the-box".

Developers should be able to choose if they want to build their own scilla-runner from the Scilla source code, or to use the API that we already have.

GetBalance account has to be "lowercase"

We should be able to pass addresses in any uppercase / lowercase / checksummed format.
Currently it only accepts lowercase addresses.

Available Accounts
=============================
(0) 17f343a7a13bac8026d6c84e2ee2925aeba1fa61 (Amt: 100000) (Nonce: 0)

call:

{ jsonrpc: '2.0', method: 'GetBalance', params: [ '17F343A7A13BAC8026D6C84E2EE2925AEBA1FA61' ],  id: 1 }

result:

{ id: 1, jsonrpc: '2.0', result: { balance: 0, nonce: 0 } }

EXPECTED result:

{ id: 1, jsonrpc: '2.0', result: { balance: 100000, nonce: 0 } }

Issue with Kaya-cli and ../data

I've been having several problems with Kaya on windows so now I'm using NVM and virtualbox in an attempt to bypass the issues. However, it seems that npm install -g kaya-cli will result in some problems regarding permissions in its relative path. Full output of my error:

~ kaya-cli -f
ZILLIQA KAYA RPC SERVER (ver: 0.2.9)
Server listening on 127.0.0.1:4200
Running from remote interpreter
https://scilla-runner.zilliqa.com/contract/call
================================================================================
fs.js:114
throw err;
^

Error: EACCES: permission denied, mkdir '../data/'
at Object.mkdirSync (fs.js:757:3)
at Object.prepareDirectories (/home/cameron/.nvm/versions/node/v10.16.0/lib/node_modules/kaya-cli/src/utilities.js:177:10)
at Object. (/home/cameron/.nvm/versions/node/v10.16.0/lib/node_modules/kaya-cli/src/app.js:89:7)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/home/cameron/.nvm/versions/node/v10.16.0/lib/node_modules/kaya-cli/src/server.js:38:13)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

There is an open issue that may fix this by removing relative paths: #78 , but it may have gone stale. If we were to move to a database, what would it be? a sqlite DB stored in $HOME/.kaya ? If I have time in a couple weeks I may attempt a fix and submit pull request.

Error handling when scilla-runner does not run to completion

When user sends an erroneous code to the kaya rpc server, the error is not handled properly. The server should still return a transaction hash like the actual zilliqa blockchain's response. But the error will be displayed on the console screen when run debug is activated.

Multi- Contract Calls

Contracts that calls another contracts are not supported now. TestRPC only supports returns to the sender.

To do this functionality, a revert mechanism is required to stop contracts with insufficient gas.

Use CORS to allow Access-Control-Allow-Origin

// server.js
...
const cors = require('cors')
...
// cross region settings with Env
if (process.env.NODE_ENV === 'dev') {
  app.use(cors())
}

Required dependencies as follows:

// package.json

"scripts": {
   ...
    "dev": "cross-env NODE_ENV=dev node server.js"
  },
"devDependencies": {
    ...
    "cross-env": "^5.2.0",
    ...
  },

"dependencies": {
    ...
    "cors": "^2.8.4",
    ...
  }

That we can use npm run dev to start the dev mode and use CORS

Using tabs in scilla code make error

Problem

When use tab and Kaya and zilliqa-js, deploy will fail.
Interpreter says:

{ id: 1,
  jsonrpc: '2.0',
  result:
   { Error:
      'Interpreter error: Syntax error in file tmp/967c182975d2046a7f5bcbae87b625761e7757a3_code.scilla: line 1, position 71.: Unexpected character: \\\n' } }

Content of tmp/967c182975d2046a7f5bcbae87b625761e7757a3_code.scilla is here:

import BoolUtils  library Room  let zero = Uint128 0  let one_msg =  \tfun ( ...

position 71 is '\t'.

How to resolve

I replace tab to 4 spaces.

Unexpected behaviour with command line parser

Command line parser (Yargs) exhibits unpredictable behaviour.

E.g. sometimes --help works, sometimes it doesn't. Same goes for -? and --version. But the option flags seem to work fine.

Run SCILLA-CHECKER within Kaya RPC

Kaya RPC should check the contract before running the interpreter.

If scilla-checker fails, the KayaRPC should through the ScillaInterpreterError and the correct gas should be deducted from the account.

automated testing

Testing is done manually using my testapp, essentially just a JS file that fires calls. I check the output manually. Automated testing needs to be done.

Wallet component "addFunds" types issue

When using the zilliqa-js library, the transaction sends the amount / gasLimit / gasPrice as a BN string.

This ends up causing issues with the current Balance for an account as well as gas calculations.

currentBalance += amount; => will concatenate strings, instead of adding the values.

example:

currentBalance += amount;

Example call:

{ version: 0,  nonce: 1,  to: '22537dfddb1232be8ce10c7fc4b784f61a4375a9',
  amount: <BN: 1>, gasPrice: 10, gasLimit: 10, code: null, data: null,  pubKey: null }

Debug output:

[App.js]	 : Method specified GetBalance
[App.js]	 : Getting balance for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Wallet]	 : Getting balance for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[App.js]	 : Sending response back to client
[App.js]	 : Method specified CreateTransaction
[Logic.js]	 : Processing transaction...
[Logic.js]	 : Payload well-formed? true
[Logic.js]	 : Sender: 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Wallet]	 : Getting balance for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Logic.js]	 : User Nonce: 0
[Logic.js]	 : Payload Nonce: 1
[Logic.js]	 : p2p token tranfer
[Wallet]	 : Deducting 110 from 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Wallet]	 : Getting balance for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Wallet]	 : Checking if 17f343a7a13bac8026d6c84e2ee2925aeba1fa61 has 110
[Wallet]	 : Sufficient Funds.
[Wallet]	 : Sender's previous Balance: 100000
[Wallet]	 : Deduct funds complete. Sender's new balance: 99890
[Wallet]	 : Increasing nonce for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Wallet]	 : New nonce for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61 : 1
[Wallet]	 : Adding 1 to 22537dfddb1232be8ce10c7fc4b784f61a4375a9
[Wallet]	 : Recipient's previous Balance: 100000
[Wallet]	 : Adding funds complete. Recipient's new Balance: 1000001

=>> 100000 +1 != 1000001

[Logic.js]	 : Transaction will be logged as 766d9fb349d049d531a9b9825d1b74e37d1bdb988c75ac460c8bb6cf24a336fe
[App.js]	 : Sending response back to client
[App.js]	 : Method specified GetBalance
[App.js]	 : Getting balance for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Wallet]	 : Getting balance for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[App.js]	 : Sending response back to client
[App.js]	 : Method specified CreateTransaction
[Logic.js]	 : Processing transaction...
[Logic.js]	 : Payload well-formed? true
[Logic.js]	 : Sender: 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Wallet]	 : Getting balance for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Logic.js]	 : User Nonce: 1
[Logic.js]	 : Payload Nonce: 2
[Logic.js]	 : p2p token tranfer
[Wallet]	 : Deducting 110 from 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Wallet]	 : Getting balance for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Wallet]	 : Checking if 17f343a7a13bac8026d6c84e2ee2925aeba1fa61 has 110
[Wallet]	 : Sufficient Funds.
[Wallet]	 : Sender's previous Balance: 99890
[Wallet]	 : Deduct funds complete. Sender's new balance: 99780
[Wallet]	 : Increasing nonce for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61
[Wallet]	 : New nonce for 17f343a7a13bac8026d6c84e2ee2925aeba1fa61 : 2
[Wallet]	 : Adding 1 to 22537dfddb1232be8ce10c7fc4b784f61a4375a9
[Wallet]	 : Recipient's previous Balance: 1000001
[Wallet]	 : Adding funds complete. Recipient's new Balance: 10000011

=>> 1000001 +1 != 10000011

[Logic.js]	 : Transaction will be logged as 88c533a5d5d803a45a8dfb0deaee9a05919eb4d14b4df3117ec6dde68312fef2
[App.js]	 : Sending response back to client

Since we're using BN, the whole implementation should most likely parse the payload.amount into a BN instance and use add / sub / div methods.

Program Robustness

  • rimraf used in shutdown of server.js is not stable.
  • Robustness for fs checks.
  • Check for JSON well-formness

Improve test coverage of kayaRPC

More testing vectors have to be introduced.

Test coverage for the CreateTransaction has been limited so far. Help needed to have more test cases to ensure correctness of CreateTransaction with smart contract. Payments testing has already been done under tests/transaction.test.js, but more vectors are welcome.

Currently only 50.87% of the lines have been covered under test case. Will be good if we can have 80% coverage since smart contract transaction is a significant portion of the code.

------------------------|----------|----------|----------|----------|-------------------|
File                    |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
------------------------|----------|----------|----------|----------|-------------------|
All files               |    50.77 |    43.59 |       56 |    50.87 |                   |
 kaya                   |    52.59 |    48.36 |    53.33 |    52.77 |                   |
  app.js                |    70.07 |    64.71 |    83.33 |    69.85 |... 14,215,220,221 |
  config.js             |      100 |      100 |      100 |      100 |                   |
  jest.config.js        |        0 |      100 |      100 |        0 |             18,38 |
  logic.js              |    49.76 |    44.05 |    64.71 |       50 |... 99,400,401,404 |
  server.js             |        0 |        0 |        0 |        0 |... 41,42,43,44,46 |
  utilities.js          |     5.56 |      100 |        0 |     5.56 |... 49,50,54,55,58 |
 kaya/components        |    83.33 |      100 |       50 |    83.33 |                   |
  blockchain.js         |    83.33 |      100 |       50 |    83.33 |                23 |
 kaya/components/scilla |    15.38 |        0 |        0 |    15.38 |                   |
  scilla.js             |    15.38 |        0 |        0 |    15.38 |... 08,209,212,214 |
 kaya/components/wallet |    74.49 |    60.47 |    84.62 |    74.49 |                   |
  wallet.js             |    74.49 |    60.47 |    84.62 |    74.49 |... 66,191,194,204 |
------------------------|----------|----------|----------|----------|-------------------|
Test Suites: 2 passed, 2 total
Tests:       19 passed, 19 total
Snapshots:   0 total
Time:        5.116s
Ran all test suites.

CreateTransaction is not writing the correct state

Repeated calls might yield incorrect contract state. It's likely to be due to some logic gap and improper error checking. Have to align code with interpreter's behavior.

Developers building testapp on kaya should be aware of this issue. Will fix it soon since its urgent.

Does not correctly handle insufficient gas limit

Known bug in the Kaya RPC. If there's insufficient gasLimit in your transaction, Kaya RPC will not run correctly.

Waiting for a more structured error message from scilla interpreter to be developed before rectifying this issue. Zilliqa/scilla#214

For now, make sure you have enough gas limit in your transactions (e.g. assign 2000 as a gas limit. The unused gas will be refunded anyway).

is remote interpreter down ?

hi i want to test kaya rpc deploy contract, im user windows, so im used remote interpreter scilla, but its always throwing an error,
this my log

[Logic.js] : Processing transaction...
[Logic.js] : Payload well-formed? true
[Logic.js] : Sender: b9998710c6c5b7ad49bda5080031412c5a3f20d3
[Wallet] : Getting balance for b9998710c6c5b7ad49bda5080031412c5a3f20d3
[Logic.js] : User Nonce: 0
[Logic.js] : Payload Nonce: 1
[Logic.js] : Task: Contract Deployment / Create Transaction
[Wallet] : Getting balance for b9998710c6c5b7ad49bda5080031412c5a3f20d3
[Wallet] : Checking if b9998710c6c5b7ad49bda5080031412c5a3f20d3 has 25002000200000000
[Wallet] : Funds sufficient true
[Logic.js] : Running scilla interpreter now
[Wallet] : Increasing nonce for b9998710c6c5b7ad49bda5080031412c5a3f20d3
[Wallet] : New nonce for b9998710c6c5b7ad49bda5080031412c5a3f20d3 : 1
[Scilla] : blockchain.json file prepared for blocknumber: 68
[Scilla] : Code Deployment
[Scilla] : Running Remote Interpreter
throwing interpreter error

can i get explained about this ?

Expose Kaya as a Library

From @bobio2018

To clarify the issue isn't we want to use node or kaya-cli to spin up kaya in terminal, it is
whether we spin out kaya inside our node code, it feels like it is running but not printing any result compare to run kaya server.js in terminal directly. kaya-cli has the same issue, when I call kaya-cli server.js inside a node app it is not printing any result.

I have setup a test app here you can download and play to replicate the issue, instruction is in readme.me ( we just use node command for simplicity, in muer project it is muer develop )
https://github.com/bobio2018/testkayacli

Currently we have to have entire kaya inside muer folder, and reference it as library, however when we reference it, it starts straightaway.

Ideally, kaya npm package should be a library we can reference in code and set init parameters to start kaya in the current terminal window. for example we can use kaya or kaya-cli npm like this

const kaya = require('kaya-cli') ;

var DevelopMode = {
  run:  async function(options) {
      kaya.start({fixtures:'test/account-fixtures.json',remote=false}).then(
        function(data){
          // this should start kaya server and output 10xaccounts on the screen
       }
     );
  },

}

module.exports = DevelopMode

CreateTransaction: should return an error message if TX nonce is lower than account nonce

CreateTransaction: should return an error message if TX nonce is lower than account nonce

Fix: return Error Object instead of just the message.

Details:

Call

getNonce( 0x17f343a7A13BaC8026D6C84e2Ee2925aEba1FA61 ) {
  balance: 88130, nonce: 17 
}

{ jsonrpc: '2.0',
  method: 'CreateTransaction',
  params:
   [ { version: 0,
       nonce: 1,
       to: '22537dfddb1232be8ce10c7fc4b784f61a4375a9',
       amount: <BN: 1>,
       pubKey: '03b51541a4e231517740ec9bc5dda5647bc5ef560f849f95a4f7d9eaa118fba131',
       gasPrice: 10,
       gasLimit: 10,
       code: '',
       data: '',
       signature: '9acfcb4a0aac7911559038c576cdbc0256a8ffe355c10d9922069ca3c7513806dfa32f01e00ed12bbf0012ec26e684c1015a71fc9352d9513f4b81d4179df8d6' } ],
  id: 31 }

EXPECTED:

new Error( "the tx doesn't have the correct nonce" );

Actual

{
status: 200,
statusText: 'OK',
config: {
     data: '{"jsonrpc":"2.0","method":"CreateTransaction","params":[{"version":0,"nonce":1,"to":"22537dfddb1232be8ce10c7fc4b784f61a4375a9","amount":"1","pubKey":"03b51541a4e231517740ec9bc5dda5647bc5ef560f849f95a4f7d9eaa118fba131","gasPrice":10,"gasLimit":10,"code":"","data":"","signature":"9acfcb4a0aac7911559038c576cdbc0256a8ffe355c10d9922069ca3c7513806dfa32f01e00ed12bbf0012ec26e684c1015a71fc9352d9513f4b81d4179df8d6"}],"id":29}' },
=>>> data: { id: 29, jsonrpc: '2.0', result: { Error: 'Invalid Tx Json' } } }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.