Code Monkey home page Code Monkey logo

skalenetwork / skaled Goto Github PK

View Code? Open in Web Editor NEW
85.0 13.0 39.0 19.63 MB

Running more than 20 production blockchains, SKALED is Ethereum-compatible, high performance C++ Proof-of-Stake client, tools and libraries. Uses SKALE consensus as a blockchain consensus core. Includes dynamic Oracle. Implements file storage and retrieval as an EVM extension.

Home Page: https://skale.network

License: GNU General Public License v3.0

CMake 1.13% Shell 0.64% C++ 83.85% C 7.92% Dockerfile 0.03% Python 0.28% JavaScript 1.15% HTML 3.55% Assembly 0.31% Makefile 0.03% Gnuplot 0.01% Solidity 0.36% TypeScript 0.76%
cpp evm skale-network blockchain dapp ethereum proof-of-stake

skaled's Introduction




SKALED – SKALE C++ Client

Discord

Skaled is SKALE Proof-Of-Stake blockchain client, compatible with ETH ecocystem, including EVM, Solidity, Metamask and Truffle. It uses SKALE BFT Consensus engine. It is currently actively developed and maintained by SKALE Labs, and intended to be used for SKALE blockchains.

The SKALE network supports an unlimited number of independent blockchains with zero gas fees, instant finality, and high transaction throughput. SKALE is the first live blockchain with Linear Scaling. As more nodes join the network, the capacity of the network also grows.

Forklessness

Skaled is forkless, meaning that blockchain a linear chain (and not a tree of forks as with ETH 1.0). Every block is provably finalized within finite time.

Asynchronous block production

Skaled is asynchronous, meaning that the consensus on the next block starts immediately after the previous block is finalized. There is no set block time interval. This allows for subsecond block production in case of a fast network, enabling interactive Dapps.

Provable security

Skaled is the only provably secure ETH compatible PoS client. Security is proven under assumption of maximum t malicious nodes, where the total number of nodes N is more or equal 3t + 1.

Survivability

The network is assumed to bef fully asynchronous meaning that there is no upper limit for the packet delivery time. In case of a temporarily network split, the protocol can wait indefinitely long until the split is resolved and then resume normal block production.

Historic origins

Historically skaled started by forking Aleth (formerly known as the cpp-ethereum project). We are thankful to the original cpp-ethereum team for their contributions.

Building from source

OS requirements

Skaled builds and runs on Ubuntu 20.04 and 22.04

Clone repository

git clone --recurse-submodules https://github.com/skalenetwork/skaled.git
cd skaled

⚠️ Note: Because this repository depends on additional submodules, it is important to pass--recurse-submodules to the git clone command.

If you have already cloned the repo and forgot to pass --recurse-submodules, execute git submodule update --init --recursive

Install required Ubuntu packages

sudo apt update
sudo apt install autoconf build-essential cmake libprocps-dev libtool texinfo wget yasm flex bison btrfs-progs python3 python3-pip gawk git vim doxygen 
sudo apt install make build-essential cmake pkg-config libgnutls28-dev libssl-dev unzip zlib1g-dev libgcrypt20-dev docker.io gcc-9 g++-9 gperf clang-format-11 gnutls-dev
sudo apt install nettle-dev libhiredis-dev redis-server google-perftools libgoogle-perftools-dev lcov sudo apt-get install libv8-dev

NB cmake needs to be of version >=3.21, git of version >=2.18

(for Ubuntu 20.10 or later) Set gcc-9 as default compiler

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-9 9
sudo update-alternatives --install /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-9 9
sudo update-alternatives --install /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-9 9
gcc --version

Install latest cmake

sudo apt-get purge cmake
sudo snap install cmake --classic

Build dependencies

cd deps
./build.sh DEBUG=1

Hunter fix

mkdir -p ~/.hunter/_Base/Download/crc32c/1.0.5/dc7fa8c/
cd ~/.hunter/_Base/Download/crc32c/1.0.5/dc7fa8c/
wget https://github.com/hunter-packages/crc32c/archive/refs/tags/hunter-1.0.5.tar.gz

Configure and build skaled

# Configure the project and create a build directory.
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug
# Build all default targets using all cores.
cmake --build build -- -j$(nproc)

Testing

To run the tests:

cd build/test
./testeth -- --all

Documentation

SKALED documentation

Contributing

We are actively looking for contributors and have great bounties!

Please read CONTRIBUTING and CODING_STYLE thoroughly before making alterations to the code base. This project adheres to SKALE's code of conduct. By participating, you are expected to uphold this code.

We use GitHub issues for tracking requests and bugs, so please see our general development questions and discussion on Discord.

All contributions are welcome! We try to keep a list of tasks that are suitable for newcomers under the tag help wanted. If you have any questions, please just ask.

Discord

All development goes in develop branch.

For more information

Learn more about the SKALE community over on Discord.

License

License

All contributions are made under the GNU General Public License v3. See LICENSE.

All original cpp-ethereum code Copyright (C) Aleth Authors.
All cpp-ethereum modifications Copyright (C) SKALE Labs.
All skaled code Copyright (C) SKALE Labs.

skaled's People

Contributors

badrogger avatar cstrangedk avatar dimalit avatar dimastebaev avatar dmytronazarenko avatar dmytrotkk avatar evgeniyzz avatar gannakulikova avatar kladkogex avatar olehnikolaiev avatar polinakiporenko avatar sergiy-skalelabs 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

skaled's Issues

sChain block minining stucks on 1 node

sChain version: 3.4.1-beta.0
sChain blocks mining stucks on one node, while other nodes are working fine

