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/.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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 84337233e..6f4062e96 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 @@ -120,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 @@ -133,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 @@ -146,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##*/} @@ -155,22 +153,22 @@ 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 - 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 + prerelease: ${{ env.PRERELEASE }} - 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 }} @@ -180,7 +178,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##*/} @@ -192,7 +189,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 }} 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: | diff --git a/README.md b/README.md index 6e625db81..e20d1df9f 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 clang-format-11 ``` 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 ``` diff --git a/VERSION b/VERSION index 1eeac129c..ffaa55f59 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.16.0 +3.16.1 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/libconsensus b/libconsensus index ad673965d..93f47e966 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit ad673965d6ac193ded024a427c76c67df63663aa +Subproject commit 93f47e9661addf2312f691fad49b0a0a73b28805 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/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/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/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index f6eb085d9..4e15e72eb 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 ( ... ) { 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..bbbc0c653 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 ) ); } } @@ -1513,11 +1512,12 @@ uint64_t Client::getHistoricRootsDbUsage() const { } #endif // HISTORIC_STATE -uint64_t Client::submitOracleRequest( const string& _spec, string& _receipt ) { +uint64_t Client::submitOracleRequest( + const string& _spec, string& _receipt, string& _errorMessage ) { assert( m_skaleHost ); uint64_t status = -1; if ( m_skaleHost ) - status = m_skaleHost->submitOracleRequest( _spec, _receipt ); + status = m_skaleHost->submitOracleRequest( _spec, _receipt, _errorMessage ); else throw runtime_error( "Instance of SkaleHost was not properly created." ); return status; diff --git a/libethereum/Client.h b/libethereum/Client.h index 64ebd96d1..b4a8ed68b 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -322,7 +322,7 @@ class Client : public ClientBase, protected Worker { uint64_t getHistoricRootsDbUsage() const; #endif // HISTORIC_STATE - uint64_t submitOracleRequest( const string& _spec, string& _receipt ); + uint64_t submitOracleRequest( const string& _spec, string& _receipt, string& _errorMessage ); uint64_t checkOracleResult( const string& _receipt, string& _result ); SkaleDebugInterface::handler getDebugHandler() const { return m_debugHandler; } diff --git a/libethereum/SkaleHost.cpp b/libethereum/SkaleHost.cpp index 1df6da4dc..32c06ebc6 100644 --- a/libethereum/SkaleHost.cpp +++ b/libethereum/SkaleHost.cpp @@ -983,8 +983,9 @@ std::array< std::string, 4 > SkaleHost::getIMABLSPublicKey() const { return m_client.getIMABLSPublicKey(); } -uint64_t SkaleHost::submitOracleRequest( const string& _spec, string& _receipt ) { - return m_consensus->submitOracleRequest( _spec, _receipt ); +uint64_t SkaleHost::submitOracleRequest( + const string& _spec, string& _receipt, string& _errorMessage ) { + return m_consensus->submitOracleRequest( _spec, _receipt, _errorMessage ); } uint64_t SkaleHost::checkOracleResult( const string& _receipt, string& _result ) { diff --git a/libethereum/SkaleHost.h b/libethereum/SkaleHost.h index 3f3a7ed81..05194ffe2 100644 --- a/libethereum/SkaleHost.h +++ b/libethereum/SkaleHost.h @@ -127,7 +127,7 @@ class SkaleHost { std::map< std::string, uint64_t > getConsensusDbUsage() const; std::array< std::string, 4 > getIMABLSPublicKey() const; - uint64_t submitOracleRequest( const string& _spec, string& _receipt ); + uint64_t submitOracleRequest( const string& _spec, string& _receipt, string& _errorMessage ); uint64_t checkOracleResult( const string& _receipt, string& _result ); void pauseConsensus( bool _pause ) { 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/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 ) { diff --git a/libskale/State.cpp b/libskale/State.cpp index a73d53272..2411e193e 100644 --- a/libskale/State.cpp +++ b/libskale/State.cpp @@ -1100,7 +1100,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/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/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 16af2cc1c..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 %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}; diff --git a/libweb3jsonrpc/Skale.cpp b/libweb3jsonrpc/Skale.cpp index cc53ce299..a1d83e5c8 100644 --- a/libweb3jsonrpc/Skale.cpp +++ b/libweb3jsonrpc/Skale.cpp @@ -517,46 +517,47 @@ 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 ) { - throw jsonrpc::JsonRpcException( - status, skutils::tools::format( "Oracle request failed with status %zu", status ) ); + std::string errorMessage; + + clog( VerbosityDebug, "Oracle request:" ) << request; + + uint64_t status = this->m_client.submitOracleRequest( request, receipt, errorMessage ); + if ( status != ORACLE_SUCCESS ) { + throw jsonrpc::JsonRpcException( status, errorMessage ); } 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( status, skutils::tools::format( "Oracle request failed with status %zu", status ) ); } + clog( VerbosityDebug, "Oracle result:" ) << result; 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() ); } } 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++ )) diff --git a/scripts/skale_build/Dockerfile b/scripts/skale_build/Dockerfile index 28641df6f..002020c05 100644 --- a/scripts/skale_build/Dockerfile +++ b/scripts/skale_build/Dockerfile @@ -1,4 +1,5 @@ -FROM ubuntu:18.04 +FROM ubuntu:20.04 +ENV DEBIAN_FRONTEND=noninteractive RUN apt-get -q update && \ apt-get -qy install \ 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/test/unittests/libethereum/SkaleHost.cpp b/test/unittests/libethereum/SkaleHost.cpp index 05f469d38..2069b3a91 100644 --- a/test/unittests/libethereum/SkaleHost.cpp +++ b/test/unittests/libethereum/SkaleHost.cpp @@ -81,7 +81,7 @@ class ConsensusTestStub : public ConsensusInterface { } uint64_t submitOracleRequest( const string& /*_spec*/, string& - /*_receipt*/) override { + /*_receipt*/, string& ) override { return 0; } diff --git a/test/unittests/libweb3jsonrpc/jsonrpc.cpp b/test/unittests/libweb3jsonrpc/jsonrpc.cpp index a6b762b08..2e7e84d03 100644 --- a/test/unittests/libweb3jsonrpc/jsonrpc.cpp +++ b/test/unittests/libweb3jsonrpc/jsonrpc.cpp @@ -2902,7 +2902,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 );