From c919af763391a0fc39b04aad35bd9c9b2350efef Mon Sep 17 00:00:00 2001 From: Dmytro Nazarenko Date: Mon, 30 Jan 2023 19:51:23 +0200 Subject: [PATCH 01/19] Update VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1eeac129c..3f67e25ce 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.16.0 +3.17.0 From 7ec6bd53c060598f8a835f014024349b5186f48f Mon Sep 17 00:00:00 2001 From: Dmytro Nazarenko Date: Mon, 30 Jan 2023 20:23:56 +0200 Subject: [PATCH 02/19] Update publish.yml --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 84337233e..baf30ed48 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,6 +3,7 @@ on: pull_request: types: [closed] branches: + - 'v*.*.*' - master - develop - beta From a7db090725d10ddd93cef40c4e5cf010bc5abaa2 Mon Sep 17 00:00:00 2001 From: Dmytro Nazarenko Date: Mon, 30 Jan 2023 20:32:34 +0200 Subject: [PATCH 03/19] Update publish.yml --- .github/workflows/publish.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index baf30ed48..ab9e4d847 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -121,7 +121,6 @@ jobs: strip skaled/skaled cd .. - name: Configure historic state build - if: contains(github.ref, 'develop') || contains(github.ref, 'beta') || contains(github.ref, 'master') || contains(github.ref, 'stable') run: | export CC=gcc-9 export CXX=g++-9 @@ -134,7 +133,6 @@ jobs: cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DHISTORIC_STATE=1 .. cd .. - name: Build historic state version - if: contains(github.ref, 'develop') || contains(github.ref, 'beta') || contains(github.ref, 'master') || contains(github.ref, 'stable') run: | export CC=gcc-9 export CXX=g++-9 @@ -147,7 +145,6 @@ jobs: strip skaled/skaled cd .. - name: Build and publish container - if: contains(github.ref, 'develop') || contains(github.ref, 'beta') || contains(github.ref, 'master') || contains(github.ref, 'stable') run: | cp build/skaled/skaled scripts/skale_build/executable/ export BRANCH=${GITHUB_REF##*/} @@ -160,18 +157,16 @@ jobs: echo "::set-env name=RELEASE::$RELEASE" bash ./scripts/build_and_publish.sh - name: Create Release - if: contains(github.ref, 'develop') || contains(github.ref, 'beta') || contains(github.ref, 'master') || contains(github.ref, 'stable') id: create_release uses: actions/create-release@latest env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ env.VERSION }} release_name: ${{ env.VERSION }} draft: false prerelease: true - name: Upload skaled binary to Release - if: contains(github.ref, 'develop') || contains(github.ref, 'beta') || contains(github.ref, 'master') || contains(github.ref, 'stable') uses: actions/upload-release-asset@latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -181,7 +176,6 @@ jobs: asset_name: skaled asset_content_type: application/octet-stream - name: Build and publish historic-state container - if: contains(github.ref, 'develop') || contains(github.ref, 'beta') || contains(github.ref, 'master') || contains(github.ref, 'stable') run: | cp build-historic/skaled/skaled scripts/skale_build/executable/ export BRANCH=${GITHUB_REF##*/} @@ -193,7 +187,6 @@ jobs: echo "::set-env name=RELEASE::$RELEASE" bash ./scripts/build_and_publish.sh - name: Upload historic-state skaled binary to Release - if: contains(github.ref, 'develop') || contains(github.ref, 'beta') || contains(github.ref, 'master') || contains(github.ref, 'stable') uses: actions/upload-release-asset@latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e712d90cae036192d92df7593b699de2c7924940 Mon Sep 17 00:00:00 2001 From: Dmytro Nazarenko Date: Mon, 30 Jan 2023 22:57:53 +0200 Subject: [PATCH 04/19] Update calculate_version.sh --- scripts/calculate_version.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/calculate_version.sh b/scripts/calculate_version.sh index 7a454ad36..6fdd5f1c8 100755 --- a/scripts/calculate_version.sh +++ b/scripts/calculate_version.sh @@ -17,22 +17,16 @@ fi git fetch --tags -if [ $BRANCH = "master" ] +if [ $BRANCH = "stable" ] then echo $VERSION exit 0 fi LABEL="develop" -if [ $BRANCH = "stable" ] -then - LABEL="stable" -elif [ $BRANCH = "beta" ] +if [ $BRANCH = "beta" ] then LABEL="beta" -elif [ $BRANCH = "syncnode_develop" ] -then - LABEL="sync" fi for (( VERSION_NUMBER=0; ; VERSION_NUMBER++ )) From 4df65429abfe61fbdcbdbd3f0b341e5201f6e714 Mon Sep 17 00:00:00 2001 From: Dmytro Nazarenko Date: Tue, 31 Jan 2023 20:57:13 +0200 Subject: [PATCH 05/19] Update publish.yml --- .github/workflows/publish.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ab9e4d847..6f4062e96 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -153,6 +153,8 @@ jobs: export VERSION=$(bash ./scripts/calculate_version.sh $BRANCH $VERSION) echo "::set-env name=VERSION::$VERSION" echo "Version $VERSION" + ( test $BRANCH = "stable" && export PRERELEASE=false ) || export PRERELEASE=true + echo "PRERELEASE=$PRERELEASE" >> $GITHUB_ENV export RELEASE=true echo "::set-env name=RELEASE::$RELEASE" bash ./scripts/build_and_publish.sh @@ -165,7 +167,7 @@ jobs: tag_name: ${{ env.VERSION }} release_name: ${{ env.VERSION }} draft: false - prerelease: true + prerelease: ${{ env.PRERELEASE }} - name: Upload skaled binary to Release uses: actions/upload-release-asset@latest env: From 7ce3a89dda38e0e45856bc0f911143f7e5ad3ddb Mon Sep 17 00:00:00 2001 From: Dmytro Nazarenko Date: Mon, 20 Mar 2023 15:02:05 +0200 Subject: [PATCH 06/19] Update VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3f67e25ce..ffaa55f59 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.17.0 +3.16.1 From 12a4f41566b53cfae7417448756346f34ccbfe57 Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Mon, 20 Mar 2023 14:18:47 +0200 Subject: [PATCH 07/19] Instructions for 20.04 in README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6e625db81..90c4f2b12 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Historically skaled started by forking [Aleth](https://github.com/ethereum/aleth ### OS requirements -Skaled builds and runs on Ubuntu 16.04 and 18.04 +Skaled builds and runs on Ubuntu 20.04 and 22.04 ### Clone repository @@ -59,12 +59,12 @@ If you have already cloned the repo and forgot to pass `--recurse-submodules`, e ``` sudo apt update sudo apt install autoconf build-essential cmake libprocps-dev libtool texinfo wget yasm flex bison btrfs-progs -sudo apt install make build-essential cmake pkg-config libgnutls28-dev libssl-dev unzip zlib1g-dev libgcrypt20-dev docker.io gprof gcc-9 g++-9 +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 ``` NB cmake needs to be of version >=3.31, git of version >=2.18 -### Set gcc-9 as default compiler +### (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 @@ -92,6 +92,7 @@ cd deps ## 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 ``` From 924fc283d84cbaab9085be64a58fcac23e68cc6d Mon Sep 17 00:00:00 2001 From: DmytroNazarenko Date: Mon, 20 Mar 2023 18:24:35 +0000 Subject: [PATCH 08/19] Fix cached_filestorage test --- test/unittests/libweb3jsonrpc/jsonrpc.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/unittests/libweb3jsonrpc/jsonrpc.cpp b/test/unittests/libweb3jsonrpc/jsonrpc.cpp index 5440023a9..f821a7775 100644 --- a/test/unittests/libweb3jsonrpc/jsonrpc.cpp +++ b/test/unittests/libweb3jsonrpc/jsonrpc.cpp @@ -2898,7 +2898,14 @@ BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE( FilestorageCacheSuite ) BOOST_AUTO_TEST_CASE( cached_filestorage ) { - RestrictedAddressFixture fixture( c_genesisConfigString ); + + auto _config = c_genesisConfigString; + Json::Value ret; + Json::Reader().parse( _config, ret ); + ret["skaleConfig"]["sChain"]["revertableFSPatchTimestamp"] = 1; + Json::FastWriter fastWriter; + std::string config = fastWriter.write( ret ); + RestrictedAddressFixture fixture( config ); auto senderAddress = fixture.coinbase.address(); fixture.client->setAuthor( senderAddress ); From 1268fc9104ae8bf2269cc311bc52f9582c71f5f6 Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Tue, 21 Mar 2023 15:46:10 +0000 Subject: [PATCH 09/19] SKALED-1455 Add -f option in btrfs command as required --- libskutils/src/btrfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libskutils/src/btrfs.c b/libskutils/src/btrfs.c index 16af2cc1c..9ee6ddf01 100644 --- a/libskutils/src/btrfs.c +++ b/libskutils/src/btrfs.c @@ -189,7 +189,7 @@ int btrfs_send(const char* parent, const char* file, const char* vol){ } int btrfs_subvolume_property_set(const char* path, const char* name, const char* value){ - char fmt[] = "btrfs property set -ts %s %s %s"; + char fmt[] = "btrfs property set -ts -f %s %s %s"; int len = 1 + snprintf(NULL, 0, fmt, path, name, value); From cf4f0bea070c2b90d6be123dd86b7a25a978e794 Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Tue, 21 Mar 2023 19:40:41 +0000 Subject: [PATCH 10/19] SKALED-1455 Use Ubuntu 20.04 in Dockerfile --- scripts/skale_build/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/skale_build/Dockerfile b/scripts/skale_build/Dockerfile index 28641df6f..fb78090be 100644 --- a/scripts/skale_build/Dockerfile +++ b/scripts/skale_build/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:20.04 RUN apt-get -q update && \ apt-get -qy install \ From 84e41a6d86b861cc6eb257df4a7b12b107024e6b Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Wed, 22 Mar 2023 11:54:48 +0000 Subject: [PATCH 11/19] SKALED-1455 Fix tzdata --- scripts/skale_build/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/skale_build/Dockerfile b/scripts/skale_build/Dockerfile index fb78090be..002020c05 100644 --- a/scripts/skale_build/Dockerfile +++ b/scripts/skale_build/Dockerfile @@ -1,4 +1,5 @@ FROM ubuntu:20.04 +ENV DEBIAN_FRONTEND=noninteractive RUN apt-get -q update && \ apt-get -qy install \ From 5299dc4368a7d2dc2e187cb20525a821c39add23 Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Thu, 23 Mar 2023 17:15:30 +0000 Subject: [PATCH 12/19] SKALED-1455 Automatically check btrfs-progs version --- libskutils/include/skutils/btrfs.h | 3 ++- libskutils/src/btrfs.c | 32 ++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/libskutils/include/skutils/btrfs.h b/libskutils/include/skutils/btrfs.h index 4aedd2567..63df60cc4 100644 --- a/libskutils/include/skutils/btrfs.h +++ b/libskutils/include/skutils/btrfs.h @@ -2,16 +2,17 @@ typedef struct { const char* ( *strerror )(); const char* ( *last_cmd )(); int ( *present )( const char* path ); + const char* ( *version )(); struct { int ( *list )( const char* path ); int ( *create )( const char* path ); int ( *_delete )( const char* path ); int ( *snapshot )( const char* from, const char* to ); int ( *snapshot_r )( const char* from, const char* to ); + int ( *property_set )( const char* path, const char* name, const char* value ); } subvolume; int ( *receive )( const char* file, const char* path ); int ( *send )( const char* parent, const char* file, const char* vol ); - int ( *btrfs_subvolume_property_set )( const char* path, const char* name, const char* value ); } btrfs_t; extern btrfs_t btrfs; diff --git a/libskutils/src/btrfs.c b/libskutils/src/btrfs.c index 9ee6ddf01..afb816207 100644 --- a/libskutils/src/btrfs.c +++ b/libskutils/src/btrfs.c @@ -7,6 +7,7 @@ static _Thread_local char errbuf[256]; static _Thread_local char last_cmd[256]; +static _Thread_local int need_f = -1; // 0 false, 1 true, -1 unknown static int shell_call(const char* cmd){ @@ -55,6 +56,12 @@ const char* btrfs_last_cmd(){ return last_cmd; } +const char* btrfs_version(){ + int res = shell_call("btrfs --version"); + if( res != 0 ) + return NULL; + return errbuf; +} int btrfs_present(const char* path){ const char fmt[] = "btrfs filesystem df %s"; @@ -189,7 +196,28 @@ int btrfs_send(const char* parent, const char* file, const char* vol){ } int btrfs_subvolume_property_set(const char* path, const char* name, const char* value){ - char fmt[] = "btrfs property set -ts -f %s %s %s"; + char* fmt; + + // check version if needed + if(need_f == -1){ + + const char* ver = btrfs_version(); + if(ver==NULL) + return -1; + + int v1,v2,v3; + int res = sscanf(ver, "btrfs-progs v%d.%d.%d", &v1, &v2, &v3); + if(res != 3) + return -1; + + // check v5.14.2 or higher + need_f = v1>5 || (v1==5 && (v2>14 || (v2==14 && v3>=2))); + }// if -1 + + if(need_f) + fmt = "btrfs property set -ts -f %s %s %s"; + else + fmt = "btrfs property set -ts %s %s %s"; int len = 1 + snprintf(NULL, 0, fmt, path, name, value); @@ -202,4 +230,4 @@ int btrfs_subvolume_property_set(const char* path, const char* name, const char* return res; } -btrfs_t btrfs = {btrfs_strerror, btrfs_last_cmd, btrfs_present, {btrfs_subvolume_list, btrfs_subvolume_create, btrfs_subvolume_delete, btrfs_subvolume_snapshot, btrfs_subvolume_snapshot_r}, btrfs_receive, btrfs_send, btrfs_subvolume_property_set}; +btrfs_t btrfs = {btrfs_strerror, btrfs_last_cmd, btrfs_present, btrfs_version, {btrfs_subvolume_list, btrfs_subvolume_create, btrfs_subvolume_delete, btrfs_subvolume_snapshot, btrfs_subvolume_snapshot_r, btrfs_subvolume_property_set}, btrfs_receive, btrfs_send}; From 6625516f46afc28572aba428ed06bc5f094ef357 Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Fri, 24 Mar 2023 10:09:38 +0000 Subject: [PATCH 13/19] SKALED-1455 Fix dependencies from btrfs.c in SnapshotManager --- libskale/SnapshotManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libskale/SnapshotManager.cpp b/libskale/SnapshotManager.cpp index 553fa6a73..970a15d31 100644 --- a/libskale/SnapshotManager.cpp +++ b/libskale/SnapshotManager.cpp @@ -648,7 +648,7 @@ void SnapshotManager::computeSnapshotHash( unsigned _blockNumber, bool is_checki int dummy_counter = 0; for ( const auto& volume : this->volumes ) { - int res = btrfs.btrfs_subvolume_property_set( + int res = btrfs.subvolume.property_set( ( this->snapshots_dir / std::to_string( _blockNumber ) / volume ).string().c_str(), "ro", "false" ); @@ -663,7 +663,7 @@ void SnapshotManager::computeSnapshotHash( unsigned _blockNumber, bool is_checki this->computeAllVolumesHash( _blockNumber, &ctx, is_checking ); for ( const auto& volume : this->volumes ) { - int res = btrfs.btrfs_subvolume_property_set( + int res = btrfs.subvolume.property_set( ( this->snapshots_dir / std::to_string( _blockNumber ) / volume ).string().c_str(), "ro", "true" ); @@ -701,7 +701,7 @@ uint64_t SnapshotManager::getBlockTimestamp( fs::path db_dir = this->snapshots_dir / std::to_string( _blockNumber ); - int res = btrfs.btrfs_subvolume_property_set( + int res = btrfs.subvolume.property_set( ( db_dir / this->volumes[0] ).string().c_str(), "ro", "false" ); if ( res != 0 ) { @@ -713,7 +713,7 @@ uint64_t SnapshotManager::getBlockTimestamp( uint64_t timestamp = dev::eth::BlockHeader( bc.block( hash ) ).timestamp(); - res = btrfs.btrfs_subvolume_property_set( + res = btrfs.subvolume.property_set( ( db_dir / this->volumes[0] ).string().c_str(), "ro", "true" ); if ( res != 0 ) { From 897c57af2d2debcf3adae84497788872e9730631 Mon Sep 17 00:00:00 2001 From: Oleh Nikolaiev Date: Fri, 24 Mar 2023 16:06:19 +0000 Subject: [PATCH 14/19] add missing tests to github pipeline --- .github/workflows/test.yml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a0f49551..f3cda41d7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -164,11 +164,17 @@ jobs: export NO_ULIMIT_CHECK=1 # we specifically run each test for easier log review ./testeth -t BlockchainTests -- --express && touch /tmp/BlockchainTestsPassed + ./testeth -t TransitionTests -- --express && touch /tmp/TransitionTestsPassed ./testeth -t TransactionTests -- --express && touch /tmp/TransactionTestsPassed ./testeth -t VMTests -- --express && touch /tmp/VMTestsPassed ./testeth -t LevelDBTests -- --express && touch /tmp/LevelDBTestsPassed + ./testeth -t CoreLibTests -- --express && touch /tmp/CoreLibTestsPassed + ./testeth -t RlpTests -- --express && touch /tmp/RlpTestsPassed ./testeth -t SharedSpaceTests -- --express && touch /tmp/SharedSpaceTestsPassed - ./testeth -t SealEngineTests -- --express && touch /tmp/SealEngineTestsPassed + ./testeth -t EthashTests -- --express && touch /tmp/EthashTestsPassed + ./testeth -t SealEngineTests -- --express && touch /tmp/SealEngineTestsPassed + ./testeth -t DifficultyTests -- --express && touch /tmp/DifficultyTestsPassed + ./testeth -t BlockSuite -- --express && touch /tmp/BlockSuitePassed ./testeth -t BlockChainMainNetworkSuite -- --express && touch /tmp/BlockChainMainNetworkSuitePassed ./testeth -t BlockChainFrontierSuite -- --express && touch /tmp/BlockChainFrontierSuitePassed ./testeth -t BlockQueueSuite -- --express && touch /tmp/BlockQueueSuitePassed @@ -198,6 +204,9 @@ jobs: ./testeth -t JsonRpcSuite -- --express && touch /tmp/JsonRpcSuitePassed ./testeth -t SingleConsensusTests -- --express && touch /tmp/SingleConsensusTestsPassed ./testeth -t ConsensusTests -- --express && touch /tmp/ConsensusTestsPassed + sudo ./testeth -t BtrfsTestSuite -- --all && touch /tmp/BtrfsTestSuitePassed + sudo ./testeth -t HashSnapshotTestSuite -- --all && touch /tmp/HashSnapshotTestSuitePassed + sudo ./testeth -t ClientSnapshotsSuite -- --all && touch /tmp/ClientSnapshotsSuitePassed cd .. - name: Testeth verbosity 4 run : | @@ -206,11 +215,17 @@ jobs: export NO_NTP_CHECK=1 export NO_ULIMIT_CHECK=1 ls /tmp/BlockchainTestsPassed || ./testeth -t BlockchainTests -- --express --verbosity 4 + ls /tmp/TransitionTestsPassed || ./testeth -t TransitionTests -- --express --verbosity 4 ls /tmp/TransactionTestsPassed || ./testeth -t TransactionTests -- --express --verbosity 4 ls /tmp/VMTestsPassed || ./testeth -t VMTests -- --express --verbosity 4 ls /tmp/LevelDBTestsPassed || ./testeth -t LevelDBTests -- --express --verbosity 4 + ls /tmp/CoreLibTestsPassed || ./testeth -t CoreLibTests -- --express --verbosity 4 + ls /tmp/RlpTestsPassed || ./testeth -t RlpTests -- --express --verbosity 4 ls /tmp/SharedSpaceTestsPassed || ./testeth -t SharedSpaceTests -- --express --verbosity 4 + ls /tmp/EthashTestsPassed || ./testeth -t EthashTests -- --express --verbosity 4 ls /tmp/SealEngineTestsPassed || ./testeth -t SealEngineTests -- --express --verbosity 4 + ls /tmp/DifficultyTestsPassed || ./testeth -t DifficultyTests -- --express --verbosity 4 + ls /tmp/BlockSuitePassed || ./testeth -t BlockSuite -- --express --verbosity 4 ls /tmp/BlockChainMainNetworkSuitePassed || ./testeth -t BlockChainMainNetworkSuite -- --express --verbosity 4 ls /tmp/BlockChainFrontierSuitePassed || ./testeth -t BlockChainFrontierSuite -- --express --verbosity 4 ls /tmp/BlockQueueSuitePassed || ./testeth -t BlockQueueSuite -- --express --verbosity 4 @@ -239,7 +254,10 @@ jobs: ls /tmp/ClientTestsPassed || ./testeth -t ClientTests -- --express --verbosity 4 ls /tmp/JsonRpcSuitePassed || ./testeth -t JsonRpcSuite -- --express --verbosity 4 ls /tmp/SingleConsensusTestsPassed || ./testeth -t SingleConsensusTests -- --express --verbosity 4 - ls /tmp/ConsensusTestsPassed || ./testeth -t ConsensusTests -- --express --verbosity 4 + ls /tmp/ConsensusTestsPassed || ./testeth -t ConsensusTests -- --express --verbosity 4 + ls /tmp/BtrfsTestSuitePassed || sudo NO_ULIMIT_CHECK=1 NO_NTP_CHECK=1 ./testeth -t BtrfsTestSuite -- --all --verbosity 4 + ls /tmp/HashSnapshotTestSuitePassed || sudo NO_ULIMIT_CHECK=1 NO_NTP_CHECK=1 ./testeth -t HashSnapshotTestSuite -- --all --verbosity 4 + ls /tmp/ClientSnapshotsSuitePassed || sudo NO_ULIMIT_CHECK=1 NO_NTP_CHECK=1 ./testeth -t ClientSnapshotsSuite -- --all --verbosity 4 cd .. - name: Configure all as historic run: | From 42062371ff90e3f7c43c28d26fc6ca0a0826614c Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Fri, 24 Mar 2023 16:42:50 +0000 Subject: [PATCH 15/19] SKALED-1467 clang-format-11 --- .github/workflows/clang-format-check.yml | 2 +- README.md | 2 +- cmake/FindClangFormat.cmake | 2 +- libdevcore/Common.h | 8 +- libdevcore/CommonData.cpp | 2 +- libdevcore/CommonData.h | 4 +- libdevcore/CommonIO.h | 7 +- libdevcore/RLP.cpp | 14 +-- libdevcore/microprofile.cpp | 22 ++--- libdevcore/microprofile.h | 4 +- libdevcore/miniz.h | 18 ++-- libdevcrypto/SecretStore.cpp | 6 +- libethashseal/Ethash.cpp | 2 +- libethashseal/EthashCPUMiner.cpp | 2 +- libethereum/Block.h | 24 +++-- libethereum/BlockChain.cpp | 10 ++- libethereum/BlockQueue.cpp | 12 ++- libethereum/Client.cpp | 22 +++-- libethereum/Client.h | 108 +++++++++++++++++------ libethereum/ClientBase.cpp | 2 +- libethereum/ClientBase.h | 4 +- libethereum/Executive.cpp | 2 +- libethereum/Interface.h | 36 ++++++-- libethereum/TransactionQueue.h | 4 +- libevm/LegacyVM.cpp | 10 ++- libevm/LegacyVM.h | 8 +- libevm/LegacyVMCalls.cpp | 2 +- libhistoric/AlethExecutive.cpp | 2 +- libhistoric/HistoricState.cpp | 3 +- libskale-interpreter/VM.cpp | 10 ++- libskale-interpreter/VMCalls.cpp | 2 +- libskale/State.cpp | 3 +- libskale/State.h | 16 +++- libskale/httpserveroverride.cpp | 2 +- libskutils/include/skutils/dispatch.h | 4 +- libskutils/include/skutils/http.h | 8 +- libskutils/include/skutils/rest_call.h | 4 +- libskutils/src/http.cpp | 2 +- libskutils/src/rest_call.cpp | 3 +- libskutils/src/utils.cpp | 10 +-- libweb3jsonrpc/IpcServerBase.cpp | 2 +- skaled/main.cpp | 2 +- 42 files changed, 266 insertions(+), 146 deletions(-) diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index cd8a9218e..e0f1ec5b4 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -11,4 +11,4 @@ jobs: source: '.' exclude: './CMakeFiles ./cmake ./deps ./build ./skaled_ssl_test ./newer_lcov' extensions: 'h,hpp,hxx,cpp,cxx,cc,ipp' - clangFormatVersion: 10 \ No newline at end of file + clangFormatVersion: 11 diff --git a/README.md b/README.md index 90c4f2b12..e20d1df9f 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ If you have already cloned the repo and forgot to pass `--recurse-submodules`, e ``` sudo apt update sudo apt install autoconf build-essential cmake libprocps-dev libtool texinfo wget yasm flex bison btrfs-progs -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 +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 ``` NB cmake needs to be of version >=3.31, git of version >=2.18 diff --git a/cmake/FindClangFormat.cmake b/cmake/FindClangFormat.cmake index 4c5d4d878..f58de1805 100644 --- a/cmake/FindClangFormat.cmake +++ b/cmake/FindClangFormat.cmake @@ -7,7 +7,7 @@ if( ( NOT DEFINED CLANG_FORMAT_BIN_NAME ) OR ( "${CLANG_FORMAT_BIN_NAME}" STREQU # unset( CLANG_FORMAT_FOUND ) unset( CLANG_FORMAT_BIN_NAME ) - set( VARIANTS_OF_CLANG_FORMAT_BIN_NAME clang-format-10 clang-format ) + set( VARIANTS_OF_CLANG_FORMAT_BIN_NAME clang-format-11 clang-format ) foreach( CLANG_FORMAT_WALK_VAR IN LISTS VARIANTS_OF_CLANG_FORMAT_BIN_NAME ) execute_process( COMMAND bash -c "which ${CLANG_FORMAT_WALK_VAR}" OUTPUT_VARIABLE CLANG_FORMAT_BIN_NAME ) if( ( DEFINED CLANG_FORMAT_BIN_NAME ) AND ( NOT "${CLANG_FORMAT_BIN_NAME}" STREQUAL "" ) ) diff --git a/libdevcore/Common.h b/libdevcore/Common.h index b1203c377..40e8867fb 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -300,8 +300,8 @@ class Timer { std::chrono::high_resolution_clock::time_point m_t; }; -#define DEV_TIMED( S ) \ - for ( ::std::pair<::dev::TimerHelper, bool > __eth_t( S, true ); __eth_t.second; \ +#define DEV_TIMED( S ) \ + for ( ::std::pair< ::dev::TimerHelper, bool > __eth_t( S, true ); __eth_t.second; \ __eth_t.second = false ) #define DEV_TIMED_SCOPE( S ) ::dev::TimerHelper __eth_t( S ) #if defined( _WIN32 ) @@ -310,8 +310,8 @@ class Timer { #define DEV_TIMED_FUNCTION DEV_TIMED_SCOPE( __PRETTY_FUNCTION__ ) #endif -#define DEV_TIMED_ABOVE( S, MS ) \ - for ( ::std::pair<::dev::TimerHelper, bool > __eth_t( ::dev::TimerHelper( S, MS ), true ); \ +#define DEV_TIMED_ABOVE( S, MS ) \ + for ( ::std::pair< ::dev::TimerHelper, bool > __eth_t( ::dev::TimerHelper( S, MS ), true ); \ __eth_t.second; __eth_t.second = false ) #define DEV_TIMED_SCOPE_ABOVE( S, MS ) ::dev::TimerHelper __eth_t( S, MS ) #if defined( _WIN32 ) diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp index 16911de42..0ec32aa18 100644 --- a/libdevcore/CommonData.cpp +++ b/libdevcore/CommonData.cpp @@ -91,7 +91,7 @@ bytes dev::fromHex( std::string const& _s, WhenError _throw ) { int h = fromHexChar( _s[i] ); int l = fromHexChar( _s[i + 1] ); if ( h != -1 && l != -1 ) - ret.push_back( ( _byte_ )( h * 16 + l ) ); + ret.push_back( ( _byte_ ) ( h * 16 + l ) ); else if ( _throw == WhenError::Throw ) BOOST_THROW_EXCEPTION( BadHexCharacter() ); else diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index fa896be69..44bcdc563 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -137,8 +137,8 @@ template < class T, class _In > inline T fromBigEndian( _In const& _bytes ) { T ret = ( T ) 0; for ( auto i : _bytes ) - ret = ( T )( - ( ret << 8 ) | ( _byte_ )( typename std::make_unsigned< decltype( i ) >::type ) i ); + ret = ( T ) ( ( ret << 8 ) | + ( _byte_ ) ( typename std::make_unsigned< decltype( i ) >::type ) i ); return ret; } diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 9e066f1ac..0ce76d12f 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -134,9 +134,10 @@ inline std::string toString( char buffer[1024]; if ( strftime( buffer, sizeof( buffer ), _format.c_str(), &timeValue ) ) return std::string( buffer ) + "." + - ( millisRemainder < 1 ? - "000" : - millisRemainder < 10 ? "00" : millisRemainder < 100 ? "0" : "" ) + + ( millisRemainder < 1 ? "000" : + millisRemainder < 10 ? "00" : + millisRemainder < 100 ? "0" : + "" ) + std::to_string( millisRemainder ) + "Z"; return std::string(); } diff --git a/libdevcore/RLP.cpp b/libdevcore/RLP.cpp index 8bbd3e2fe..74516b9d5 100644 --- a/libdevcore/RLP.cpp +++ b/libdevcore/RLP.cpp @@ -241,9 +241,9 @@ void RLPStream::noteAppended( size_t _itemCount ) { m_out.resize( os + encodeSize ); memmove( m_out.data() + p + encodeSize, m_out.data() + p, os - p ); if ( s < c_rlpListImmLenCount ) - m_out[p] = ( _byte_ )( c_rlpListStart + s ); + m_out[p] = ( _byte_ ) ( c_rlpListStart + s ); else if ( c_rlpListIndLenZero + brs <= 0xff ) { - m_out[p] = ( _byte_ )( c_rlpListIndLenZero + brs ); + m_out[p] = ( _byte_ ) ( c_rlpListIndLenZero + brs ); _byte_* b = &( m_out[p + brs] ); for ( ; s; s >>= 8 ) *( b-- ) = ( _byte_ ) s; @@ -267,7 +267,7 @@ RLPStream& RLPStream::appendList( size_t _items ) { RLPStream& RLPStream::appendList( bytesConstRef _rlp ) { if ( _rlp.size() < c_rlpListImmLenCount ) - m_out.push_back( ( _byte_ )( _rlp.size() + c_rlpListStart ) ); + m_out.push_back( ( _byte_ ) ( _rlp.size() + c_rlpListStart ) ); else pushCount( _rlp.size(), c_rlpListIndLenZero ); appendRaw( _rlp, 1 ); @@ -285,7 +285,7 @@ RLPStream& RLPStream::append( bytesConstRef _s, bool _compact ) { m_out.push_back( *d ); else { if ( s < c_rlpDataImmLenCount ) - m_out.push_back( ( _byte_ )( s + c_rlpDataImmLenStart ) ); + m_out.push_back( ( _byte_ ) ( s + c_rlpDataImmLenStart ) ); else pushCount( s, c_rlpDataIndLenZero ); appendRaw( bytesConstRef( d, s ), 0 ); @@ -302,13 +302,13 @@ RLPStream& RLPStream::append( bigint _i ) { else { unsigned br = bytesRequired( _i ); if ( br < c_rlpDataImmLenCount ) - m_out.push_back( ( _byte_ )( br + c_rlpDataImmLenStart ) ); + m_out.push_back( ( _byte_ ) ( br + c_rlpDataImmLenStart ) ); else { auto brbr = bytesRequired( br ); if ( c_rlpDataIndLenZero + brbr > 0xff ) BOOST_THROW_EXCEPTION( RLPException() << errinfo_comment( "Number too large for RLP" ) ); - m_out.push_back( ( _byte_ )( c_rlpDataIndLenZero + brbr ) ); + m_out.push_back( ( _byte_ ) ( c_rlpDataIndLenZero + brbr ) ); pushInt( br, brbr ); } pushInt( _i, br ); @@ -321,7 +321,7 @@ void RLPStream::pushCount( size_t _count, _byte_ _base ) { auto br = bytesRequired( _count ); if ( int( br ) + _base > 0xff ) BOOST_THROW_EXCEPTION( RLPException() << errinfo_comment( "Count too large for RLP" ) ); - m_out.push_back( ( _byte_ )( br + _base ) ); // max 8 bytes. + m_out.push_back( ( _byte_ ) ( br + _base ) ); // max 8 bytes. pushInt( _count, br ); } diff --git a/libdevcore/microprofile.cpp b/libdevcore/microprofile.cpp index b54078a8b..3cf1afd89 100644 --- a/libdevcore/microprofile.cpp +++ b/libdevcore/microprofile.cpp @@ -755,10 +755,10 @@ inline uint16_t MicroProfileGetTimerIndex( MicroProfileToken t ) { return ( t & 0xffff ); } inline uint32_t MicroProfileGetGroupMask( MicroProfileToken t ) { - return ( uint32_t )( ( t >> 16 ) & MICROPROFILE_GROUP_MASK_ALL ); + return ( uint32_t ) ( ( t >> 16 ) & MICROPROFILE_GROUP_MASK_ALL ); } inline uint32_t MicroProfileGetGroupMaskIndex( MicroProfileToken t ) { - return ( uint32_t )( t >> 48 ); + return ( uint32_t ) ( t >> 48 ); } @@ -782,7 +782,7 @@ T MicroProfileClamp( T a, T min_, T max_ ) { } inline int64_t MicroProfileMsToTick( float fMs, int64_t nTicksPerSecond ) { - return ( int64_t )( fMs * 0.001f * nTicksPerSecond ); + return ( int64_t ) ( fMs * 0.001f * nTicksPerSecond ); } inline float MicroProfileTickToMsMultiplier( int64_t nTicksPerSecond ) { @@ -846,7 +846,7 @@ void MicroProfileThreadJoin( MicroProfileThread* pThread ) { typedef HANDLE MicroProfileThread; DWORD _stdcall ThreadTrampoline( void* pFunc ) { MicroProfileThreadFunc F = ( MicroProfileThreadFunc ) pFunc; - return ( uint32_t )( uintptr_t ) F( 0 ); + return ( uint32_t ) ( uintptr_t ) F( 0 ); } void MicroProfileThreadStart( MicroProfileThread* pThread, MicroProfileThreadFunc Func ) { @@ -1367,7 +1367,7 @@ MicroProfileToken MicroProfileGetToken( if ( ret != MICROPROFILE_INVALID_TOKEN ) return ret; uint16_t nGroupIndex = MicroProfileGetGroup( pGroup, Type ); - uint16_t nTimerIndex = ( uint16_t )( S.nTotalTimers++ ); + uint16_t nTimerIndex = ( uint16_t ) ( S.nTotalTimers++ ); MP_ASSERT( nTimerIndex < MICROPROFILE_MAX_TIMERS ); uint32_t nBitIndex = nGroupIndex / 32; @@ -1452,7 +1452,7 @@ const char* MicroProfileCounterFullName( int nCounter ) { int nOffset = 0; while ( nIndex >= 0 && nOffset < ( int ) sizeof( Buffer ) - 2 ) { uint32_t nLen = S.CounterInfo[nNodes[nIndex]].nNameLen + nOffset; // < sizeof(Buffer)-1 - nLen = MicroProfileMin( ( uint32_t )( sizeof( Buffer ) - 2 - nOffset ), nLen ); + nLen = MicroProfileMin( ( uint32_t ) ( sizeof( Buffer ) - 2 - nOffset ), nLen ); memcpy( &Buffer[nOffset], S.CounterInfo[nNodes[nIndex]].pName, nLen ); nOffset += S.CounterInfo[nNodes[nIndex]].nNameLen + 1; @@ -5663,7 +5663,7 @@ const char* MicroProfileWin32ThreadInfoAddString( const char* pString ) { if ( 0 == g_ThreadInfo.pStrings[idx] ) { g_ThreadInfo.pStrings[idx] = &g_ThreadInfo.StringData[g_ThreadInfo.nStringOffset]; memcpy( &g_ThreadInfo.StringData[g_ThreadInfo.nStringOffset], pString, nLen + 1 ); - g_ThreadInfo.nStringOffset += ( uint32_t )( nLen + 1 ); + g_ThreadInfo.nStringOffset += ( uint32_t ) ( nLen + 1 ); return g_ThreadInfo.pStrings[idx]; } if ( 0 == strcmp( g_ThreadInfo.pStrings[idx], pString ) ) { @@ -5996,7 +5996,7 @@ void* MicroProfileTraceThread( void* unused ) { gettimeofday( &tv, NULL ); uint64_t nsSinceEpoch = - ( ( uint64_t )( tv.tv_sec ) * 1000000 + ( uint64_t )( tv.tv_usec ) ) * 1000; + ( ( uint64_t ) ( tv.tv_sec ) * 1000000 + ( uint64_t ) ( tv.tv_usec ) ) * 1000; uint64_t nTickEpoch = MP_TICK(); uint32_t nLastThread[MICROPROFILE_MAX_CONTEXT_SWITCH_THREADS] = { 0 }; mach_timebase_info_data_t sTimebaseInfo; @@ -6306,7 +6306,7 @@ void MicroProfileGpuWaitFence( uint32_t nNode, uint64_t nFence ) { uint64_t nCompletedFrame = S.pGPU->NodeState[nNode].pFence->GetCompletedValue(); // while(nCompletedFrame < nPending) // while(0 < nPending - nCompletedFrame) - while ( 0 < ( int64_t )( nFence - nCompletedFrame ) ) { + while ( 0 < ( int64_t ) ( nFence - nCompletedFrame ) ) { MICROPROFILE_SCOPEI( "Microprofile", "gpu-wait", MP_GREEN4 ); Sleep( 20 ); // todo: use event. nCompletedFrame = S.pGPU->NodeState[nNode].pFence->GetCompletedValue(); @@ -6317,7 +6317,7 @@ void MicroProfileGpuFetchResults( uint64_t nFrame ) { uint64_t nPending = S.pGPU->nPendingFrame; // while(nPending <= nFrame) // while(0 <= nFrame - nPending) - while ( 0 <= ( int64_t )( nFrame - nPending ) ) { + while ( 0 <= ( int64_t ) ( nFrame - nPending ) ) { uint32_t nInternal = nPending % MICROPROFILE_D3D_INTERNAL_DELAY; uint32_t nNode = S.pGPU->Frames[nInternal].nNode; MicroProfileGpuWaitFence( nNode, nPending ); @@ -6610,7 +6610,7 @@ void MicroProfileGpuFetchResults( VkCommandBuffer Buffer, uint64_t nFrame ) { uint64_t nPending = S.pGPU->nPendingFrame; // while(nPending <= nFrame) // while(0 <= nFrame - nPending) - while ( 0 <= ( int64_t )( nFrame - nPending ) ) { + while ( 0 <= ( int64_t ) ( nFrame - nPending ) ) { uint32_t nInternal = nPending % MICROPROFILE_VULKAN_INTERNAL_DELAY; uint32_t nNode = S.pGPU->Frames[nInternal].nNode; MicroProfileGpuWaitFence( nNode, nInternal ); diff --git a/libdevcore/microprofile.h b/libdevcore/microprofile.h index ea3aae9b1..62f466a74 100644 --- a/libdevcore/microprofile.h +++ b/libdevcore/microprofile.h @@ -491,7 +491,7 @@ typedef uint64_t MicroProfileThreadIdType; #define MICROPROFILE_COUNTER_LOCAL_ADD( var, count ) \ MicroProfileLocalCounterAdd( &g_mp_local_counter##var, ( count ) ) #define MICROPROFILE_COUNTER_LOCAL_SUB( var, count ) \ - MicroProfileLocalCounterAdd( &g_mp_local_counter##var, -( int64_t )( count ) ) + MicroProfileLocalCounterAdd( &g_mp_local_counter##var, -( int64_t ) ( count ) ) #define MICROPROFILE_COUNTER_LOCAL_SET( var, count ) \ MicroProfileLocalCounterSet( &g_mp_local_counter##var, count ) #define MICROPROFILE_COUNTER_LOCAL_UPDATE_ADD( var ) \ @@ -503,7 +503,7 @@ typedef uint64_t MicroProfileThreadIdType; #define MICROPROFILE_COUNTER_LOCAL_ADD_ATOMIC( var, count ) \ MicroProfileLocalCounterAddAtomic( &g_mp_local_counter##var, ( count ) ) #define MICROPROFILE_COUNTER_LOCAL_SUB_ATOMIC( var, count ) \ - MicroProfileLocalCounterAddAtomic( &g_mp_local_counter##var, -( int64_t )( count ) ) + MicroProfileLocalCounterAddAtomic( &g_mp_local_counter##var, -( int64_t ) ( count ) ) #define MICROPROFILE_COUNTER_LOCAL_SET_ATOMIC( var, count ) \ MicroProfileLocalCounterSetAtomic( &g_mp_local_counter##var, count ) #define MICROPROFILE_COUNTER_LOCAL_UPDATE_ADD_ATOMIC( var ) \ diff --git a/libdevcore/miniz.h b/libdevcore/miniz.h index 91b717452..faf54532d 100644 --- a/libdevcore/miniz.h +++ b/libdevcore/miniz.h @@ -569,14 +569,14 @@ typedef struct mz_dummy_time_t_tag { #define MZ_READ_LE16( p ) *( ( const mz_uint16* ) ( p ) ) #define MZ_READ_LE32( p ) *( ( const mz_uint32* ) ( p ) ) #else -#define MZ_READ_LE16( p ) \ - ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[0] ) | \ - ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[1] ) << 8U ) ) -#define MZ_READ_LE32( p ) \ - ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[0] ) | \ - ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[1] ) << 8U ) | \ - ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[2] ) << 16U ) | \ - ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[3] ) << 24U ) ) +#define MZ_READ_LE16( p ) \ + ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[0] ) | \ + ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[1] ) << 8U ) ) +#define MZ_READ_LE32( p ) \ + ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[0] ) | \ + ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[1] ) << 8U ) | \ + ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[2] ) << 16U ) | \ + ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[3] ) << 24U ) ) #endif #define MZ_READ_LE64( p ) \ @@ -858,7 +858,7 @@ void* tinfl_decompress_mem_to_heap( /* tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. */ /* Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. */ -#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ( ( size_t )( -1 ) ) +#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ( ( size_t ) ( -1 ) ) size_t tinfl_decompress_mem_to_mem( void* pOut_buf, size_t out_buf_len, const void* pSrc_buf, size_t src_buf_len, int flags ); diff --git a/libdevcrypto/SecretStore.cpp b/libdevcrypto/SecretStore.cpp index 6814e79d4..cbb209e72 100644 --- a/libdevcrypto/SecretStore.cpp +++ b/libdevcrypto/SecretStore.cpp @@ -46,9 +46,9 @@ static js::mValue upgraded( string const& _s ) { if ( v.type() != js::obj_type ) return js::mValue(); js::mObject ret = v.get_obj(); - unsigned version = ret.count( "Version" ) ? - stoi( ret["Version"].get_str() ) : - ret.count( "version" ) ? ret["version"].get_int() : 0; + unsigned version = ret.count( "Version" ) ? stoi( ret["Version"].get_str() ) : + ret.count( "version" ) ? ret["version"].get_int() : + 0; if ( version == 1 ) { // upgrade to version 2 js::mObject old; diff --git a/libethashseal/Ethash.cpp b/libethashseal/Ethash.cpp index f920e9d97..b8109c7e9 100644 --- a/libethashseal/Ethash.cpp +++ b/libethashseal/Ethash.cpp @@ -177,7 +177,7 @@ u256 Ethash::calculateDifficulty( BlockHeader const& _bi, BlockHeader const& _pa bigint const adjFactor = _bi.number() < chainParams().byzantiumForkBlock ? max< bigint >( 1 - timestampDiff / 10, -99 ) : // Homestead-era difficulty - // adjustment + // adjustment max< bigint >( ( _parent.hasUncles() ? 2 : 1 ) - timestampDiff / 9, -99 ); // Byzantium-era difficulty adjustment diff --git a/libethashseal/EthashCPUMiner.cpp b/libethashseal/EthashCPUMiner.cpp index a4cbd2dfc..88fc611ef 100644 --- a/libethashseal/EthashCPUMiner.cpp +++ b/libethashseal/EthashCPUMiner.cpp @@ -90,7 +90,7 @@ void EthashCPUMiner::minerBody() { auto result = ethash::hash( ethashContext, toEthash( w.headerHash() ), tryNonce ); h256 value = h256( result.final_hash.bytes, h256::ConstructFromPointer ); if ( value <= boundary && - submitProof( EthashProofOfWork::Solution{ ( h64 )( u64 ) tryNonce, + submitProof( EthashProofOfWork::Solution{ ( h64 ) ( u64 ) tryNonce, h256( result.mix_hash.bytes, h256::ConstructFromPointer ) } ) ) break; if ( !( hashCount % 100 ) ) diff --git a/libethereum/Block.h b/libethereum/Block.h index 3dff5b034..7f38baf42 100644 --- a/libethereum/Block.h +++ b/libethereum/Block.h @@ -282,18 +282,26 @@ class Block { * // unlock * @endcode */ - bool sealBlock( bytes const& _header ) { return sealBlock( &_header ); } + bool sealBlock( bytes const& _header ) { + return sealBlock( &_header ); + } bool sealBlock( bytesConstRef _header ); /// @returns true if sealed - in this case you can no longer append transactions. - bool isSealed() const { return !m_currentBytes.empty(); } + bool isSealed() const { + return !m_currentBytes.empty(); + } /// Get the complete current block, including valid nonce. /// Only valid when isSealed() is true. - bytes const& blockData() const { return m_currentBytes; } + bytes const& blockData() const { + return m_currentBytes; + } /// Get the header information on the present block. - BlockHeader const& info() const { return m_currentBlock; } + BlockHeader const& info() const { + return m_currentBlock; + } void startReadState(); @@ -312,7 +320,9 @@ class Block { std::vector< BlockHeader > const& _uncleBlockHeaders, u256 const& _blockReward ); /// @returns gas used by transactions thus far executed. - u256 gasUsed() const { return m_receipts.size() ? m_receipts.back().cumulativeGasUsed() : 0; } + u256 gasUsed() const { + return m_receipts.size() ? m_receipts.back().cumulativeGasUsed() : 0; + } /// Performs irregular modifications right after initialization, e.g. to implement a hard fork. void performIrregularModifications(); @@ -347,7 +357,9 @@ class Block { ; public: - static uint64_t howMany() { return Counter< Block >::howMany(); } + static uint64_t howMany() { + return Counter< Block >::howMany(); + } }; diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index f6eb085d9..0cdd90533 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -176,9 +176,9 @@ string BlockChain::getChainDirName( const ChainParams& _cp ) { return toHex( BlockHeader( _cp.genesisBlock() ).hash().ref().cropped( 0, 4 ) ); } -BlockChain::BlockChain( ChainParams const& _p, fs::path const& _dbPath, bool _applyPatches, - WithExisting _we ) try : m_lastBlockHashes( new LastBlockHashes( *this ) ), - m_dbPath( _dbPath ) { +BlockChain::BlockChain( + ChainParams const& _p, fs::path const& _dbPath, bool _applyPatches, WithExisting _we ) try + : m_lastBlockHashes( new LastBlockHashes( *this ) ), m_dbPath( _dbPath ) { init( _p ); open( _dbPath, _applyPatches, _we ); } catch ( ... ) { @@ -1373,7 +1373,9 @@ void BlockChain::clearCaches() { //} void BlockChain::checkConsistency() { - DEV_WRITE_GUARDED( x_details ) { m_details.clear(); } + DEV_WRITE_GUARDED( x_details ) { + m_details.clear(); + } m_blocksDB->forEach( [this]( db::Slice const& _key, db::Slice const& /* _value */ ) { if ( _key.size() == 32 ) { diff --git a/libethereum/BlockQueue.cpp b/libethereum/BlockQueue.cpp index 36468bc2a..5c69b0505 100644 --- a/libethereum/BlockQueue.cpp +++ b/libethereum/BlockQueue.cpp @@ -386,13 +386,11 @@ BlockQueueStatus BlockQueue::status() const { QueueStatus BlockQueue::blockStatus( h256 const& _h ) const { ReadGuard l( m_lock ); - return m_readySet.count( _h ) ? - QueueStatus::Ready : - m_drainingSet.count( _h ) ? - QueueStatus::Importing : - m_unknownSet.count( _h ) ? - QueueStatus::UnknownParent : - m_knownBad.count( _h ) ? QueueStatus::Bad : QueueStatus::Unknown; + return m_readySet.count( _h ) ? QueueStatus::Ready : + m_drainingSet.count( _h ) ? QueueStatus::Importing : + m_unknownSet.count( _h ) ? QueueStatus::UnknownParent : + m_knownBad.count( _h ) ? QueueStatus::Bad : + QueueStatus::Unknown; } bool BlockQueue::knownFull() const { diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index fcf660e20..03a88b4e3 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -1067,11 +1067,10 @@ void Client::noteChanged( h256Hash const& _filters ) { w.second.append_changes( m_filters.at( w.second.id ).changes_ ); } else if ( m_specialFilters.count( w.second.id ) ) for ( h256 const& hash : m_specialFilters.at( w.second.id ) ) { - LOG( m_loggerWatch ) - << "!!! " << w.first << " " - << ( w.second.id == PendingChangedFilter ? - "pending" : - w.second.id == ChainChangedFilter ? "chain" : "???" ); + LOG( m_loggerWatch ) << "!!! " << w.first << " " + << ( w.second.id == PendingChangedFilter ? "pending" : + w.second.id == ChainChangedFilter ? "chain" : + "???" ); w.second.append_changes( LocalisedLogEntry( SpecialLogEntry, hash ) ); } } @@ -1177,7 +1176,9 @@ Block Client::blockByNumber( BlockNumber _h ) const { auto readState = m_state.createStateReadOnlyCopy(); readState.mutableHistoricState().setRootByBlockNumber( _h ); - DEV_GUARDED( m_blockImportMutex ) { return Block( bc(), hash, readState ); } + DEV_GUARDED( m_blockImportMutex ) { + return Block( bc(), hash, readState ); + } assert( false ); return Block( bc() ); } catch ( Exception& ex ) { @@ -1191,7 +1192,9 @@ Block Client::blockByNumber( BlockNumber _h ) const { Block Client::latestBlock() const { // TODO Why it returns not-filled block??! (see Block ctor) try { - DEV_GUARDED( m_blockImportMutex ) { return Block( bc(), bc().currentHash(), m_state ); } + DEV_GUARDED( m_blockImportMutex ) { + return Block( bc(), bc().currentHash(), m_state ); + } assert( false ); return Block( bc() ); } catch ( Exception& ex ) { @@ -1339,7 +1342,7 @@ ExecutionResult Client::call( Address const& _from, u256 _value, Address _dest, t.checkOutExternalGas( ~u256( 0 ) ); if ( _ff == FudgeFactor::Lenient ) { historicBlock.mutableState().mutableHistoricState().addBalance( - _from, ( u256 )( t.gas() * t.gasPrice() + t.value() ) ); + _from, ( u256 ) ( t.gas() * t.gasPrice() + t.value() ) ); } ret = historicBlock.executeHistoricCall( bc().lastBlockHashes(), t ); @@ -1363,7 +1366,8 @@ ExecutionResult Client::call( Address const& _from, u256 _value, Address _dest, t.forceChainId( chainParams().chainID ); t.checkOutExternalGas( ~u256( 0 ) ); if ( _ff == FudgeFactor::Lenient ) - temp.mutableState().addBalance( _from, ( u256 )( t.gas() * t.gasPrice() + t.value() ) ); + temp.mutableState().addBalance( + _from, ( u256 ) ( t.gas() * t.gasPrice() + t.value() ) ); ret = temp.execute( bc().lastBlockHashes(), t, skale::Permanence::Reverted ); } catch ( InvalidNonce const& in ) { LOG( m_logger ) << "exception in client call(1):" diff --git a/libethereum/Client.h b/libethereum/Client.h index 64ebd96d1..abc7b9c85 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -129,9 +129,13 @@ class Client : public ClientBase, protected Worker { ImportResult queueBlock( bytes const& _block, bool _isSafe = false ); /// Get the remaining gas limit in this block. - u256 gasLimitRemaining() const override { return m_postSeal.gasLimitRemaining(); } + u256 gasLimitRemaining() const override { + return m_postSeal.gasLimitRemaining(); + } /// Get the gas bid price - u256 gasBidPrice() const override { return m_gp->bid(); } + u256 gasBidPrice() const override { + return m_gp->bid(); + } // [PRIVATE API - only relevant for base clients, not available in general] /// Get the block. @@ -143,22 +147,36 @@ class Client : public ClientBase, protected Worker { return m_postSeal; } /// Get the object representing the current canonical blockchain. - BlockChain const& blockChain() const { return bc(); } + BlockChain const& blockChain() const { + return bc(); + } /// Get some information on the block queue. - BlockQueueStatus blockQueueStatus() const { return m_bq.status(); } + BlockQueueStatus blockQueueStatus() const { + return m_bq.status(); + } /// Get some information on the block syncing. SyncStatus syncStatus() const override; /// Populate the uninitialized fields in the supplied transaction with default values TransactionSkeleton populateTransactionWithDefaults( TransactionSkeleton const& _t ) const override; /// Get the block queue. - BlockQueue const& blockQueue() const { return m_bq; } + BlockQueue const& blockQueue() const { + return m_bq; + } /// Get the state database. - skale::State const& state() const { return m_state; } + skale::State const& state() const { + return m_state; + } /// Get some information on the transaction queue. - TransactionQueue::Status transactionQueueStatus() const { return m_tq.status(); } - TransactionQueue::Limits transactionQueueLimits() const { return m_tq.limits(); } - TransactionQueue* debugGetTransactionQueue() { return &m_tq; } + TransactionQueue::Status transactionQueueStatus() const { + return m_tq.status(); + } + TransactionQueue::Limits transactionQueueLimits() const { + return m_tq.limits(); + } + TransactionQueue* debugGetTransactionQueue() { + return &m_tq; + } /// Freeze worker thread and sync some of the block queue. std::tuple< ImportRoute, bool, unsigned > syncQueue( unsigned _max = 1 ); @@ -177,9 +195,13 @@ class Client : public ClientBase, protected Worker { } /// Type of sealers available for this seal engine. - strings sealers() const { return sealEngine()->sealers(); } + strings sealers() const { + return sealEngine()->sealers(); + } /// Current sealer in use. - std::string sealer() const { return sealEngine()->sealer(); } + std::string sealer() const { + return sealEngine()->sealer(); + } /// Change sealer. void setSealer( std::string const& _id ) { sealEngine()->setSealer( _id ); @@ -187,7 +209,9 @@ class Client : public ClientBase, protected Worker { startSealing(); } /// Review option for the sealer. - bytes sealOption( std::string const& _name ) const { return sealEngine()->option( _name ); } + bytes sealOption( std::string const& _name ) const { + return sealEngine()->option( _name ); + } /// Set option for the sealer. bool setSealOption( std::string const& _name, bytes const& _value ) { auto ret = sealEngine()->setOption( _name, _value ); @@ -199,9 +223,13 @@ class Client : public ClientBase, protected Worker { /// Start sealing. void startSealing() override; /// Stop sealing. - void stopSealing() override { m_wouldSeal = false; } + void stopSealing() override { + m_wouldSeal = false; + } /// Are we sealing now? - bool wouldSeal() const override { return m_wouldSeal; } + bool wouldSeal() const override { + return m_wouldSeal; + } /// Are we updating the chain (syncing or importing a new block)? bool isSyncing() const override; @@ -214,7 +242,9 @@ class Client : public ClientBase, protected Worker { void setNetworkId( u256 const& _n ) override; /// Get the seal engine. - SealEngineFace* sealEngine() const override { return bc().sealEngine(); } + SealEngineFace* sealEngine() const override { + return bc().sealEngine(); + } // Debug stuff: @@ -222,7 +252,9 @@ class Client : public ClientBase, protected Worker { /// Clears pending transactions. Just for debug use. void clearPending(); /// Retries all blocks with unknown parents. - void retryUnknown() { m_bq.retryAllUnknown(); } + void retryUnknown() { + m_bq.retryAllUnknown(); + } /// Get a report of activity. ActivityReport activityReport() { ActivityReport ret; @@ -230,9 +262,13 @@ class Client : public ClientBase, protected Worker { return ret; } /// Set the extra data that goes into sealed blocks. - void setExtraData( bytes const& _extraData ) { m_extraData = _extraData; } + void setExtraData( bytes const& _extraData ) { + m_extraData = _extraData; + } /// Rescue the chain. - void rescue() { bc().rescue( m_state ); } + void rescue() { + bc().rescue( m_state ); + } std::unique_ptr< StateImporterFace > createStateImporter() { throw std::logic_error( "createStateImporter is not implemented" ); @@ -261,7 +297,9 @@ class Client : public ClientBase, protected Worker { return m_onBlockSealed.add( _handler ); } - std::shared_ptr< SkaleHost > skaleHost() const { return m_skaleHost; } + std::shared_ptr< SkaleHost > skaleHost() const { + return m_skaleHost; + } // main entry point after consensus size_t importTransactionsAsBlock( const Transactions& _transactions, u256 _gasPrice, @@ -297,9 +335,13 @@ class Client : public ClientBase, protected Worker { return this->m_snapshotManager->getBlockTimestamp( _blockNumber, chainParams() ); } - int64_t getLatestSnapshotBlockNumer() const { return this->last_snapshoted_block_with_hash; } + int64_t getLatestSnapshotBlockNumer() const { + return this->last_snapshoted_block_with_hash; + } - uint64_t getSnapshotCalculationTime() const { return this->snapshot_calculation_time_ms; } + uint64_t getSnapshotCalculationTime() const { + return this->snapshot_calculation_time_ms; + } uint64_t getSnapshotHashCalculationTime() const { return this->snapshot_hash_calculation_time_ms; @@ -325,11 +367,17 @@ class Client : public ClientBase, protected Worker { uint64_t submitOracleRequest( const string& _spec, string& _receipt ); uint64_t checkOracleResult( const string& _receipt, string& _result ); - SkaleDebugInterface::handler getDebugHandler() const { return m_debugHandler; } + SkaleDebugInterface::handler getDebugHandler() const { + return m_debugHandler; + } #ifdef HISTORIC_STATE - OverlayDB const& historicStateDB() const { return m_historicStateDB; } - OverlayDB const& historicBlockToStateRootDB() const { return m_historicBlockToStateRootDB; } + OverlayDB const& historicStateDB() const { + return m_historicStateDB; + } + OverlayDB const& historicBlockToStateRootDB() const { + return m_historicBlockToStateRootDB; + } #endif protected: @@ -353,8 +401,12 @@ class Client : public ClientBase, protected Worker { void init( WithExisting _forceAction, u256 _networkId ); /// InterfaceStub methods - BlockChain& bc() override { return m_bc; } - BlockChain const& bc() const override { return m_bc; } + BlockChain& bc() override { + return m_bc; + } + BlockChain const& bc() const override { + return m_bc; + } /// Returns the state object for the full block (i.e. the terminal state) for index _h. /// Works properly with LatestBlock and PendingBlock. @@ -395,7 +447,9 @@ class Client : public ClientBase, protected Worker { /// Do some work. Handles blockchain maintenance and sealing. void doWork( bool _doWait ); - void doWork() override { doWork( true ); } + void doWork() override { + doWork( true ); + } /// Called when Worker is exiting. void doneWorking() override; diff --git a/libethereum/ClientBase.cpp b/libethereum/ClientBase.cpp index a20c2f9b3..6ebe47140 100644 --- a/libethereum/ClientBase.cpp +++ b/libethereum/ClientBase.cpp @@ -93,7 +93,7 @@ std::pair< bool, ExecutionResult > ClientBase::estimateGasStep( int64_t _gas, Bl EnvInfo const env( _latestBlock.info(), bc().lastBlockHashes(), 0, _gas ); // Make a copy of state!! It will be deleted after step! State tempState = _latestBlock.mutableState(); - tempState.addBalance( _from, ( u256 )( t.gas() * t.gasPrice() + t.value() ) ); + tempState.addBalance( _from, ( u256 ) ( t.gas() * t.gasPrice() + t.value() ) ); ExecutionResult executionResult = tempState.execute( env, *bc().sealEngine(), t, Permanence::Reverted ).first; if ( executionResult.excepted == TransactionException::OutOfGas || diff --git a/libethereum/ClientBase.h b/libethereum/ClientBase.h index ab4b7a812..7fbf3ff43 100644 --- a/libethereum/ClientBase.h +++ b/libethereum/ClientBase.h @@ -74,7 +74,9 @@ struct ClientWatch { mutable std::chrono::system_clock::time_point lastPoll = std::chrono::system_clock::now(); - bool isWS() const { return isWS_; }; + bool isWS() const { + return isWS_; + }; }; class ClientBase : public Interface { diff --git a/libethereum/Executive.cpp b/libethereum/Executive.cpp index 2ab8015e5..efafe1107 100644 --- a/libethereum/Executive.cpp +++ b/libethereum/Executive.cpp @@ -321,7 +321,7 @@ bool Executive::call( CallParameters const& _p, u256 const& _gasPrice, Address c return true; // true actually means "all finished - nothing more to be done regarding // go(). } else { - m_gas = ( u256 )( _p.gas - g ); + m_gas = ( u256 ) ( _p.gas - g ); bytes output; bool success; // dev::eth::g_state = m_s.delegateWrite(); diff --git a/libethereum/Interface.h b/libethereum/Interface.h index a6c1c874f..a61ca7fc2 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -118,7 +118,9 @@ class Interface { // [STATE-QUERY API] - int getDefault() const { return PendingBlock; } + int getDefault() const { + return PendingBlock; + } void setDefault( BlockNumber /*_block*/ ) { throw std::logic_error( "setDefault is not supported" ); } @@ -202,10 +204,16 @@ class Interface { virtual Transactions transactions( BlockNumber _block ) const = 0; virtual TransactionHashes transactionHashes( h256 _blockHash ) const = 0; - virtual BlockHeader pendingInfo() const { return BlockHeader(); } - virtual BlockDetails pendingDetails() const { return BlockDetails(); } + virtual BlockHeader pendingInfo() const { + return BlockHeader(); + } + virtual BlockDetails pendingDetails() const { + return BlockDetails(); + } /// @returns the EVMSchedule in the context of the pending block. - virtual EVMSchedule evmSchedule() const { return EVMSchedule(); } + virtual EVMSchedule evmSchedule() const { + return EVMSchedule(); + } BlockHeader blockInfo( BlockNumber _block ) const; BlockDetails blockDetails( BlockNumber _block ) const; @@ -268,20 +276,30 @@ class Interface { virtual bool wouldSeal() const = 0; /// Are we updating the chain (syncing or importing a new block)? - virtual bool isSyncing() const { return false; } + virtual bool isSyncing() const { + return false; + } /// Are we syncing the chain? - virtual bool isMajorSyncing() const { return false; } + virtual bool isMajorSyncing() const { + return false; + } /// Gets the network id. - virtual u256 networkId() const { return 0; } + virtual u256 networkId() const { + return 0; + } /// Sets the network id. virtual void setNetworkId( u256 const& ) {} /// Gets the chain id - virtual uint64_t chainId() const { return 0; } + virtual uint64_t chainId() const { + return 0; + } /// Get the seal engine. - virtual SealEngineFace* sealEngine() const { return nullptr; } + virtual SealEngineFace* sealEngine() const { + return nullptr; + } public: // new block watch diff --git a/libethereum/TransactionQueue.h b/libethereum/TransactionQueue.h index 31bbd2340..c1cd28fa5 100644 --- a/libethereum/TransactionQueue.h +++ b/libethereum/TransactionQueue.h @@ -147,7 +147,9 @@ class TransactionQueue { /// @returns the status of the transaction queue. Status status() const { Status ret; - DEV_GUARDED( x_queue ) { ret.unverified = m_unverified.size(); } + DEV_GUARDED( x_queue ) { + ret.unverified = m_unverified.size(); + } ReadGuard l( m_lock ); ret.dropped = m_dropped.size(); ret.current = m_currentByHash.size(); diff --git a/libevm/LegacyVM.cpp b/libevm/LegacyVM.cpp index 8a0775112..06f7ed735 100644 --- a/libevm/LegacyVM.cpp +++ b/libevm/LegacyVM.cpp @@ -27,12 +27,12 @@ uint64_t LegacyVM::memNeed( u256 const& _offset, u256 const& _size ) { template < class S > S divWorkaround( S const& _a, S const& _b ) { - return ( S )( s512( _a ) / s512( _b ) ); + return ( S ) ( s512( _a ) / s512( _b ) ); } template < class S > S modWorkaround( S const& _a, S const& _b ) { - return ( S )( s512( _a ) % s512( _b ) ); + return ( S ) ( s512( _a ) % s512( _b ) ); } @@ -353,7 +353,7 @@ void LegacyVM::interpretCases() { updateMem( toInt63( m_SP[0] ) + 1 ); updateIOGas(); - m_mem[( unsigned ) m_SP[0]] = ( _byte_ )( m_SP[1] & 0xff ); + m_mem[( unsigned ) m_SP[0]] = ( _byte_ ) ( m_SP[1] & 0xff ); } NEXT @@ -1082,7 +1082,9 @@ void LegacyVM::interpretCases() { CASE( XPUT ) CASE( XGET ) CASE( XSWIZZLE ) - CASE( XSHUFFLE ) { throwBadInstruction(); } + CASE( XSHUFFLE ) { + throwBadInstruction(); + } CONTINUE #endif diff --git a/libevm/LegacyVM.h b/libevm/LegacyVM.h index 8a5e20704..085946c4d 100644 --- a/libevm/LegacyVM.h +++ b/libevm/LegacyVM.h @@ -35,7 +35,9 @@ class LegacyVM : public VMFace { void validateSubroutine( uint64_t _PC, uint64_t* _rp, u256* _sp ); #endif - bytes const& memory() const { return m_mem; } + bytes const& memory() const { + return m_mem; + } u256s stack() const { u256s stack( m_SP, m_stackEnd ); reverse( stack.begin(), stack.end() ); @@ -73,7 +75,9 @@ class LegacyVM : public VMFace { // space for data stack, grows towards smaller addresses from the end u256 m_stack[1024]; u256* m_stackEnd = &m_stack[1024]; - size_t stackSize() { return m_stackEnd - m_SP; } + size_t stackSize() { + return m_stackEnd - m_SP; + } #if EIP_615 // space for return stack diff --git a/libevm/LegacyVMCalls.cpp b/libevm/LegacyVMCalls.cpp index ff6beb71d..f9f4b0da5 100644 --- a/libevm/LegacyVMCalls.cpp +++ b/libevm/LegacyVMCalls.cpp @@ -69,7 +69,7 @@ void LegacyVM::throwBadStack( unsigned _removed, unsigned _added ) { if ( m_onFail ) ( this->*m_onFail )(); BOOST_THROW_EXCEPTION( - OutOfStack() << RequirementError( ( bigint )( _added - _removed ), size ) ); + OutOfStack() << RequirementError( ( bigint ) ( _added - _removed ), size ) ); } } diff --git a/libhistoric/AlethExecutive.cpp b/libhistoric/AlethExecutive.cpp index ebc687dd0..36698d9e8 100644 --- a/libhistoric/AlethExecutive.cpp +++ b/libhistoric/AlethExecutive.cpp @@ -175,7 +175,7 @@ bool AlethExecutive::call( return true; // true actually means "all finished - nothing more to be done regarding // go(). } else { - m_gas = ( u256 )( _p.gas - g ); + m_gas = ( u256 ) ( _p.gas - g ); bytes output; bool success; tie( success, output ) = diff --git a/libhistoric/HistoricState.cpp b/libhistoric/HistoricState.cpp index 4bb7d3a04..ecb4a49f7 100644 --- a/libhistoric/HistoricState.cpp +++ b/libhistoric/HistoricState.cpp @@ -707,7 +707,8 @@ std::ostream& dev::eth::operator<<( std::ostream& _out, HistoricState const& _s contout << std::endl << ( delta.count( j.first ) ? back.count( j.first ) ? " * " : " + " : - cached.count( j.first ) ? " . " : " " ) + cached.count( j.first ) ? " . " : + " " ) << std::hex << nouppercase << std::setw( 64 ) << j.first << ": " << std::setw( 0 ) << j.second; else diff --git a/libskale-interpreter/VM.cpp b/libskale-interpreter/VM.cpp index 6d414ff12..4e88a1a15 100644 --- a/libskale-interpreter/VM.cpp +++ b/libskale-interpreter/VM.cpp @@ -107,12 +107,12 @@ uint64_t VM::memNeed( u256 const& _offset, u256 const& _size ) { template < class S > S divWorkaround( S const& _a, S const& _b ) { - return ( S )( s512( _a ) / s512( _b ) ); + return ( S ) ( s512( _a ) / s512( _b ) ); } template < class S > S modWorkaround( S const& _a, S const& _b ) { - return ( S )( s512( _a ) % s512( _b ) ); + return ( S ) ( s512( _a ) % s512( _b ) ); } @@ -374,7 +374,7 @@ void VM::interpretCases() { updateMem( toInt63( m_SP[0] ) + 1 ); updateIOGas(); - m_mem[( unsigned ) m_SP[0]] = ( _byte_ )( m_SP[1] & 0xff ); + m_mem[( unsigned ) m_SP[0]] = ( _byte_ ) ( m_SP[1] & 0xff ); } NEXT @@ -779,7 +779,9 @@ void VM::interpretCases() { CASE( XPUT ) CASE( XGET ) CASE( XSWIZZLE ) - CASE( XSHUFFLE ) { throwBadInstruction(); } + CASE( XSHUFFLE ) { + throwBadInstruction(); + } CONTINUE CASE( ADDRESS ) { diff --git a/libskale-interpreter/VMCalls.cpp b/libskale-interpreter/VMCalls.cpp index c4d084bc0..c3723318f 100644 --- a/libskale-interpreter/VMCalls.cpp +++ b/libskale-interpreter/VMCalls.cpp @@ -66,7 +66,7 @@ void VM::throwBadStack( int _removed, int _added ) { BOOST_THROW_EXCEPTION( StackUnderflow() << RequirementError( ( bigint ) _removed, size ) ); else BOOST_THROW_EXCEPTION( - OutOfStack() << RequirementError( ( bigint )( _added - _removed ), size ) ); + OutOfStack() << RequirementError( ( bigint ) ( _added - _removed ), size ) ); } void VM::throwRevertInstruction( owning_bytes_ref&& _output ) { diff --git a/libskale/State.cpp b/libskale/State.cpp index 77f2712d3..2921fd69b 100644 --- a/libskale/State.cpp +++ b/libskale/State.cpp @@ -1101,7 +1101,8 @@ std::ostream& skale::operator<<( std::ostream& _out, State const& _s ) { contout << std::endl << ( delta.count( j.first ) ? back.count( j.first ) ? " * " : " + " : - cached.count( j.first ) ? " . " : " " ) + cached.count( j.first ) ? " . " : + " " ) << std::hex << nouppercase << std::setw( 64 ) << j.first << ": " << std::setw( 0 ) << j.second; else diff --git a/libskale/State.h b/libskale/State.h index ee7a827e6..3e81b770b 100644 --- a/libskale/State.h +++ b/libskale/State.h @@ -356,7 +356,9 @@ class State { dev::eth::OnOpFunc const& _onOp = dev::eth::OnOpFunc() ); /// Get the account start nonce. May be required. - dev::u256 const& accountStartNonce() const { return m_accountStartNonce; } + dev::u256 const& accountStartNonce() const { + return m_accountStartNonce; + } dev::u256 const& requireAccountStartNonce() const; void noteAccountStartNonce( dev::u256 const& _actual ); @@ -367,7 +369,9 @@ class State { /// Revert all recent changes up to the given @p _savepoint savepoint. void rollback( size_t _savepoint ); - ChangeLog const& changeLog() const { return m_changeLog; } + ChangeLog const& changeLog() const { + return m_changeLog; + } /// Create State copy to get access to data. /// Different copies can be safely used in different threads @@ -515,7 +519,9 @@ class State { public: /// Get the backing state object. - dev::eth::HistoricState& mutableHistoricState() { return m_historicState; } + dev::eth::HistoricState& mutableHistoricState() { + return m_historicState; + } dev::eth::AccountMap getBatchOfAccounts( std::unordered_map< dev::Address, dev::u256 >& _allAccountAddresses, @@ -529,7 +535,9 @@ class State { pDB = m_db_ptr->db(); return pDB; } - std::shared_ptr< OverlayFS > fs() { return m_fs_ptr; } + std::shared_ptr< OverlayFS > fs() { + return m_fs_ptr; + } }; std::ostream& operator<<( std::ostream& _out, State const& _s ); diff --git a/libskale/httpserveroverride.cpp b/libskale/httpserveroverride.cpp index fd6dcd92c..9eb77db31 100644 --- a/libskale/httpserveroverride.cpp +++ b/libskale/httpserveroverride.cpp @@ -2108,7 +2108,7 @@ SkaleServerOverride::SkaleServerOverride( { // block std::function< void( const unsigned& iw, const dev::eth::Transaction& tx ) > fnOnSunscriptionEvent = - [this]( const unsigned& /*iw*/, const dev::eth::Transaction & /*tx*/ ) -> void { + [this]( const unsigned& /*iw*/, const dev::eth::Transaction& /*tx*/ ) -> void { lock_type lock( mtxStats_ ); statsPendingTx_.event_add( "transactionsPending", 1 ); }; diff --git a/libskutils/include/skutils/dispatch.h b/libskutils/include/skutils/dispatch.h index 1b6c5bea4..1c7ba5066 100644 --- a/libskutils/include/skutils/dispatch.h +++ b/libskutils/include/skutils/dispatch.h @@ -405,7 +405,9 @@ class loop : public ref_retain_release { ~loop(); loop& operator=( const loop& ) = delete; loop& operator=( loop&& ) = delete; - uv_loop_s* internal_handle() { return p_uvLoop_; } + uv_loop_s* internal_handle() { + return p_uvLoop_; + } mutex_type& loop_mtx() const; static loop_ptr_t get_current(); bool is_running() const; diff --git a/libskutils/include/skutils/http.h b/libskutils/include/skutils/http.h index 4ba9b967e..954ca8ccd 100644 --- a/libskutils/include/skutils/http.h +++ b/libskutils/include/skutils/http.h @@ -436,7 +436,9 @@ class server : public common { bool is_running() const; void stop(); - virtual bool is_ssl() const { return false; } + virtual bool is_ssl() const { + return false; + } protected: bool process_request( @@ -493,7 +495,9 @@ class server : public common { void remove_all_tasks(); public: - bool is_in_loop() const { return is_in_loop_; } + bool is_in_loop() const { + return is_in_loop_; + } void wait_while_in_loop() const { while ( is_in_loop() ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); diff --git a/libskutils/include/skutils/rest_call.h b/libskutils/include/skutils/rest_call.h index ebdb0943f..4de8dee25 100644 --- a/libskutils/include/skutils/rest_call.h +++ b/libskutils/include/skutils/rest_call.h @@ -149,7 +149,9 @@ class client { client( const char* url_str, long nClientConnectionTimeoutMS = -1 ); virtual ~client(); - const skutils::url& url() const { return u_; } + const skutils::url& url() const { + return u_; + } bool open( const skutils::url& u, std::chrono::milliseconds wait_step = std::chrono::milliseconds( 20 ), diff --git a/libskutils/src/http.cpp b/libskutils/src/http.cpp index a0ece1234..4569a34c3 100644 --- a/libskutils/src/http.cpp +++ b/libskutils/src/http.cpp @@ -1431,7 +1431,7 @@ bool async_read_and_close_socket_base::schedule_check_clock() { if ( retry_index_ > retry_count_ ) return false; clock_t tpNow = clock(); - clock_t tpMin = ( clock_t )( ( retry_index_ == 0 ) ? retry_first_ms_ : retry_after_ms_ ); + clock_t tpMin = ( clock_t ) ( ( retry_index_ == 0 ) ? retry_first_ms_ : retry_after_ms_ ); clock_t tpDist = tpNow - tpStep_; if ( tpDist < tpMin ) return false; // too early diff --git a/libskutils/src/rest_call.cpp b/libskutils/src/rest_call.cpp index 467226ef5..312a0dfaa 100644 --- a/libskutils/src/rest_call.cpp +++ b/libskutils/src/rest_call.cpp @@ -624,7 +624,8 @@ std::string client::stat_extract_short_content_type_string( const std::string& s } uint64_t client::stat_get_random_number( uint64_t const& min, uint64_t const& max ) { - return ( ( ( uint64_t )( unsigned int ) rand() << 32 ) + ( uint64_t )( unsigned int ) rand() ) % + return ( ( ( uint64_t ) ( unsigned int ) rand() << 32 ) + + ( uint64_t ) ( unsigned int ) rand() ) % ( max - min ) + min; } diff --git a/libskutils/src/utils.cpp b/libskutils/src/utils.cpp index 1c398316c..eedcfc5e4 100644 --- a/libskutils/src/utils.cpp +++ b/libskutils/src/utils.cpp @@ -1038,7 +1038,7 @@ void md5::finalize() { // save number of bits encode( bits, count, 8 ); // pad out to 56 mod 64. - index = ( uint4 )( ( count[0] >> 3 ) & 0x3f ); + index = ( uint4 ) ( ( count[0] >> 3 ) & 0x3f ); padLen = ( index < 56 ) ? ( 56 - index ) : ( 120 - index ); update( PADDING, padLen ); update( bits, 8 ); // append length (before padding) @@ -1203,10 +1203,10 @@ void md5::encode( uint1* output, uint4* input, uint4 len ) { // Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. unsigned int i, j; for ( i = 0, j = 0; j < len; i++, j += 4 ) { - output[j] = ( uint1 )( input[i] & 0xff ); - output[j + 1] = ( uint1 )( ( input[i] >> 8 ) & 0xff ); - output[j + 2] = ( uint1 )( ( input[i] >> 16 ) & 0xff ); - output[j + 3] = ( uint1 )( ( input[i] >> 24 ) & 0xff ); + output[j] = ( uint1 ) ( input[i] & 0xff ); + output[j + 1] = ( uint1 ) ( ( input[i] >> 8 ) & 0xff ); + output[j + 2] = ( uint1 ) ( ( input[i] >> 16 ) & 0xff ); + output[j + 3] = ( uint1 ) ( ( input[i] >> 24 ) & 0xff ); } } void md5::decode( uint4* output, uint1* input, uint4 len ) { diff --git a/libweb3jsonrpc/IpcServerBase.cpp b/libweb3jsonrpc/IpcServerBase.cpp index 539216571..2bb75ec24 100644 --- a/libweb3jsonrpc/IpcServerBase.cpp +++ b/libweb3jsonrpc/IpcServerBase.cpp @@ -72,7 +72,7 @@ template < class S > bool IpcServerBase< S >::SendResponse( string const& _response, void* _addInfo ) { bool fullyWritten = false; bool errorOccured = false; - S socket = ( S )( reinterpret_cast< intptr_t >( _addInfo ) ); + S socket = ( S ) ( reinterpret_cast< intptr_t >( _addInfo ) ); string toSend = _response; do { size_t bytesWritten = Write( socket, toSend ); diff --git a/skaled/main.cpp b/skaled/main.cpp index 3315ca09b..18893140b 100644 --- a/skaled/main.cpp +++ b/skaled/main.cpp @@ -1820,7 +1820,7 @@ int main( int argc, char** argv ) try { "Unknown seal engine: " + chainParams.sealEngineName ) ); g_client->dbRotationPeriod( - ( ( clock_t )( clockDbRotationPeriodInSeconds ) ) * CLOCKS_PER_SEC ); + ( ( clock_t ) ( clockDbRotationPeriodInSeconds ) ) * CLOCKS_PER_SEC ); // XXX nested lambdas and strlen hacks.. auto client_debug_handler = g_client->getDebugHandler(); From 2dbf8e9c37a11481f5da9c1c1a6ebb5118ea007c Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Mon, 27 Mar 2023 13:09:54 +0100 Subject: [PATCH 16/19] SKALED-1467 Once more clang-format-11 --- libdevcore/CommonData.cpp | 2 +- libdevcore/CommonData.h | 4 +- libdevcore/RLP.cpp | 14 ++-- libdevcore/microprofile.cpp | 22 ++--- libdevcore/microprofile.h | 4 +- libdevcore/miniz.h | 18 ++--- libethashseal/EthashCPUMiner.cpp | 2 +- libethereum/Block.h | 24 ++---- libethereum/BlockChain.cpp | 4 +- libethereum/Client.cpp | 13 +-- libethereum/Client.h | 108 +++++++------------------ libethereum/ClientBase.cpp | 2 +- libethereum/ClientBase.h | 4 +- libethereum/Executive.cpp | 2 +- libethereum/Interface.h | 36 +++------ libethereum/TransactionQueue.h | 4 +- libevm/LegacyVM.cpp | 10 +-- libevm/LegacyVM.h | 8 +- libevm/LegacyVMCalls.cpp | 2 +- libhistoric/AlethExecutive.cpp | 2 +- libskale-interpreter/VM.cpp | 10 +-- libskale-interpreter/VMCalls.cpp | 2 +- libskale/State.h | 16 +--- libskutils/include/skutils/dispatch.h | 4 +- libskutils/include/skutils/http.h | 8 +- libskutils/include/skutils/rest_call.h | 4 +- libskutils/src/http.cpp | 2 +- libskutils/src/rest_call.cpp | 3 +- libskutils/src/utils.cpp | 10 +-- libweb3jsonrpc/IpcServerBase.cpp | 2 +- skale-vm/main.cpp | 3 +- skaled/main.cpp | 2 +- 32 files changed, 116 insertions(+), 235 deletions(-) diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp index 0ec32aa18..16911de42 100644 --- a/libdevcore/CommonData.cpp +++ b/libdevcore/CommonData.cpp @@ -91,7 +91,7 @@ bytes dev::fromHex( std::string const& _s, WhenError _throw ) { int h = fromHexChar( _s[i] ); int l = fromHexChar( _s[i + 1] ); if ( h != -1 && l != -1 ) - ret.push_back( ( _byte_ ) ( h * 16 + l ) ); + ret.push_back( ( _byte_ )( h * 16 + l ) ); else if ( _throw == WhenError::Throw ) BOOST_THROW_EXCEPTION( BadHexCharacter() ); else diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index 44bcdc563..fa896be69 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -137,8 +137,8 @@ template < class T, class _In > inline T fromBigEndian( _In const& _bytes ) { T ret = ( T ) 0; for ( auto i : _bytes ) - ret = ( T ) ( ( ret << 8 ) | - ( _byte_ ) ( typename std::make_unsigned< decltype( i ) >::type ) i ); + ret = ( T )( + ( ret << 8 ) | ( _byte_ )( typename std::make_unsigned< decltype( i ) >::type ) i ); return ret; } diff --git a/libdevcore/RLP.cpp b/libdevcore/RLP.cpp index 74516b9d5..8bbd3e2fe 100644 --- a/libdevcore/RLP.cpp +++ b/libdevcore/RLP.cpp @@ -241,9 +241,9 @@ void RLPStream::noteAppended( size_t _itemCount ) { m_out.resize( os + encodeSize ); memmove( m_out.data() + p + encodeSize, m_out.data() + p, os - p ); if ( s < c_rlpListImmLenCount ) - m_out[p] = ( _byte_ ) ( c_rlpListStart + s ); + m_out[p] = ( _byte_ )( c_rlpListStart + s ); else if ( c_rlpListIndLenZero + brs <= 0xff ) { - m_out[p] = ( _byte_ ) ( c_rlpListIndLenZero + brs ); + m_out[p] = ( _byte_ )( c_rlpListIndLenZero + brs ); _byte_* b = &( m_out[p + brs] ); for ( ; s; s >>= 8 ) *( b-- ) = ( _byte_ ) s; @@ -267,7 +267,7 @@ RLPStream& RLPStream::appendList( size_t _items ) { RLPStream& RLPStream::appendList( bytesConstRef _rlp ) { if ( _rlp.size() < c_rlpListImmLenCount ) - m_out.push_back( ( _byte_ ) ( _rlp.size() + c_rlpListStart ) ); + m_out.push_back( ( _byte_ )( _rlp.size() + c_rlpListStart ) ); else pushCount( _rlp.size(), c_rlpListIndLenZero ); appendRaw( _rlp, 1 ); @@ -285,7 +285,7 @@ RLPStream& RLPStream::append( bytesConstRef _s, bool _compact ) { m_out.push_back( *d ); else { if ( s < c_rlpDataImmLenCount ) - m_out.push_back( ( _byte_ ) ( s + c_rlpDataImmLenStart ) ); + m_out.push_back( ( _byte_ )( s + c_rlpDataImmLenStart ) ); else pushCount( s, c_rlpDataIndLenZero ); appendRaw( bytesConstRef( d, s ), 0 ); @@ -302,13 +302,13 @@ RLPStream& RLPStream::append( bigint _i ) { else { unsigned br = bytesRequired( _i ); if ( br < c_rlpDataImmLenCount ) - m_out.push_back( ( _byte_ ) ( br + c_rlpDataImmLenStart ) ); + m_out.push_back( ( _byte_ )( br + c_rlpDataImmLenStart ) ); else { auto brbr = bytesRequired( br ); if ( c_rlpDataIndLenZero + brbr > 0xff ) BOOST_THROW_EXCEPTION( RLPException() << errinfo_comment( "Number too large for RLP" ) ); - m_out.push_back( ( _byte_ ) ( c_rlpDataIndLenZero + brbr ) ); + m_out.push_back( ( _byte_ )( c_rlpDataIndLenZero + brbr ) ); pushInt( br, brbr ); } pushInt( _i, br ); @@ -321,7 +321,7 @@ void RLPStream::pushCount( size_t _count, _byte_ _base ) { auto br = bytesRequired( _count ); if ( int( br ) + _base > 0xff ) BOOST_THROW_EXCEPTION( RLPException() << errinfo_comment( "Count too large for RLP" ) ); - m_out.push_back( ( _byte_ ) ( br + _base ) ); // max 8 bytes. + m_out.push_back( ( _byte_ )( br + _base ) ); // max 8 bytes. pushInt( _count, br ); } diff --git a/libdevcore/microprofile.cpp b/libdevcore/microprofile.cpp index 3cf1afd89..b54078a8b 100644 --- a/libdevcore/microprofile.cpp +++ b/libdevcore/microprofile.cpp @@ -755,10 +755,10 @@ inline uint16_t MicroProfileGetTimerIndex( MicroProfileToken t ) { return ( t & 0xffff ); } inline uint32_t MicroProfileGetGroupMask( MicroProfileToken t ) { - return ( uint32_t ) ( ( t >> 16 ) & MICROPROFILE_GROUP_MASK_ALL ); + return ( uint32_t )( ( t >> 16 ) & MICROPROFILE_GROUP_MASK_ALL ); } inline uint32_t MicroProfileGetGroupMaskIndex( MicroProfileToken t ) { - return ( uint32_t ) ( t >> 48 ); + return ( uint32_t )( t >> 48 ); } @@ -782,7 +782,7 @@ T MicroProfileClamp( T a, T min_, T max_ ) { } inline int64_t MicroProfileMsToTick( float fMs, int64_t nTicksPerSecond ) { - return ( int64_t ) ( fMs * 0.001f * nTicksPerSecond ); + return ( int64_t )( fMs * 0.001f * nTicksPerSecond ); } inline float MicroProfileTickToMsMultiplier( int64_t nTicksPerSecond ) { @@ -846,7 +846,7 @@ void MicroProfileThreadJoin( MicroProfileThread* pThread ) { typedef HANDLE MicroProfileThread; DWORD _stdcall ThreadTrampoline( void* pFunc ) { MicroProfileThreadFunc F = ( MicroProfileThreadFunc ) pFunc; - return ( uint32_t ) ( uintptr_t ) F( 0 ); + return ( uint32_t )( uintptr_t ) F( 0 ); } void MicroProfileThreadStart( MicroProfileThread* pThread, MicroProfileThreadFunc Func ) { @@ -1367,7 +1367,7 @@ MicroProfileToken MicroProfileGetToken( if ( ret != MICROPROFILE_INVALID_TOKEN ) return ret; uint16_t nGroupIndex = MicroProfileGetGroup( pGroup, Type ); - uint16_t nTimerIndex = ( uint16_t ) ( S.nTotalTimers++ ); + uint16_t nTimerIndex = ( uint16_t )( S.nTotalTimers++ ); MP_ASSERT( nTimerIndex < MICROPROFILE_MAX_TIMERS ); uint32_t nBitIndex = nGroupIndex / 32; @@ -1452,7 +1452,7 @@ const char* MicroProfileCounterFullName( int nCounter ) { int nOffset = 0; while ( nIndex >= 0 && nOffset < ( int ) sizeof( Buffer ) - 2 ) { uint32_t nLen = S.CounterInfo[nNodes[nIndex]].nNameLen + nOffset; // < sizeof(Buffer)-1 - nLen = MicroProfileMin( ( uint32_t ) ( sizeof( Buffer ) - 2 - nOffset ), nLen ); + nLen = MicroProfileMin( ( uint32_t )( sizeof( Buffer ) - 2 - nOffset ), nLen ); memcpy( &Buffer[nOffset], S.CounterInfo[nNodes[nIndex]].pName, nLen ); nOffset += S.CounterInfo[nNodes[nIndex]].nNameLen + 1; @@ -5663,7 +5663,7 @@ const char* MicroProfileWin32ThreadInfoAddString( const char* pString ) { if ( 0 == g_ThreadInfo.pStrings[idx] ) { g_ThreadInfo.pStrings[idx] = &g_ThreadInfo.StringData[g_ThreadInfo.nStringOffset]; memcpy( &g_ThreadInfo.StringData[g_ThreadInfo.nStringOffset], pString, nLen + 1 ); - g_ThreadInfo.nStringOffset += ( uint32_t ) ( nLen + 1 ); + g_ThreadInfo.nStringOffset += ( uint32_t )( nLen + 1 ); return g_ThreadInfo.pStrings[idx]; } if ( 0 == strcmp( g_ThreadInfo.pStrings[idx], pString ) ) { @@ -5996,7 +5996,7 @@ void* MicroProfileTraceThread( void* unused ) { gettimeofday( &tv, NULL ); uint64_t nsSinceEpoch = - ( ( uint64_t ) ( tv.tv_sec ) * 1000000 + ( uint64_t ) ( tv.tv_usec ) ) * 1000; + ( ( uint64_t )( tv.tv_sec ) * 1000000 + ( uint64_t )( tv.tv_usec ) ) * 1000; uint64_t nTickEpoch = MP_TICK(); uint32_t nLastThread[MICROPROFILE_MAX_CONTEXT_SWITCH_THREADS] = { 0 }; mach_timebase_info_data_t sTimebaseInfo; @@ -6306,7 +6306,7 @@ void MicroProfileGpuWaitFence( uint32_t nNode, uint64_t nFence ) { uint64_t nCompletedFrame = S.pGPU->NodeState[nNode].pFence->GetCompletedValue(); // while(nCompletedFrame < nPending) // while(0 < nPending - nCompletedFrame) - while ( 0 < ( int64_t ) ( nFence - nCompletedFrame ) ) { + while ( 0 < ( int64_t )( nFence - nCompletedFrame ) ) { MICROPROFILE_SCOPEI( "Microprofile", "gpu-wait", MP_GREEN4 ); Sleep( 20 ); // todo: use event. nCompletedFrame = S.pGPU->NodeState[nNode].pFence->GetCompletedValue(); @@ -6317,7 +6317,7 @@ void MicroProfileGpuFetchResults( uint64_t nFrame ) { uint64_t nPending = S.pGPU->nPendingFrame; // while(nPending <= nFrame) // while(0 <= nFrame - nPending) - while ( 0 <= ( int64_t ) ( nFrame - nPending ) ) { + while ( 0 <= ( int64_t )( nFrame - nPending ) ) { uint32_t nInternal = nPending % MICROPROFILE_D3D_INTERNAL_DELAY; uint32_t nNode = S.pGPU->Frames[nInternal].nNode; MicroProfileGpuWaitFence( nNode, nPending ); @@ -6610,7 +6610,7 @@ void MicroProfileGpuFetchResults( VkCommandBuffer Buffer, uint64_t nFrame ) { uint64_t nPending = S.pGPU->nPendingFrame; // while(nPending <= nFrame) // while(0 <= nFrame - nPending) - while ( 0 <= ( int64_t ) ( nFrame - nPending ) ) { + while ( 0 <= ( int64_t )( nFrame - nPending ) ) { uint32_t nInternal = nPending % MICROPROFILE_VULKAN_INTERNAL_DELAY; uint32_t nNode = S.pGPU->Frames[nInternal].nNode; MicroProfileGpuWaitFence( nNode, nInternal ); diff --git a/libdevcore/microprofile.h b/libdevcore/microprofile.h index 62f466a74..ea3aae9b1 100644 --- a/libdevcore/microprofile.h +++ b/libdevcore/microprofile.h @@ -491,7 +491,7 @@ typedef uint64_t MicroProfileThreadIdType; #define MICROPROFILE_COUNTER_LOCAL_ADD( var, count ) \ MicroProfileLocalCounterAdd( &g_mp_local_counter##var, ( count ) ) #define MICROPROFILE_COUNTER_LOCAL_SUB( var, count ) \ - MicroProfileLocalCounterAdd( &g_mp_local_counter##var, -( int64_t ) ( count ) ) + MicroProfileLocalCounterAdd( &g_mp_local_counter##var, -( int64_t )( count ) ) #define MICROPROFILE_COUNTER_LOCAL_SET( var, count ) \ MicroProfileLocalCounterSet( &g_mp_local_counter##var, count ) #define MICROPROFILE_COUNTER_LOCAL_UPDATE_ADD( var ) \ @@ -503,7 +503,7 @@ typedef uint64_t MicroProfileThreadIdType; #define MICROPROFILE_COUNTER_LOCAL_ADD_ATOMIC( var, count ) \ MicroProfileLocalCounterAddAtomic( &g_mp_local_counter##var, ( count ) ) #define MICROPROFILE_COUNTER_LOCAL_SUB_ATOMIC( var, count ) \ - MicroProfileLocalCounterAddAtomic( &g_mp_local_counter##var, -( int64_t ) ( count ) ) + MicroProfileLocalCounterAddAtomic( &g_mp_local_counter##var, -( int64_t )( count ) ) #define MICROPROFILE_COUNTER_LOCAL_SET_ATOMIC( var, count ) \ MicroProfileLocalCounterSetAtomic( &g_mp_local_counter##var, count ) #define MICROPROFILE_COUNTER_LOCAL_UPDATE_ADD_ATOMIC( var ) \ diff --git a/libdevcore/miniz.h b/libdevcore/miniz.h index faf54532d..91b717452 100644 --- a/libdevcore/miniz.h +++ b/libdevcore/miniz.h @@ -569,14 +569,14 @@ typedef struct mz_dummy_time_t_tag { #define MZ_READ_LE16( p ) *( ( const mz_uint16* ) ( p ) ) #define MZ_READ_LE32( p ) *( ( const mz_uint32* ) ( p ) ) #else -#define MZ_READ_LE16( p ) \ - ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[0] ) | \ - ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[1] ) << 8U ) ) -#define MZ_READ_LE32( p ) \ - ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[0] ) | \ - ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[1] ) << 8U ) | \ - ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[2] ) << 16U ) | \ - ( ( mz_uint32 ) ( ( ( const mz_uint8* ) ( p ) )[3] ) << 24U ) ) +#define MZ_READ_LE16( p ) \ + ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[0] ) | \ + ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[1] ) << 8U ) ) +#define MZ_READ_LE32( p ) \ + ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[0] ) | \ + ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[1] ) << 8U ) | \ + ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[2] ) << 16U ) | \ + ( ( mz_uint32 )( ( ( const mz_uint8* ) ( p ) )[3] ) << 24U ) ) #endif #define MZ_READ_LE64( p ) \ @@ -858,7 +858,7 @@ void* tinfl_decompress_mem_to_heap( /* tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. */ /* Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. */ -#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ( ( size_t ) ( -1 ) ) +#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ( ( size_t )( -1 ) ) size_t tinfl_decompress_mem_to_mem( void* pOut_buf, size_t out_buf_len, const void* pSrc_buf, size_t src_buf_len, int flags ); diff --git a/libethashseal/EthashCPUMiner.cpp b/libethashseal/EthashCPUMiner.cpp index 88fc611ef..a4cbd2dfc 100644 --- a/libethashseal/EthashCPUMiner.cpp +++ b/libethashseal/EthashCPUMiner.cpp @@ -90,7 +90,7 @@ void EthashCPUMiner::minerBody() { auto result = ethash::hash( ethashContext, toEthash( w.headerHash() ), tryNonce ); h256 value = h256( result.final_hash.bytes, h256::ConstructFromPointer ); if ( value <= boundary && - submitProof( EthashProofOfWork::Solution{ ( h64 ) ( u64 ) tryNonce, + submitProof( EthashProofOfWork::Solution{ ( h64 )( u64 ) tryNonce, h256( result.mix_hash.bytes, h256::ConstructFromPointer ) } ) ) break; if ( !( hashCount % 100 ) ) diff --git a/libethereum/Block.h b/libethereum/Block.h index 7f38baf42..3dff5b034 100644 --- a/libethereum/Block.h +++ b/libethereum/Block.h @@ -282,26 +282,18 @@ class Block { * // unlock * @endcode */ - bool sealBlock( bytes const& _header ) { - return sealBlock( &_header ); - } + bool sealBlock( bytes const& _header ) { return sealBlock( &_header ); } bool sealBlock( bytesConstRef _header ); /// @returns true if sealed - in this case you can no longer append transactions. - bool isSealed() const { - return !m_currentBytes.empty(); - } + bool isSealed() const { return !m_currentBytes.empty(); } /// Get the complete current block, including valid nonce. /// Only valid when isSealed() is true. - bytes const& blockData() const { - return m_currentBytes; - } + bytes const& blockData() const { return m_currentBytes; } /// Get the header information on the present block. - BlockHeader const& info() const { - return m_currentBlock; - } + BlockHeader const& info() const { return m_currentBlock; } void startReadState(); @@ -320,9 +312,7 @@ class Block { std::vector< BlockHeader > const& _uncleBlockHeaders, u256 const& _blockReward ); /// @returns gas used by transactions thus far executed. - u256 gasUsed() const { - return m_receipts.size() ? m_receipts.back().cumulativeGasUsed() : 0; - } + u256 gasUsed() const { return m_receipts.size() ? m_receipts.back().cumulativeGasUsed() : 0; } /// Performs irregular modifications right after initialization, e.g. to implement a hard fork. void performIrregularModifications(); @@ -357,9 +347,7 @@ class Block { ; public: - static uint64_t howMany() { - return Counter< Block >::howMany(); - } + static uint64_t howMany() { return Counter< Block >::howMany(); } }; diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 0cdd90533..4e15e72eb 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -1373,9 +1373,7 @@ void BlockChain::clearCaches() { //} void BlockChain::checkConsistency() { - DEV_WRITE_GUARDED( x_details ) { - m_details.clear(); - } + DEV_WRITE_GUARDED( x_details ) { m_details.clear(); } m_blocksDB->forEach( [this]( db::Slice const& _key, db::Slice const& /* _value */ ) { if ( _key.size() == 32 ) { diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 03a88b4e3..9730bffc1 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -1176,9 +1176,7 @@ Block Client::blockByNumber( BlockNumber _h ) const { auto readState = m_state.createStateReadOnlyCopy(); readState.mutableHistoricState().setRootByBlockNumber( _h ); - DEV_GUARDED( m_blockImportMutex ) { - return Block( bc(), hash, readState ); - } + DEV_GUARDED( m_blockImportMutex ) { return Block( bc(), hash, readState ); } assert( false ); return Block( bc() ); } catch ( Exception& ex ) { @@ -1192,9 +1190,7 @@ Block Client::blockByNumber( BlockNumber _h ) const { Block Client::latestBlock() const { // TODO Why it returns not-filled block??! (see Block ctor) try { - DEV_GUARDED( m_blockImportMutex ) { - return Block( bc(), bc().currentHash(), m_state ); - } + DEV_GUARDED( m_blockImportMutex ) { return Block( bc(), bc().currentHash(), m_state ); } assert( false ); return Block( bc() ); } catch ( Exception& ex ) { @@ -1342,7 +1338,7 @@ ExecutionResult Client::call( Address const& _from, u256 _value, Address _dest, t.checkOutExternalGas( ~u256( 0 ) ); if ( _ff == FudgeFactor::Lenient ) { historicBlock.mutableState().mutableHistoricState().addBalance( - _from, ( u256 ) ( t.gas() * t.gasPrice() + t.value() ) ); + _from, ( u256 )( t.gas() * t.gasPrice() + t.value() ) ); } ret = historicBlock.executeHistoricCall( bc().lastBlockHashes(), t ); @@ -1366,8 +1362,7 @@ ExecutionResult Client::call( Address const& _from, u256 _value, Address _dest, t.forceChainId( chainParams().chainID ); t.checkOutExternalGas( ~u256( 0 ) ); if ( _ff == FudgeFactor::Lenient ) - temp.mutableState().addBalance( - _from, ( u256 ) ( t.gas() * t.gasPrice() + t.value() ) ); + temp.mutableState().addBalance( _from, ( u256 )( t.gas() * t.gasPrice() + t.value() ) ); ret = temp.execute( bc().lastBlockHashes(), t, skale::Permanence::Reverted ); } catch ( InvalidNonce const& in ) { LOG( m_logger ) << "exception in client call(1):" diff --git a/libethereum/Client.h b/libethereum/Client.h index abc7b9c85..64ebd96d1 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -129,13 +129,9 @@ class Client : public ClientBase, protected Worker { ImportResult queueBlock( bytes const& _block, bool _isSafe = false ); /// Get the remaining gas limit in this block. - u256 gasLimitRemaining() const override { - return m_postSeal.gasLimitRemaining(); - } + u256 gasLimitRemaining() const override { return m_postSeal.gasLimitRemaining(); } /// Get the gas bid price - u256 gasBidPrice() const override { - return m_gp->bid(); - } + u256 gasBidPrice() const override { return m_gp->bid(); } // [PRIVATE API - only relevant for base clients, not available in general] /// Get the block. @@ -147,36 +143,22 @@ class Client : public ClientBase, protected Worker { return m_postSeal; } /// Get the object representing the current canonical blockchain. - BlockChain const& blockChain() const { - return bc(); - } + BlockChain const& blockChain() const { return bc(); } /// Get some information on the block queue. - BlockQueueStatus blockQueueStatus() const { - return m_bq.status(); - } + BlockQueueStatus blockQueueStatus() const { return m_bq.status(); } /// Get some information on the block syncing. SyncStatus syncStatus() const override; /// Populate the uninitialized fields in the supplied transaction with default values TransactionSkeleton populateTransactionWithDefaults( TransactionSkeleton const& _t ) const override; /// Get the block queue. - BlockQueue const& blockQueue() const { - return m_bq; - } + BlockQueue const& blockQueue() const { return m_bq; } /// Get the state database. - skale::State const& state() const { - return m_state; - } + skale::State const& state() const { return m_state; } /// Get some information on the transaction queue. - TransactionQueue::Status transactionQueueStatus() const { - return m_tq.status(); - } - TransactionQueue::Limits transactionQueueLimits() const { - return m_tq.limits(); - } - TransactionQueue* debugGetTransactionQueue() { - return &m_tq; - } + TransactionQueue::Status transactionQueueStatus() const { return m_tq.status(); } + TransactionQueue::Limits transactionQueueLimits() const { return m_tq.limits(); } + TransactionQueue* debugGetTransactionQueue() { return &m_tq; } /// Freeze worker thread and sync some of the block queue. std::tuple< ImportRoute, bool, unsigned > syncQueue( unsigned _max = 1 ); @@ -195,13 +177,9 @@ class Client : public ClientBase, protected Worker { } /// Type of sealers available for this seal engine. - strings sealers() const { - return sealEngine()->sealers(); - } + strings sealers() const { return sealEngine()->sealers(); } /// Current sealer in use. - std::string sealer() const { - return sealEngine()->sealer(); - } + std::string sealer() const { return sealEngine()->sealer(); } /// Change sealer. void setSealer( std::string const& _id ) { sealEngine()->setSealer( _id ); @@ -209,9 +187,7 @@ class Client : public ClientBase, protected Worker { startSealing(); } /// Review option for the sealer. - bytes sealOption( std::string const& _name ) const { - return sealEngine()->option( _name ); - } + bytes sealOption( std::string const& _name ) const { return sealEngine()->option( _name ); } /// Set option for the sealer. bool setSealOption( std::string const& _name, bytes const& _value ) { auto ret = sealEngine()->setOption( _name, _value ); @@ -223,13 +199,9 @@ class Client : public ClientBase, protected Worker { /// Start sealing. void startSealing() override; /// Stop sealing. - void stopSealing() override { - m_wouldSeal = false; - } + void stopSealing() override { m_wouldSeal = false; } /// Are we sealing now? - bool wouldSeal() const override { - return m_wouldSeal; - } + bool wouldSeal() const override { return m_wouldSeal; } /// Are we updating the chain (syncing or importing a new block)? bool isSyncing() const override; @@ -242,9 +214,7 @@ class Client : public ClientBase, protected Worker { void setNetworkId( u256 const& _n ) override; /// Get the seal engine. - SealEngineFace* sealEngine() const override { - return bc().sealEngine(); - } + SealEngineFace* sealEngine() const override { return bc().sealEngine(); } // Debug stuff: @@ -252,9 +222,7 @@ class Client : public ClientBase, protected Worker { /// Clears pending transactions. Just for debug use. void clearPending(); /// Retries all blocks with unknown parents. - void retryUnknown() { - m_bq.retryAllUnknown(); - } + void retryUnknown() { m_bq.retryAllUnknown(); } /// Get a report of activity. ActivityReport activityReport() { ActivityReport ret; @@ -262,13 +230,9 @@ class Client : public ClientBase, protected Worker { return ret; } /// Set the extra data that goes into sealed blocks. - void setExtraData( bytes const& _extraData ) { - m_extraData = _extraData; - } + void setExtraData( bytes const& _extraData ) { m_extraData = _extraData; } /// Rescue the chain. - void rescue() { - bc().rescue( m_state ); - } + void rescue() { bc().rescue( m_state ); } std::unique_ptr< StateImporterFace > createStateImporter() { throw std::logic_error( "createStateImporter is not implemented" ); @@ -297,9 +261,7 @@ class Client : public ClientBase, protected Worker { return m_onBlockSealed.add( _handler ); } - std::shared_ptr< SkaleHost > skaleHost() const { - return m_skaleHost; - } + std::shared_ptr< SkaleHost > skaleHost() const { return m_skaleHost; } // main entry point after consensus size_t importTransactionsAsBlock( const Transactions& _transactions, u256 _gasPrice, @@ -335,13 +297,9 @@ class Client : public ClientBase, protected Worker { return this->m_snapshotManager->getBlockTimestamp( _blockNumber, chainParams() ); } - int64_t getLatestSnapshotBlockNumer() const { - return this->last_snapshoted_block_with_hash; - } + int64_t getLatestSnapshotBlockNumer() const { return this->last_snapshoted_block_with_hash; } - uint64_t getSnapshotCalculationTime() const { - return this->snapshot_calculation_time_ms; - } + uint64_t getSnapshotCalculationTime() const { return this->snapshot_calculation_time_ms; } uint64_t getSnapshotHashCalculationTime() const { return this->snapshot_hash_calculation_time_ms; @@ -367,17 +325,11 @@ class Client : public ClientBase, protected Worker { uint64_t submitOracleRequest( const string& _spec, string& _receipt ); uint64_t checkOracleResult( const string& _receipt, string& _result ); - SkaleDebugInterface::handler getDebugHandler() const { - return m_debugHandler; - } + SkaleDebugInterface::handler getDebugHandler() const { return m_debugHandler; } #ifdef HISTORIC_STATE - OverlayDB const& historicStateDB() const { - return m_historicStateDB; - } - OverlayDB const& historicBlockToStateRootDB() const { - return m_historicBlockToStateRootDB; - } + OverlayDB const& historicStateDB() const { return m_historicStateDB; } + OverlayDB const& historicBlockToStateRootDB() const { return m_historicBlockToStateRootDB; } #endif protected: @@ -401,12 +353,8 @@ class Client : public ClientBase, protected Worker { void init( WithExisting _forceAction, u256 _networkId ); /// InterfaceStub methods - BlockChain& bc() override { - return m_bc; - } - BlockChain const& bc() const override { - return m_bc; - } + BlockChain& bc() override { return m_bc; } + BlockChain const& bc() const override { return m_bc; } /// Returns the state object for the full block (i.e. the terminal state) for index _h. /// Works properly with LatestBlock and PendingBlock. @@ -447,9 +395,7 @@ class Client : public ClientBase, protected Worker { /// Do some work. Handles blockchain maintenance and sealing. void doWork( bool _doWait ); - void doWork() override { - doWork( true ); - } + void doWork() override { doWork( true ); } /// Called when Worker is exiting. void doneWorking() override; diff --git a/libethereum/ClientBase.cpp b/libethereum/ClientBase.cpp index 6ebe47140..a20c2f9b3 100644 --- a/libethereum/ClientBase.cpp +++ b/libethereum/ClientBase.cpp @@ -93,7 +93,7 @@ std::pair< bool, ExecutionResult > ClientBase::estimateGasStep( int64_t _gas, Bl EnvInfo const env( _latestBlock.info(), bc().lastBlockHashes(), 0, _gas ); // Make a copy of state!! It will be deleted after step! State tempState = _latestBlock.mutableState(); - tempState.addBalance( _from, ( u256 ) ( t.gas() * t.gasPrice() + t.value() ) ); + tempState.addBalance( _from, ( u256 )( t.gas() * t.gasPrice() + t.value() ) ); ExecutionResult executionResult = tempState.execute( env, *bc().sealEngine(), t, Permanence::Reverted ).first; if ( executionResult.excepted == TransactionException::OutOfGas || diff --git a/libethereum/ClientBase.h b/libethereum/ClientBase.h index 7fbf3ff43..ab4b7a812 100644 --- a/libethereum/ClientBase.h +++ b/libethereum/ClientBase.h @@ -74,9 +74,7 @@ struct ClientWatch { mutable std::chrono::system_clock::time_point lastPoll = std::chrono::system_clock::now(); - bool isWS() const { - return isWS_; - }; + bool isWS() const { return isWS_; }; }; class ClientBase : public Interface { diff --git a/libethereum/Executive.cpp b/libethereum/Executive.cpp index efafe1107..2ab8015e5 100644 --- a/libethereum/Executive.cpp +++ b/libethereum/Executive.cpp @@ -321,7 +321,7 @@ bool Executive::call( CallParameters const& _p, u256 const& _gasPrice, Address c return true; // true actually means "all finished - nothing more to be done regarding // go(). } else { - m_gas = ( u256 ) ( _p.gas - g ); + m_gas = ( u256 )( _p.gas - g ); bytes output; bool success; // dev::eth::g_state = m_s.delegateWrite(); diff --git a/libethereum/Interface.h b/libethereum/Interface.h index a61ca7fc2..a6c1c874f 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -118,9 +118,7 @@ class Interface { // [STATE-QUERY API] - int getDefault() const { - return PendingBlock; - } + int getDefault() const { return PendingBlock; } void setDefault( BlockNumber /*_block*/ ) { throw std::logic_error( "setDefault is not supported" ); } @@ -204,16 +202,10 @@ class Interface { virtual Transactions transactions( BlockNumber _block ) const = 0; virtual TransactionHashes transactionHashes( h256 _blockHash ) const = 0; - virtual BlockHeader pendingInfo() const { - return BlockHeader(); - } - virtual BlockDetails pendingDetails() const { - return BlockDetails(); - } + virtual BlockHeader pendingInfo() const { return BlockHeader(); } + virtual BlockDetails pendingDetails() const { return BlockDetails(); } /// @returns the EVMSchedule in the context of the pending block. - virtual EVMSchedule evmSchedule() const { - return EVMSchedule(); - } + virtual EVMSchedule evmSchedule() const { return EVMSchedule(); } BlockHeader blockInfo( BlockNumber _block ) const; BlockDetails blockDetails( BlockNumber _block ) const; @@ -276,30 +268,20 @@ class Interface { virtual bool wouldSeal() const = 0; /// Are we updating the chain (syncing or importing a new block)? - virtual bool isSyncing() const { - return false; - } + virtual bool isSyncing() const { return false; } /// Are we syncing the chain? - virtual bool isMajorSyncing() const { - return false; - } + virtual bool isMajorSyncing() const { return false; } /// Gets the network id. - virtual u256 networkId() const { - return 0; - } + virtual u256 networkId() const { return 0; } /// Sets the network id. virtual void setNetworkId( u256 const& ) {} /// Gets the chain id - virtual uint64_t chainId() const { - return 0; - } + virtual uint64_t chainId() const { return 0; } /// Get the seal engine. - virtual SealEngineFace* sealEngine() const { - return nullptr; - } + virtual SealEngineFace* sealEngine() const { return nullptr; } public: // new block watch diff --git a/libethereum/TransactionQueue.h b/libethereum/TransactionQueue.h index c1cd28fa5..31bbd2340 100644 --- a/libethereum/TransactionQueue.h +++ b/libethereum/TransactionQueue.h @@ -147,9 +147,7 @@ class TransactionQueue { /// @returns the status of the transaction queue. Status status() const { Status ret; - DEV_GUARDED( x_queue ) { - ret.unverified = m_unverified.size(); - } + DEV_GUARDED( x_queue ) { ret.unverified = m_unverified.size(); } ReadGuard l( m_lock ); ret.dropped = m_dropped.size(); ret.current = m_currentByHash.size(); diff --git a/libevm/LegacyVM.cpp b/libevm/LegacyVM.cpp index 06f7ed735..8a0775112 100644 --- a/libevm/LegacyVM.cpp +++ b/libevm/LegacyVM.cpp @@ -27,12 +27,12 @@ uint64_t LegacyVM::memNeed( u256 const& _offset, u256 const& _size ) { template < class S > S divWorkaround( S const& _a, S const& _b ) { - return ( S ) ( s512( _a ) / s512( _b ) ); + return ( S )( s512( _a ) / s512( _b ) ); } template < class S > S modWorkaround( S const& _a, S const& _b ) { - return ( S ) ( s512( _a ) % s512( _b ) ); + return ( S )( s512( _a ) % s512( _b ) ); } @@ -353,7 +353,7 @@ void LegacyVM::interpretCases() { updateMem( toInt63( m_SP[0] ) + 1 ); updateIOGas(); - m_mem[( unsigned ) m_SP[0]] = ( _byte_ ) ( m_SP[1] & 0xff ); + m_mem[( unsigned ) m_SP[0]] = ( _byte_ )( m_SP[1] & 0xff ); } NEXT @@ -1082,9 +1082,7 @@ void LegacyVM::interpretCases() { CASE( XPUT ) CASE( XGET ) CASE( XSWIZZLE ) - CASE( XSHUFFLE ) { - throwBadInstruction(); - } + CASE( XSHUFFLE ) { throwBadInstruction(); } CONTINUE #endif diff --git a/libevm/LegacyVM.h b/libevm/LegacyVM.h index 085946c4d..8a5e20704 100644 --- a/libevm/LegacyVM.h +++ b/libevm/LegacyVM.h @@ -35,9 +35,7 @@ class LegacyVM : public VMFace { void validateSubroutine( uint64_t _PC, uint64_t* _rp, u256* _sp ); #endif - bytes const& memory() const { - return m_mem; - } + bytes const& memory() const { return m_mem; } u256s stack() const { u256s stack( m_SP, m_stackEnd ); reverse( stack.begin(), stack.end() ); @@ -75,9 +73,7 @@ class LegacyVM : public VMFace { // space for data stack, grows towards smaller addresses from the end u256 m_stack[1024]; u256* m_stackEnd = &m_stack[1024]; - size_t stackSize() { - return m_stackEnd - m_SP; - } + size_t stackSize() { return m_stackEnd - m_SP; } #if EIP_615 // space for return stack diff --git a/libevm/LegacyVMCalls.cpp b/libevm/LegacyVMCalls.cpp index f9f4b0da5..ff6beb71d 100644 --- a/libevm/LegacyVMCalls.cpp +++ b/libevm/LegacyVMCalls.cpp @@ -69,7 +69,7 @@ void LegacyVM::throwBadStack( unsigned _removed, unsigned _added ) { if ( m_onFail ) ( this->*m_onFail )(); BOOST_THROW_EXCEPTION( - OutOfStack() << RequirementError( ( bigint ) ( _added - _removed ), size ) ); + OutOfStack() << RequirementError( ( bigint )( _added - _removed ), size ) ); } } diff --git a/libhistoric/AlethExecutive.cpp b/libhistoric/AlethExecutive.cpp index 36698d9e8..ebc687dd0 100644 --- a/libhistoric/AlethExecutive.cpp +++ b/libhistoric/AlethExecutive.cpp @@ -175,7 +175,7 @@ bool AlethExecutive::call( return true; // true actually means "all finished - nothing more to be done regarding // go(). } else { - m_gas = ( u256 ) ( _p.gas - g ); + m_gas = ( u256 )( _p.gas - g ); bytes output; bool success; tie( success, output ) = diff --git a/libskale-interpreter/VM.cpp b/libskale-interpreter/VM.cpp index 4e88a1a15..6d414ff12 100644 --- a/libskale-interpreter/VM.cpp +++ b/libskale-interpreter/VM.cpp @@ -107,12 +107,12 @@ uint64_t VM::memNeed( u256 const& _offset, u256 const& _size ) { template < class S > S divWorkaround( S const& _a, S const& _b ) { - return ( S ) ( s512( _a ) / s512( _b ) ); + return ( S )( s512( _a ) / s512( _b ) ); } template < class S > S modWorkaround( S const& _a, S const& _b ) { - return ( S ) ( s512( _a ) % s512( _b ) ); + return ( S )( s512( _a ) % s512( _b ) ); } @@ -374,7 +374,7 @@ void VM::interpretCases() { updateMem( toInt63( m_SP[0] ) + 1 ); updateIOGas(); - m_mem[( unsigned ) m_SP[0]] = ( _byte_ ) ( m_SP[1] & 0xff ); + m_mem[( unsigned ) m_SP[0]] = ( _byte_ )( m_SP[1] & 0xff ); } NEXT @@ -779,9 +779,7 @@ void VM::interpretCases() { CASE( XPUT ) CASE( XGET ) CASE( XSWIZZLE ) - CASE( XSHUFFLE ) { - throwBadInstruction(); - } + CASE( XSHUFFLE ) { throwBadInstruction(); } CONTINUE CASE( ADDRESS ) { diff --git a/libskale-interpreter/VMCalls.cpp b/libskale-interpreter/VMCalls.cpp index c3723318f..c4d084bc0 100644 --- a/libskale-interpreter/VMCalls.cpp +++ b/libskale-interpreter/VMCalls.cpp @@ -66,7 +66,7 @@ void VM::throwBadStack( int _removed, int _added ) { BOOST_THROW_EXCEPTION( StackUnderflow() << RequirementError( ( bigint ) _removed, size ) ); else BOOST_THROW_EXCEPTION( - OutOfStack() << RequirementError( ( bigint ) ( _added - _removed ), size ) ); + OutOfStack() << RequirementError( ( bigint )( _added - _removed ), size ) ); } void VM::throwRevertInstruction( owning_bytes_ref&& _output ) { diff --git a/libskale/State.h b/libskale/State.h index 3e81b770b..ee7a827e6 100644 --- a/libskale/State.h +++ b/libskale/State.h @@ -356,9 +356,7 @@ class State { dev::eth::OnOpFunc const& _onOp = dev::eth::OnOpFunc() ); /// Get the account start nonce. May be required. - dev::u256 const& accountStartNonce() const { - return m_accountStartNonce; - } + dev::u256 const& accountStartNonce() const { return m_accountStartNonce; } dev::u256 const& requireAccountStartNonce() const; void noteAccountStartNonce( dev::u256 const& _actual ); @@ -369,9 +367,7 @@ class State { /// Revert all recent changes up to the given @p _savepoint savepoint. void rollback( size_t _savepoint ); - ChangeLog const& changeLog() const { - return m_changeLog; - } + ChangeLog const& changeLog() const { return m_changeLog; } /// Create State copy to get access to data. /// Different copies can be safely used in different threads @@ -519,9 +515,7 @@ class State { public: /// Get the backing state object. - dev::eth::HistoricState& mutableHistoricState() { - return m_historicState; - } + dev::eth::HistoricState& mutableHistoricState() { return m_historicState; } dev::eth::AccountMap getBatchOfAccounts( std::unordered_map< dev::Address, dev::u256 >& _allAccountAddresses, @@ -535,9 +529,7 @@ class State { pDB = m_db_ptr->db(); return pDB; } - std::shared_ptr< OverlayFS > fs() { - return m_fs_ptr; - } + std::shared_ptr< OverlayFS > fs() { return m_fs_ptr; } }; std::ostream& operator<<( std::ostream& _out, State const& _s ); diff --git a/libskutils/include/skutils/dispatch.h b/libskutils/include/skutils/dispatch.h index 1c7ba5066..1b6c5bea4 100644 --- a/libskutils/include/skutils/dispatch.h +++ b/libskutils/include/skutils/dispatch.h @@ -405,9 +405,7 @@ class loop : public ref_retain_release { ~loop(); loop& operator=( const loop& ) = delete; loop& operator=( loop&& ) = delete; - uv_loop_s* internal_handle() { - return p_uvLoop_; - } + uv_loop_s* internal_handle() { return p_uvLoop_; } mutex_type& loop_mtx() const; static loop_ptr_t get_current(); bool is_running() const; diff --git a/libskutils/include/skutils/http.h b/libskutils/include/skutils/http.h index 954ca8ccd..4ba9b967e 100644 --- a/libskutils/include/skutils/http.h +++ b/libskutils/include/skutils/http.h @@ -436,9 +436,7 @@ class server : public common { bool is_running() const; void stop(); - virtual bool is_ssl() const { - return false; - } + virtual bool is_ssl() const { return false; } protected: bool process_request( @@ -495,9 +493,7 @@ class server : public common { void remove_all_tasks(); public: - bool is_in_loop() const { - return is_in_loop_; - } + bool is_in_loop() const { return is_in_loop_; } void wait_while_in_loop() const { while ( is_in_loop() ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); diff --git a/libskutils/include/skutils/rest_call.h b/libskutils/include/skutils/rest_call.h index 4de8dee25..ebdb0943f 100644 --- a/libskutils/include/skutils/rest_call.h +++ b/libskutils/include/skutils/rest_call.h @@ -149,9 +149,7 @@ class client { client( const char* url_str, long nClientConnectionTimeoutMS = -1 ); virtual ~client(); - const skutils::url& url() const { - return u_; - } + const skutils::url& url() const { return u_; } bool open( const skutils::url& u, std::chrono::milliseconds wait_step = std::chrono::milliseconds( 20 ), diff --git a/libskutils/src/http.cpp b/libskutils/src/http.cpp index 4569a34c3..a0ece1234 100644 --- a/libskutils/src/http.cpp +++ b/libskutils/src/http.cpp @@ -1431,7 +1431,7 @@ bool async_read_and_close_socket_base::schedule_check_clock() { if ( retry_index_ > retry_count_ ) return false; clock_t tpNow = clock(); - clock_t tpMin = ( clock_t ) ( ( retry_index_ == 0 ) ? retry_first_ms_ : retry_after_ms_ ); + clock_t tpMin = ( clock_t )( ( retry_index_ == 0 ) ? retry_first_ms_ : retry_after_ms_ ); clock_t tpDist = tpNow - tpStep_; if ( tpDist < tpMin ) return false; // too early diff --git a/libskutils/src/rest_call.cpp b/libskutils/src/rest_call.cpp index 312a0dfaa..467226ef5 100644 --- a/libskutils/src/rest_call.cpp +++ b/libskutils/src/rest_call.cpp @@ -624,8 +624,7 @@ std::string client::stat_extract_short_content_type_string( const std::string& s } uint64_t client::stat_get_random_number( uint64_t const& min, uint64_t const& max ) { - return ( ( ( uint64_t ) ( unsigned int ) rand() << 32 ) + - ( uint64_t ) ( unsigned int ) rand() ) % + return ( ( ( uint64_t )( unsigned int ) rand() << 32 ) + ( uint64_t )( unsigned int ) rand() ) % ( max - min ) + min; } diff --git a/libskutils/src/utils.cpp b/libskutils/src/utils.cpp index eedcfc5e4..1c398316c 100644 --- a/libskutils/src/utils.cpp +++ b/libskutils/src/utils.cpp @@ -1038,7 +1038,7 @@ void md5::finalize() { // save number of bits encode( bits, count, 8 ); // pad out to 56 mod 64. - index = ( uint4 ) ( ( count[0] >> 3 ) & 0x3f ); + index = ( uint4 )( ( count[0] >> 3 ) & 0x3f ); padLen = ( index < 56 ) ? ( 56 - index ) : ( 120 - index ); update( PADDING, padLen ); update( bits, 8 ); // append length (before padding) @@ -1203,10 +1203,10 @@ void md5::encode( uint1* output, uint4* input, uint4 len ) { // Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. unsigned int i, j; for ( i = 0, j = 0; j < len; i++, j += 4 ) { - output[j] = ( uint1 ) ( input[i] & 0xff ); - output[j + 1] = ( uint1 ) ( ( input[i] >> 8 ) & 0xff ); - output[j + 2] = ( uint1 ) ( ( input[i] >> 16 ) & 0xff ); - output[j + 3] = ( uint1 ) ( ( input[i] >> 24 ) & 0xff ); + output[j] = ( uint1 )( input[i] & 0xff ); + output[j + 1] = ( uint1 )( ( input[i] >> 8 ) & 0xff ); + output[j + 2] = ( uint1 )( ( input[i] >> 16 ) & 0xff ); + output[j + 3] = ( uint1 )( ( input[i] >> 24 ) & 0xff ); } } void md5::decode( uint4* output, uint1* input, uint4 len ) { diff --git a/libweb3jsonrpc/IpcServerBase.cpp b/libweb3jsonrpc/IpcServerBase.cpp index 2bb75ec24..539216571 100644 --- a/libweb3jsonrpc/IpcServerBase.cpp +++ b/libweb3jsonrpc/IpcServerBase.cpp @@ -72,7 +72,7 @@ template < class S > bool IpcServerBase< S >::SendResponse( string const& _response, void* _addInfo ) { bool fullyWritten = false; bool errorOccured = false; - S socket = ( S ) ( reinterpret_cast< intptr_t >( _addInfo ) ); + S socket = ( S )( reinterpret_cast< intptr_t >( _addInfo ) ); string toSend = _response; do { size_t bytesWritten = Write( socket, toSend ); diff --git a/skale-vm/main.cpp b/skale-vm/main.cpp index af8296de1..50c4cc55d 100644 --- a/skale-vm/main.cpp +++ b/skale-vm/main.cpp @@ -281,7 +281,8 @@ int main( int argc, char** argv ) { std::string strCode{ reinterpret_cast< char const* >( code.data() ), code.size() }; strCode.erase( strCode.find_last_not_of( " \t\n\r" ) + 1 ); // Right trim. code = fromHex( strCode, WhenError::Throw ); - } catch ( BadHexCharacter const& ) { + } + catch ( BadHexCharacter const& ) { } // Ignore decoding errors. } diff --git a/skaled/main.cpp b/skaled/main.cpp index 18893140b..3315ca09b 100644 --- a/skaled/main.cpp +++ b/skaled/main.cpp @@ -1820,7 +1820,7 @@ int main( int argc, char** argv ) try { "Unknown seal engine: " + chainParams.sealEngineName ) ); g_client->dbRotationPeriod( - ( ( clock_t ) ( clockDbRotationPeriodInSeconds ) ) * CLOCKS_PER_SEC ); + ( ( clock_t )( clockDbRotationPeriodInSeconds ) ) * CLOCKS_PER_SEC ); // XXX nested lambdas and strlen hacks.. auto client_debug_handler = g_client->getDebugHandler(); From 3fb89cf274653d240aa7ab92c62b3342d198d97c Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Mon, 3 Apr 2023 20:45:29 +0100 Subject: [PATCH 17/19] 709 complete oracle (#1487) * 709 complete oracle * 709 complete oracle * 709 complete oracle * 709 complete oracle * 709 complete oracle --- libconsensus | 2 +- libweb3jsonrpc/Skale.cpp | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/libconsensus b/libconsensus index ad673965d..84582a3d4 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit ad673965d6ac193ded024a427c76c67df63663aa +Subproject commit 84582a3d4090f1c65c2c09feff943ca784f02a5c diff --git a/libweb3jsonrpc/Skale.cpp b/libweb3jsonrpc/Skale.cpp index cc53ce299..c5da167a7 100644 --- a/libweb3jsonrpc/Skale.cpp +++ b/libweb3jsonrpc/Skale.cpp @@ -517,34 +517,34 @@ Json::Value Skale::skale_getDBUsage() { std::string Skale::oracle_submitRequest( std::string& request ) { try { - if ( this->m_client.chainParams().nodeInfo.syncNode ) + if ( m_client.chainParams().nodeInfo.syncNode ) throw std::runtime_error( "Oracle is disabled on this instance" ); std::string receipt; - uint64_t status = this->m_client.submitOracleRequest( request, receipt ); - if ( status != 0 ) { + // this function is guaranteed not to throw exceptions + uint64_t status = m_client.submitOracleRequest( request, receipt ); + if ( status != ORACLE_SUCCESS ) { throw jsonrpc::JsonRpcException( status, skutils::tools::format( "Oracle request failed with status %zu", status ) ); } return receipt; } catch ( jsonrpc::JsonRpcException const& e ) { throw e; - } catch ( InvalidStateException const& e ) { - throw e; } catch ( const std::exception& e ) { - throw jsonrpc::JsonRpcException( jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, e.what() ); + throw jsonrpc::JsonRpcException( ORACLE_INTERNAL_SERVER_ERROR, e.what() ); } } std::string Skale::oracle_checkResult( std::string& receipt ) { try { - if ( this->m_client.chainParams().nodeInfo.syncNode ) + if ( m_client.chainParams().nodeInfo.syncNode ) throw std::runtime_error( "Oracle is disabled on this instance" ); std::string result; - uint64_t status = this->m_client.checkOracleResult( receipt, result ); + // this function is guaranteed not to throw exceptions + uint64_t status = m_client.checkOracleResult( receipt, result ); switch ( status ) { - case 0: + case ORACLE_SUCCESS: break; - case 5: + case ORACLE_RESULT_NOT_READY: throw jsonrpc::JsonRpcException( status, "Oracle result is not ready" ); default: throw jsonrpc::JsonRpcException( @@ -553,10 +553,8 @@ std::string Skale::oracle_checkResult( std::string& receipt ) { return result; } catch ( jsonrpc::JsonRpcException const& e ) { throw e; - } catch ( InvalidStateException const& e ) { - throw e; } catch ( const std::exception& e ) { - throw jsonrpc::JsonRpcException( jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, e.what() ); + throw jsonrpc::JsonRpcException( ORACLE_INTERNAL_SERVER_ERROR, e.what() ); } } From 264c5b93b8c58194e22ec2d2c15209786e674f8d Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Tue, 4 Apr 2023 19:01:38 +0100 Subject: [PATCH 18/19] 704 update consensus with fix for checkstate --- libconsensus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libconsensus b/libconsensus index 84582a3d4..9c10f8749 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit 84582a3d4090f1c65c2c09feff943ca784f02a5c +Subproject commit 9c10f87494b751ebcf0dffa2e20590bffa5cbde9 From 5d8fcc76848ef339d619909cff0f799ed5592f4e Mon Sep 17 00:00:00 2001 From: Dmytro Nazarenko Date: Wed, 5 Apr 2023 13:25:22 +0300 Subject: [PATCH 19/19] Update on_pr.yml --- .github/workflows/on_pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on_pr.yml b/.github/workflows/on_pr.yml index dab566c44..7eddeb3b6 100644 --- a/.github/workflows/on_pr.yml +++ b/.github/workflows/on_pr.yml @@ -5,7 +5,7 @@ on: types: [opened] jobs: main_job: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest name: Add some useful instructions to PR creator steps: - uses: actions/checkout@v1