2021-01-26 03:54:34.403963   Block sealed #950630
[2021-01-26 03:54:35.010] [19:main] [info] 950630:BIN_CONSENSUS_START: PROPOSING: 0101001111111011
[2021-01-26 03:54:36.224] [19:consensus] [info] 950630:BLOCK_DECIDE: PRPSR:7:BID:950631:STATS:|1|D0R0P308L681|2|D1R1P307L917|3|D1R1P765L896|4|D0R0P281L895|5|D0R0P274L690|6|D0R0P273L710|7|D1R1P744L855|8|*|9|*|10|*|11|*|12|D0R0P261L848|13|*|14|*|15|*|16|*|| Now signing block ...
[2021-01-26 03:54:36.324] [19:consensus] [info] 950630:BLOCK_DECIDE (GOT SIG): PRPSR:7:BID:950631| Now signing block ...
[2021-01-26 03:54:36.325] [19:main] [info] 950630:BLOCK_SIGNED: Now finalizing block ... BID:950631
[2021-01-26 03:54:36.325] [19:main] [info] 950630:BLOCK_COMMIT: PRPSR:7:BID: 950631:ROOT:106079737146002787738160479415799919956986602684232558788512079374694987824437:HASH:935e50af:BLOCK_TXS:0:DMSG:0:MPRPS:3:RPRPS:45:TXS:0:TXLS:48:KNWN:0:MGS:111:INSTS:321:BPS:0:HDRS:7:SOCK:2:CONS:5:DSDS:0
isSealed: 0
2021-01-26 03:54:36.342853   Block sealed #950631
[2021-01-26 03:54:36.944] [19:main] [info] 950631:BIN_CONSENSUS_START: PROPOSING: 0101000111111111
[2021-01-26 03:54:38.165] [19:consensus] [info] 950631:BLOCK_DECIDE (GOT SIG): PRPSR:4:BID:950632| Now signing block ...
[2021-01-26 03:54:38.165] [19:main] [info] 950631:BLOCK_SIGNED: Now finalizing block ... BID:950632
[2021-01-26 03:54:38.166] [19:main] [info] 950631:BLOCK_COMMIT: PRPSR:4:BID: 950632:ROOT:106079737146002787738160479415799919956986602684232558788512079374694987824437:HASH:18541859:BLOCK_TXS:0:DMSG:9:MPRPS:3:RPRPS:45:TXS:0:TXLS:48:KNWN:0:MGS:199:INSTS:332:BPS:0:HDRS:95:SOCK:0:CONS:0:DSDS:0
isSealed: 0
2021-01-26 03:54:38.183582   Block sealed #950632
[2021-01-26 03:54:38.849] [19:main] [info] 950632:BIN_CONSENSUS_START: PROPOSING: 0100001111111111
[2021-01-26 03:54:39.557] [19:consensus] [info] 950632:BLOCK_DECIDE: PRPSR:9:BID:950633:STATS:|1|D1R0P26L604|2|D1R0P25L630|3|*|4|*|5|*|6|*|7|*|8|D1R0P1L649|9|D1R0P13L661|10|*|11|*|12|*|13|*|14|*|15|*|16|*|| Now signing block ...
[2021-01-26 03:54:39.848] [19:consensus] [info] 950632:BLOCK_DECIDE (GOT SIG): PRPSR:9:BID:950633| Now signing block ...
[2021-01-26 03:54:39.848] [19:main] [info] 950632:BLOCK_SIGNED: Now finalizing block ... BID:950633
[2021-01-26 03:54:39.849] [19:main] [info] 950632:BLOCK_COMMIT: PRPSR:9:BID: 950633:ROOT:106079737146002787738160479415799919956986602684232558788512079374694987824437:HASH:a8a2a0c1:BLOCK_TXS:0:DMSG:6:MPRPS:3:RPRPS:45:TXS:0:TXLS:48:KNWN:0:MGS:124:INSTS:326:BPS:0:HDRS:27:SOCK:2:CONS:0:DSDS:0
isSealed: 0
2021-01-26 03:54:39.866150   Block sealed #950633
[2021-01-26 03:54:40.405] [19:main] [info] 950633:BIN_CONSENSUS_START: PROPOSING: 0101001110111111
[2021-01-26 03:54:41.188] [19:consensus] [info] 950633:BLOCK_DECIDE: PRPSR:9:BID:950634:STATS:|1|*|2|D1R0P23L567|3|*|4|D1R0P4L589|5|*|6|*|7|D1R0P10L671|8|D1R0P7L684|9|D1R0P3L711|10|*|11|*|12|*|13|*|14|*|15|*|16|*|| Now signing block ...
[2021-01-26 03:54:41.321] [19:consensus] [info] 950633:BLOCK_DECIDE (GOT SIG): PRPSR:9:BID:950634| Now signing block ...
[2021-01-26 03:54:41.321] [19:main] [info] 950633:BLOCK_SIGNED: Now finalizing block ... BID:950634
[2021-01-26 03:54:41.321] [19:main] [info] 950633:BLOCK_COMMIT: PRPSR:9:BID: 950634:ROOT:106079737146002787738160479415799919956986602684232558788512079374694987824437:HASH:73631ada:BLOCK_TXS:0:DMSG:7:MPRPS:3:RPRPS:45:TXS:0:TXLS:48:KNWN:0:MGS:118:INSTS:326:BPS:0:HDRS:18:SOCK:2:CONS:0:DSDS:0
isSealed: 0
2021-01-26 03:54:41.326410   Block sealed #950634
[2021-01-26 03:54:41.867] [19:main] [info] 950634:BIN_CONSENSUS_START: PROPOSING: 0101001110111111
[2021-01-26 03:54:42.631] [19:consensus] [info] 950634:BLOCK_DECIDE: PRPSR:4:BID:950635:STATS:|1|D1R1P13L517|2|D1R1P36L483|3|D0R0P2L315|4|D1R1P34L485|5|D0R0P1L357|6|D0R0P2L357|7|*|8|*|9|*|10|D0R0P1L478|11|*|12|D0R0P1L427|13|*|14|*|15|*|16|*|| Now signing block ...
[2021-01-26 03:54:42.837] [19:consensus] [info] 950634:BLOCK_DECIDE (GOT SIG): PRPSR:4:BID:950635| Now signing block ...
[2021-01-26 03:54:42.837] [19:main] [info] 950634:BLOCK_SIGNED: Now finalizing block ... BID:950635
[2021-01-26 03:54:42.837] [19:main] [info] 950634:BLOCK_COMMIT: PRPSR:4:BID: 950635:ROOT:106079737146002787738160479415799919956986602684232558788512079374694987824437:HASH:7a318e0b:BLOCK_TXS:0:DMSG:2:MPRPS:3:RPRPS:45:TXS:0:TXLS:48:KNWN:0:MGS:105:INSTS:322:BPS:0:HDRS:7:SOCK:2:CONS:0:DSDS:0
isSealed: 0
2021-01-26 03:54:42.858836   Block sealed #950635
[2021-01-26 03:54:43.763] [19:main] [info] 950635:Rotating /da_sigshares_19.db database. Max DB size in bytes: 10416660
[2021-01-26 03:54:43.815] [19:main] [info] 950635:BIN_CONSENSUS_START: PROPOSING: 0101001110111111
[2021-01-26 03:54:44.503] [19:consensus] [info] 950635:BLOCK_DECIDE: PRPSR:11:BID:950636:STATS:|1|D1R0P1L488|2|D1R0P60L479|3|*|4|D1R0P1L507|5|*|6|*|7|*|8|D1R0P10L568|9|D1R0P1L595|10|*|11|D1R0P1L635|12|*|13|*|14|*|15|*|16|*|| Now signing block ...
[2021-01-26 03:54:44.833] [19:consensus] [info] 950635:BLOCK_DECIDE (GOT SIG): PRPSR:11:BID:950636| Now signing block ...
[2021-01-26 03:54:44.833] [19:main] [info] 950635:BLOCK_SIGNED: Now finalizing block ... BID:950636
[2021-01-26 03:54:44.834] [19:main] [info] 950635:BLOCK_COMMIT: PRPSR:11:BID: 950636:ROOT:106079737146002787738160479415799919956986602684232558788512079374694987824437:HASH:34d43e2e:BLOCK_TXS:0:DMSG:9:MPRPS:4:RPRPS:45:TXS:0:TXLS:49:KNWN:0:MGS:112:INSTS:326:BPS:0:HDRS:16:SOCK:2:CONS:0:DSDS:0
isSealed: 0
free(): corrupted unsorted chunks
2021-01-26 03:54:44.855266   Block sealed #950636
[2021-01-26 03:54:45.186] [19:main] [error] 950636:!Exception: std:State check failed::_daProof /home/runner/work/skaled/skaled/libconsensus/blockproposal/pusher/BlockProposalClientAgent.cpp:127
[2021-01-26 03:54:45.321] [19:main] [info] 950636:BIN_CONSENSUS_START: PROPOSING: 1100001011111111
[2021-01-26 03:54:45.818] [19:main] [info] 950636:No proposal in finalization:9
[2021-01-26 03:54:48.190] [19:main] [error] 950636:!Exception: std:State check failed::_daProof /home/runner/work/skaled/skaled/libconsensus/blockproposal/pusher/BlockProposalClientAgent.cpp:127
[2021-01-26 03:54:49.291] [19:main] [info] 950636:BLOCK_COMMIT: PRPSR:8:BID: 950637:ROOT:106079737146002787738160479415799919956986602684232558788512079374694987824437:HASH:5c2a3882:BLOCK_TXS:0:DMSG:11:MPRPS:4:RPRPS:45:TXS:0:TXLS:50:KNWN:0:MGS:138:INSTS:326:BPS:0:HDRS:46:SOCK:3:CONS:0:DSDS:0
[2021-01-26 03:54:51.200] [19:main] [error] 950636:!Exception: std:State check failed::_daProof /home/runner/work/skaled/skaled/libconsensus/blockproposal/pusher/BlockProposalClientAgent.cpp:127
[2021-01-26 03:54:52.976] [config] [warning] Node:19:Thread:140703464158976:Schain::processCommittedBlock has been stuck for 3685 ms
[2021-01-26 03:54:52.976] [config] [warning] Node:19:Thread:140703464158976:Schain::pushBlockToExtFace has been stuck for 3682 ms
[2021-01-26 03:54:53.976] [config] [warning] Node:19:Thread:140703464158976:Schain::processCommittedBlock has been stuck for 4685 ms
[2021-01-26 03:54:53.976] [config] [warning] Node:19:Thread:140703464158976:Schain::pushBlockToExtFace has been stuck for 4682 ms
[2021-01-26 03:54:54.201] [19:main] [error] 950636:!Exception: std:State check failed::_daProof /home/runner/work/skaled/skaled/libconsensus/blockproposal/pusher/BlockProposalClientAgent.cpp:127
[2021-01-26 03:54:54.976] [config] [warning] Node:19:Thread:140703464158976:Schain::processCommittedBlock has been stuck for 5685 ms
[2021-01-26 03:54:54.976] [config] [warning] Node:19:Thread:140703464158976:Schain::pushBlockToExtFace has been stuck for 5682 ms
[2021-01-26 03:54:55.976] [config] [warning] Node:19:Thread:140703464158976:Schain::processCommittedBlock has been stuck for 6685 ms
[2021-01-26 03:54:55.977] [config] [warning] Node:19:Thread:140703464158976:Schain::pushBlockToExtFace has been stuck for 6683 ms
[2021-01-26 03:54:56.977] [config] [warning] Node:19:Thread:140703464158976:Schain::processCommittedBlock has been stuck for 7686 ms
[2021-01-26 03:54:56.977] [config] [warning] Node:19:Thread:140703464158976:Schain::pushBlockToExtFace has been stuck for 7683 ms
[2021-01-26 03:54:57.208] [19:main] [error] 950636:!Exception: std:State check failed::_daProof /home/runner/work/skaled/skaled/libconsensus/blockproposal/pusher/BlockProposalClientAgent.cpp:127
[2021-01-26 03:54:57.977] [config] [warning] Node:19:Thread:140703464158976:Schain::processCommittedBlock has been stuck for 8686 ms
[2021-01-26 03:54:57.977] [config] [warning] Node:19:Thread:140703464158976:Schain::pushBlockToExtFace has been stuck for 8683 ms
[2021-01-26 03:54:58.977] [config] [warning] Node:19:Thread:140703464158976:Schain::processCommittedBlock has been stuck for 9686 ms
[2021-01-26 03:54:58.977] [config] [warning] Node:19:Thread:140703464158976:Schain::pushBlockToExtFace has been stuck for 9683 ms
[2021-01-26 03:54:59.977] [config] [warning] Node:19:Thread:140703464158976:Schain::processCommittedBlock has been stuck for 10686 ms
[2021-01-26 03:54:59.977] [config] [warning] Node:19:Thread:140703464158976:Schain::pushBlockToExtFace has been stuck for 10683 ms

┆Issue is synchronized with this Jira Bug

Bad IMA message type

Preconditions
IMA: 1.0.0-logs.2
Skaled: 3.2.2-develop.0
https://skalelabs.atlassian.net/wiki/spaces/SE/pages/1173880898/Rinkeby+Testnet-281020
16 nodes schain(test type MEDIUM)
1 sgx operate all nodes

Step to reproduce
Send ERC20 token M to S
https://github.com/skalenetwork/IMA/blob/develop/proxy/contracts/DepositBox.sol#L228
function deposit(string memory schainID, address to) public payable
http://54.70.3.214:10014

Actual result
M2S Sign msgs: Wallet CRITICAL ERROR:S-Chain reported wallet error: bad IMA message type 192020-12-29 21:33:56.203: Transfer from Mainnet to glamorous-turais: CRITICAL ERROR: Error signing messages: signature error in 16 node(s) of 16 node(s)

┆Issue is synchronized with this Jira Task

Check and fix some snapshot-related features

1 Kill skaled before it finishes computing of snapshot hash. Then restart.
2 Stop skaled after finishing hash and restart (so all snapshots on disk have hashes)
3 Skaled that just downloaded snapshot has to give it to others (should be in tests)

┆Issue is synchronized with this Jira Task

sChain throws non-behavior exception while couldn't connect to node

After turn off sChain container on one of 16 node, in sChain log (on working machine) Exception: There is no such key in cache appears, while trying to connect to stopping node:

[2020-11-17 16:40:47.110] [26:main] [error] 28:!Exception: There is no such key in cache
[2020-11-17 16:40:50.111] [26:main] [error] 28:!Exception: ClientSocket:Couldnt connect to:18.193.89.240:10011:Connection refused
[2020-11-17 16:40:50.445] [26:consensus] [info] 28:BLOCK_DECIDE: PRPSR:3:BID:29:STATS:|1|D0R2P46L67|2|D0R2P29L80|3|D1R0P21L87|4|D1R0P18L89|5|D1R0P21L87|6|D1R0P24L87|7|*|8|D1R0P29L84|9|D1R0P43L83|10|D1R0P26L82|11|D1R0P18L80|12|D0R2P99L79|13|*|14|*|15|D1R0P4L74|16|*|| Now signing block ...
[2020-11-17 16:40:50.523] [26:consensus] [info] 28:BLOCK_DECIDE (GOT SIG): PRPSR:3:BID:29| Now signing block ...
[2020-11-17 16:40:50.523] [26:main] [info] 28:BLOCK_SIGNED: Now finalizing block ... BID:29
[2020-11-17 16:40:50.523] [26:main] [info] 28:BLOCK_COMMIT: PRPSR:3:BID: 29:ROOT:46320509353513273106582423493727320152202237096314791991810382902766530930981:HASH:6ea6990c:BLOCK_TXS:0:DMSG:22:MPRPS:5:RPRPS:45:TXS:0:TXLS:50:KNWN:0:MGS:185:INSTS:265:BPS:0:HDRS:94:SOCK:0:CONS:0:DSDS:62
2020-11-17 16:40:50.524656   createBlock ID = #29

Note: 18.193.89.240:10011 - stopped node. Test log below

STR:

Run recovery test from skale-test-cli

┆Attachments: noisy-gorgonea-secunda.zip

Skaled heap-use-after-free crash

Preconditions
skaled custom version:3.5.2-plus-sanitizer
based on: 3.5.2-develop.0

Step to reproduce
Create schain test type MEDIUM
Run func test(ima cats)
NOTE: M to S payment action

Actual result
==1==ERROR: AddressSanitizer: heap-use-after-free on address 0x60e000022da0 at pc 0x563c9f398fc1 bp 0x7f03c53a2130 sp 0x7f03c53a2120

┆Issue is synchronized with this Jira Bug

Create script for sChain load testing on TestNet

Create script that allows to run performance tests on production-type sChains. Script should :

  1. Deploy contract that send fake-eth to account
  2. Request fake-eth for cats accounts
  3. Run cats tests

┆Issue is synchronized with this Jira Task

Zero snapshot directory is absent

After running sChain with --download-snapshot flag (on the new node, while rotation is in progress), 0 snapshot directory hasn't been created.

STR:

  1. Run multiple rotation test for 4 sChains
  2. On the new node check whether there is a 0-snapshot directory in /mnt/[SCHAIN-NAME]/snapshots/

┆Issue is synchronized with this Jira Bug

skaled hangs in thread_pool

On exit, skaled sometimes hangs.
Very probably this happens because of wait:

void thread_pool::worker::invoke() {
    skutils::multithreading::threadNamer tn( skutils::tools::format( "p%zu", id_ ) );
    std::function< void() > func;
    bool was_dequeued = false;
    while ( !pool_->shutdown_flag_ ) {
        {  // block
            std::unique_lock< mutex_type > lock( pool_->conditional_mutex_ );
            if ( pool_->queue_.empty() ) {
                pool_->conditional_lock_.wait( lock );
            }
            if ( !pool_->shutdown_flag_ )
                was_dequeued = pool_->queue_.dequeue( func );
        }  // block
        if ( was_dequeued ) {
            try {
                func();
            } catch ( ... ) {
            }
        }
    }  // while( ! pool_->shutdown_flag_ )
}

Need to check exit flag more wisely.

Question: Async functionality in libskutils/include/httplib.h

Hi, I am an author of cpp-httplib HTTP library, and I am happy to see you are using it in your project.

A user just asked me to provide 'non-blocking' APIs in cpp-httplib, but it looks requiring lots of changes. But I just happened to find your fork of cpp-httplib looks supporting async functionality without changing the existing APIs in the beautiful way. I am not planning to make any change to my cpp-httplib in this regard, but I just wonder if your fork could work perfectly in the user's project.

If your fork is specialized only for your project, or is it more like a general async http library? Thanks!

yhirose/cpp-httplib#379

Bad IMA message type

Preconditions
IMA: 1.0.0-logs.2
Skaled: 3.2.2-develop.0
https://skalelabs.atlassian.net/wiki/spaces/SE/pages/1173880898/Rinkeby+Testnet-281020
16 nodes schain(test type MEDIUM)
1 sgx operate all nodes

Step to reproduce
Send ERC20 token M to S
https://github.com/skalenetwork/IMA/blob/develop/proxy/contracts/DepositBox.sol#L228
function deposit(string memory schainID, address to) public payable
http://54.70.3.214:10014

Actual result
M2S Sign msgs: Wallet CRITICAL ERROR:S-Chain reported wallet error: bad IMA message type 192020-12-29 21:33:56.203: Transfer from Mainnet to glamorous-turais: CRITICAL ERROR: Error signing messages: signature error in 16 node(s) of 16 node(s)

┆Issue is synchronized with this Jira Bug

IMA improve message stream processing between chains

Avoid using pending transactions scan. Replace it with own mechanism based on TX cache inside skaled. This cache should be used by all the IMA agents to understand which transactions are still pending and in-progress.

┆Issue is synchronized with this Jira Task

create schain container without mount folder on node

versions:
admin:beta16.OlehFix
schain:schain:3.4.6-develop.1
node_cli:1.1.0-beta.12
manager:1.8.0-develop.0

str:

  1. 17 nodes on contract
  2. put in_maintanence one of them (rotated_node)
  3. create 4 schains
  4. get from_maintenance (rotated_node)
  5. invoke skale exit start procedure on one of nodes which contains 4 skaleds

expected: all schains should works fine on rotated_node

actual: some of schain do not rotated because do not get a mount folder on node

┆Issue is synchronized with this Jira Bug
┆Attachments: rotated_node.tar.gz | usual_1.tar.gz | usual_2.tar.gz

WTF is wrong with SKALE validator documentation?

DRAFT (not active yet)

SKALE engineering has received a small but meaningful monthly budget to do all kinds of crazy things.

This month it will be all about validators!

  1. We are looking to improve SKALE validator documentation.

https://skale.network/docs/validators/getting-started

  1. There will be 20 prizes guaranteed to be paid. The first is 12,000 SKL, the second 11,500 SKL, the third is 11,000 SKL, and so on.

  2. You need to create a five minute video telling us how to improve the docs. Note, that improving documentation may be approached in all kinds of ways.

You may be:

 - a devops person 
 - a designer
 - a marketer
 - a technical writer 
 - an engineer
 - a QA
 - a school teacher
 - a poet 
  1. Being creative is good. Think of SKALE as your startup. No crazy things will be rejected!

  2. Please be positive and nice in the video! SKALE engineers are working hard!

  3. You have around a week to do the video. We should receive your submission by the end of the day (24:00) on Sunday, Jan 3, 2021, San Francisco Time.

  4. To submit, upload the video on Youtube, and direct message the link to @stan_kladko on Twitter.

  5. Once the deadline passes, we will reveal all submissions through Twitter, and then take three days to determine the 20 winners.

  6. Your Twitter account needs to be at least one year old to submit. This is to fight bots. It is OK to use friend's account if you dont have Twitter.

  7. The submission can be in any language! If not in English, it needs to have English subtitles.

  8. Any questions regarding the rules - simply tweet them to @stan_kladko

  9. We encourage diversity of all kinds!

  10. The winners will get tokens sent to an ETH wallet address.

  11. Good luck!

Investigate and implement skaled access control (make sure tokens are deployed automatically and contracts should be allowed to deploy other contracts)

Need to investigate skaled and assess the possibility of making a change to allow smart contact deploy other smart contracts

Need to investigate:

  • possibility of adding more addresses for a skale chain (list of addresses, functionality to change the address)
  • possibility of looking from origin of a transaction to the sender of a transaction

https://skalelabs.atlassian.net/wiki/spaces/SKALE/pages/1377828907/Schain+owner+should+deploy+Token#Planning---December-25

┆Issue is synchronized with this Jira Task
┆Attachments: 1_admin_acc.png | 2_admin_acc.png | whitelisted_address.png

ERC721 Interaction Issues

Posting issue reported by CryptoRaves (@cartosys):

Hi Christine,

I've recently encountered an error while working on the "BoB" testnet. I've ran the same suite of tests before without encountering an issue, so I suspect something has changed on the Skale side in recent weeks.

Here is what i've tracked it down as well as a brief description:

When depositing an ERC721 standard token into a custom smart contract I get the following error:

Wed Jan 27 01:54:32 PM EST 2021: <- I ran this on Bob within a few seconds of this time

Transaction: 0x81be80025ed66260e8fd180f85515d484f0163aafeec1d0219f00878bece7084 exited with an error (status 0) after consuming all gas.
Please check that the transaction:
- satisfies all conditions set by Solidity assert statements.
- has enough gas to execute the full transaction.
- does not trigger an invalid opcode by other means (ex: accessing an array out of bounds).
StatusError: Transaction: 0x81be80025ed66260e8fd180f85515d484f0163aafeec1d0219f00878bece7084 exited with an error (status 0) after consuming all gas.
at Context. (test/erc721Test.test.js:11:28)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:97:5)

I've tried to increase the gas limit in the truffle-config. Here is my configuration for Bob testnet:

skaleTestBob: {
provider: () => new HDWalletProvider(privateKey, 'https://dev-testnet-v1-1.skalelabs.com'),
gasPrice: 0,
gas: 160000000, // <- this # is greatly increased from when it worked before
network_id: "*",
timeout: 100000,
ChainID: 344435
},

Below is the test js file i run via the command "truffle test --network skaleTestBob test/erc721Test.test.js" Note that I purposely send a token to a contract that is not erc721 deposit-enabled. I know this will cause a reversion, but its the only way I'm able to reliably recreate the issue. So if you run this same code on a local ganache-cli node it will of course revert but with the following expected error: "Error: Returned error: VM Exception while processing transaction: revert ERC721: transfer to non ERC721Receiver implementer -- Reason given: ERC721: transfer to non ERC721Receiver implementer." Link to relevent github line. Now notice this error msg is different when run on the Bob testet. Somehow when run on Bob, the execution doesn't get to that line of solidity I linked to. It seems to fail somewhere prior to that in the safeTransferFom() function. I can also get this error to sometimes occur even if the var addr1 is set to a random non-contract address such as the commented line there. Uncomment that line (and remove the other addr1 definition) and it will perhaps pass on a ganache node but not on Bob:

const ERC721Mintable = artifacts.require('ERC721Mintable')

contract("ERC721", async accounts => {
it("sends an ERC721 token", async () => {
let erc721Instance = await ERC721Mintable.deployed()

let addr1 = '0xf9cb8AA1C041E41459de4c296e55B30DB3FCe406'  //random address to send to
//let addr1 = erc721Instance.address //purposely set to deployed contract address to cause reversion
await erc721Instance.safeTransferFrom(accounts[0], addr1, 0)
let addr2 = await erc721Instance.ownerOf(0)
assert.equal(
addr1,
addr2,
'Transfer failed'
)

})
})

Here is the solidity i have written. It's located in contracts/Erc721Mintable.sol. It imports the standard openzeppelin contracts as seen on their github.

//SPDX-License-Identifier: MIT
pragma solidity 0.6.10;
import "/home/cartosys/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol";
import "/home/cartosys/openzeppelin-contracts/contracts/utils/Counters.sol";
contract ERC721Mintable is IERC721Metadata, IERC721Enumerable, ERC721 {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;

constructor(address userAddress, string memory name, string memory symbol) ERC721(name, symbol) public {
    uint256 newItemId = _tokenIds.current();
    _safeMint(userAddress, newItemId);
}
function mint(address to, string memory tokenURI) public returns (uint256) {
    _tokenIds.increment();
    uint256 newItemId = _tokenIds.current();
    _safeMint(to, newItemId);
    _setTokenURI(newItemId, tokenURI);
    return newItemId;
}

}

I have no problems doing safeTransferFrom() using erc20. And all of my other 70+ tests using my custom smart contracts & other standard ones work fine, FYI.

That was long. 😅 Let me know if anything needs clarification.
Thanks,
-b

┆Issue is synchronized with this Jira Task

IMA pending work tracker for MessageProxy.postIncommingMessage() must use ECDSA-signed messages

IMA agent uses pending work tracker implemented as part of skaled to monitor long time mined IMA message transfers (calls to MessageProxy.postIncommingMessage() contract method where messages arrived finally). All the notifications about pending IMA messages are saved inside skaled via JSON RPC calls. Also, skaled broadcasts IMA pending work entries to other skaled instances in S-Chain via special JSON RPC broadcast calls. All the JSON RPC calls above must be ECDSA-signed.

NOTICE:

  • This task is optional but good to have for test net
  • It's must have for release

NOTES FOR IMPLEMENTATION:-

  • The CryptoManager::sgxSignECDSA, CryptoManager::verifyECDSA, setSGXKeyInfo APIs in Consensus offer ready to use ECDSA algorithm wrappers
  • The JStubClient.h file in Consensus offers ready to use configuration loader
  • The setSGXKeyInfo API in Consensus offers offers ECDSA key initialization code
  • The ConsensusEngine class in Consensus does ECDSA initialization from loaded config values in skaled
  • The crypto/OpenSSLECDSAKey.h file is ready to use ECDSA key implementation with APIs
  • The OpenSSLECDSAKey::deserializeSGXPubKey API is handy to convert string key into OpenSSL's EC_KEY that can be destroyed later with EC_KEY_free( ecKey )call

┆Issue is synchronized with this Jira Task

FATAL STATE ROOT MISMATCH ERROR on new node only

get FATAL STATE ROOT MISMATCH ERROR in each schain for new node only in pool

versions:
schain:3.2.2-develop.0
admin:1.1.0-beta.4
node_cli:1.1.0-beta.5

STR:

  1. 18 nodes on contract
  2. create/add one new node (NN - 44.237.112.8) on contract
  3. 19 nodes on contract
  4. start creating schains one by one in loop (5 times)
  5. schain created successfully but after some time schain (only on node NN) fail with error:
    2020-12-23 13:46:16.745723 FATAL STATE ROOT MISMATCH ERROR: current state root 24745939710161491612369937548995839602973854240519570550688128547476896622564 is not equal to arrived state root 68133205624415312807337791088692335477496143231606368363052400763714831147101 with block ID #329, /data_dir cleanup is recommended, exiting with code 200... `

actual: all schain containers on node NN constantly recreated

┆Attachments: bad_101_snapshot_hash_ksLzLKuqBp.txt | broken_schain_log.txt | NN_node.tar.gz | regular_1002_snapshot_hash_ksLzLKuqBp.txt | regular_1063_snapshot_hash_ksLzLKuqBp.txt | regular_1127_snapshot_hash_ksLzLKuqBp.txt | regular_node.tar.gz

Remove ECDSA key form skaled output

Remove(or hide) ECDSA private key from skaled output
////
[2020-10-19 18:43:21.580] [11:main] [info] 0:Getting ECDSA public key for NEK:b4245fe8bc068d53ce24c8d85025234c2d08c0d2b0a854fc1d06474616b8ca74

///

Dispatch: Have all 16 threads in pool started fast
btrfs filesystem df /data_dir
btrfs filesystem df /data_dir/28e07f34
btrfs subvolume create /data_dir/28e07f34
btrfs filesystem df /data_dir/filestorage
btrfs subvolume create /data_dir/filestorage
btrfs filesystem df /data_dir/prices_11.db
btrfs subvolume create /data_dir/prices_11.db
btrfs filesystem df /data_dir/blocks_11.db
btrfs subvolume create /data_dir/blocks_11.db
2020-10-19 18:43:21.133308 IPC server is: off
2020-10-19 18:43:21.133426 Got HTTP/4 port from configuration JSON: 10014
2020-10-19 18:43:21.133463 Got HTTP/6 port from configuration JSON: 10014
2020-10-19 18:43:21.133492 Got HTTPS/4 port from configuration JSON: 10019
2020-10-19 18:43:21.133520 Got HTTPS/6 port from configuration JSON: 10019
2020-10-19 18:43:21.133548 Got WS/4 port from configuration JSON: 10013
2020-10-19 18:43:21.133576 Got WS/6 port from configuration JSON: 10013
2020-10-19 18:43:21.133615 Got WSS/4 port from configuration JSON: 10018
2020-10-19 18:43:21.133643 Got WSS/6 port from configuration JSON: 10018
2020-10-19 18:43:21.133673 Got HTTP/4 port from command line: 10014
2020-10-19 18:43:21.133700 Got HTTPS/4 port from command line: 10019
2020-10-19 18:43:21.133734 Got WS/4 port from command line: 10013
2020-10-19 18:43:21.133775 Got WSS/4 port from command line: 10018
2020-10-19 18:43:21.133806 JSON RPC trace logging mode is enabled
2020-10-19 18:43:21.133833 Important notce: Programmatic enable-debug-behavior-apis mode is enabled
2020-10-19 18:43:21.133869 Important notce: Programmatic unsafe-transactions mode is disabled
2020-10-19 18:43:21.133898 Important notce: Programmatic web3-shutdown mode is disabled
2020-10-19 18:43:21.133936 IPC path is:
2020-10-19 18:43:21.133977 DB path is: /data_dir
skaled, a C++ Skale client
2020-10-19 18:43:21.191742 Removing flag file /skale_schain_data/.rotation
2020-10-19 18:43:21.354943 Opened blockchain DB. Latest: #c1374302… 49743
2020-10-19 18:43:21.414859 Opened state DB.
2020-10-19 18:43:21.415007 Using existing database
2020-10-19 18:43:21.441053 Snapshots enabled, snapshotInterval is: 21600
2020-10-19 18:43:21.442172 Latest snapshots init: 46000 49330 -> 49330
2020-10-19 18:43:21.442203 Fake Last snapshot creation time: 1603151996
2020-10-19 18:43:21.442655 Post state changed.
NOTE: Block number at startup is 49743
Consensus engine version:1.51.1
Found data dir:/data_dir
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:15987926439079474324218945030940217703237779328762376226830066614067503391304
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:9872819343083187348290321954289803764007522877550249036598321163477530148464
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:23674443878008227714358283482353998652910721295239448240518443490099500425
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:11880341348742783968223378230905437406484057090258094861893952729906203684636
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:16711745774384588923032753380104890044035761134954807314344572016110388394423
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:15605865530469504063069198191422172977064623819209781219373363757678738748013
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:20010930572919529449793659441803196370480156587703142919778977523814418687141
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:14082416449110117327199596434431052960316859843932684859629414398230328419659
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:14486179965058962511733910252364478397049967249368086513952082325521298407414
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:8606071433268578375524564637750453493142100075962936450714017029120256503773
[2020-10-19 18:43:21.498] [config] [info] Parsing BLS key share:15434732078980972309603234694315104227618009973494342419876868142764727675267
[2020-10-19 18:43:21.578] [config] [info] Monitoring agent started monitoring
[2020-10-19 18:43:21.579] [11:main] [info] 0:Setting sgxSSLKeyFileFullPath to /skale_node_data/sgx_certs/sgx.key
[2020-10-19 18:43:21.579] [11:main] [info] 0:Setting sgxCertKeyFileFullPath to /skale_node_data/sgx_certs/sgx.crt
[2020-10-19 18:43:21.580] [11:main] [info] 0:Getting ECDSA public key for NEK:b4245fe8bc068d53ce24c8d85025234c2d08c0d2b0a854fc1d06474616b8ca74
[2020-10-19 18:43:22.045] [11:main] [info] 0:Got ECDSA public key: 24582999e803714b081516db614f61ce86fb1082ea91273df07f90c6bdab420e267d790ea8583d767ab6b5dc29dd43b76ffcdd316f49f3b678016c24fe69e44d
2020-10-19 18:43:23.312726 startedWorking()
Starting consensus engine ...[2020-10-19 18:43:24.313] [11:main] [info] 0:Starting node

snpashot is not restored if there was already such a local one

versions:
schain:3.5.2-asan-catchup-size
admin:1.1.0-beta.33

STR

  1. create 16-nodes schain (was one time rotated when some of node not send a broadcas)
  2. run skale schains repair on one of node. after repair skaled download snapshot and then run from snapshot and continue a mining blocks
  3. run cats on this schain on some of 16 endpoints
  4. after some amount of time (~2 hours) node send in telegram message
Node ID: 20, IP: 52.33.227.180
sChain name: harsh-vindemiatrix
:exclamation: Some checks failed
:x: container
:x: rpc
:x: blocks
Timestamp: 1614183859
Datetime: Wed Feb 24 16:24:19 2021

and then

:exclamation: Repair mode for magnificent-alpheratz enabled 
Node id: 20
Node ip: 52.33.227.180
SChain: magnificent-alpheratz
Timestamp: 1614183915
Datetime: Wed Feb 24 16:25:15 2021

5. **after some amount of repair (~12) schain container was failed and not started again**
6. schain continue working on 15 nodes

elvis@elvisthink:~/work/skale-test-cli$ PYTHONPATH=. WATCHDOG_TIMEOUT=30 python main.py monitor schain magnificent-alpheratz
Node ID sChain Name HTTP Blocks Data directory DKG Config file Volume Container IMA Firewall RPC

6 magnificent-alpheratz http://44.242.78.240:10003 True True True True True True True True True
8 magnificent-alpheratz http://54.149.254.14:10003 True True True True True True True True True
9 magnificent-alpheratz http://44.224.239.204:10003 True True True True True True True True True
10 magnificent-alpheratz http://34.214.203.31:10067 True True True True True True True True True
11 magnificent-alpheratz http://52.88.131.171:10003 True True True True True True True True True
14 magnificent-alpheratz http://35.155.23.204:10003 True True True True True True True True True
15 magnificent-alpheratz http://35.155.32.161:10003 True True True True True True True True True
16 magnificent-alpheratz http://44.236.11.126:10003 True True True True True True True True True
17 magnificent-alpheratz http://44.231.35.54:10067 True True True True True True True True True
19 magnificent-alpheratz http://54.188.198.180:10067 True True True True True True True True True
20 magnificent-alpheratz http://52.33.227.180:10003 False True True True True False True True None
22 magnificent-alpheratz http://44.238.200.16:10067 True True True True True True True True True
23 magnificent-alpheratz http://44.241.233.23:10067 True True True True True True True True True
24 magnificent-alpheratz http://44.240.191.48:10067 True True True True True True True True True
25 magnificent-alpheratz http://52.37.19.173:10067 True True True True True True True True True
26 magnificent-alpheratz http://44.235.99.200:10067 True True True True True True True True True


see attached logs

┆Issue is synchronized with this [Jira Bug](https://skalelabs.atlassian.net/browse/SKALE-3937)
┆Attachments: <a href="https://skalelabs.atlassian.net/rest/api/2/attachment/content/10532">last_52_33_227_180.txt</a> | <a href="https://skalelabs.atlassian.net/rest/api/2/attachment/content/10531">skale_schain_magnificent-alpheratz-0.log</a> | <a href="https://skalelabs.atlassian.net/rest/api/2/attachment/content/10530">skale_schain_magnificent-alpheratz-12.log</a>

Fix WS protocol errors causing connection drops

JS test applications using various Web3 JS versions, including latest 1.3.4, do report WS low level protocol error 1002 with error reason describing【 highlighted #ff5630 】out of bounds location of control frames【 end highlighted 】. This problem occur only high load tests like cat-cycle. We need to review entire WS code in libSkUtils project. It's recommended first to update libWebSockets to latest version 4.1-stable, see https://github.com/warmcat/libwebsockets

┆Issue is synchronized with this Jira Task

eth_newPendingTransactionFilter not implemented in skaled

It was implemented, but incorrectly: notified about new transactions in mined block. It caused some events to appear twice (see Client::appendFromNewPending), now it's disabled.

Generally, this call should subscribe to new transactions in pending transactions queue.

┆Issue is synchronized with this Jira Bug

disable or log non-usual json-rpc requests in skaled

Probably somebody calls miner.setEtherbase and this leads to blockchain/state divergence.
Need to disable such calls completely or enable them on testnet, but log them to be able to investigate.

modules: admin:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 skale:0.1 skaleStats:1.0 web3:1.0

┆Issue is synchronized with this Jira Task

skaled exits on memory corruption

version: 3.4.9

16-node schain, IMA tests

after some time skaled says:
2021-02-09 15:25:44.215422 Exiting without request
Caught (first) signal. Signal SIGABRT(6). This is the abort signal. Typically, a process will initiate this kill signal on itself.

core reason is:
malloc_consolidate(): invalid chunk size

Need to check memory issues.

┆Issue is synchronized with this Jira Bug
┆Attachments: SIGABRT.log

sChain couldn't start after recovery

sChain version: v2.0.0-beta.0
sChain couldn't start after recovery

Recovery steps:

  1. We create 16-node MEDIUM sChain
  2. Stopping sChain container on 6 nodes one-by-one (10/16 working -> block mining is stopped)
  3. Restart one of stopped containers (11/16 working)

Expected:
sChain continue block mining

Got:
sChain doesn't mine blocks after 11 nodes are working

STR:
Run recovery test from skale-test-cli. Logs from failed test below

┆Attachments: becrux.txt | noisy-gorgonea-secunda.zip | rapping-angetenar.zip

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.