From 460ebb05b48e80ffc410e1d4205dbaa2a0bb3f33 Mon Sep 17 00:00:00 2001
From: Dima Litvinov <dima.litvinov@skalelabs.com>
Date: Fri, 29 Dec 2023 15:48:03 +0000
Subject: [PATCH 1/7] SKALED-1714 testeth on historic build

---
 .github/workflows/test.yml | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 49803f389..2c955ca7f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -215,7 +215,7 @@ jobs:
           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 ..
+          cd ../..
       - name: Testeth verbosity 4
         run : |
           # Since a tests failed, we are rerunning the failed test with higher verbosity          
@@ -266,23 +266,22 @@ jobs:
           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: Create lcov report
         run: |
-          lcov --capture --directory . --output-file coverage.info
+          lcov --capture --directory build/test --output-file coverage.info
           lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter system-files
           lcov --remove coverage.info 'deps/*' --output-file coverage.info # filter dependency files
           lcov --remove coverage.info 'libconsensus/deps/*' --output-file coverage.info # filter dependency files
           lcov --remove coverage.info 'libconsensus/libBLS/deps/*' --output-file coverage.info # filter dependency files
           lcov --remove coverage.info '.hunter/*' --output-file coverage.info # filter dependency files
-           
+
       - name: Upload to Codecov
         uses: codecov/codecov-action@v3
         with:
           token: ${{ secrets.CODECOV_TOKEN }}
           files: ./coverage.info
-    
+
       - name: Configure all as historic
         run: |
           export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
@@ -310,3 +309,9 @@ jobs:
       - name: Print ccache stats after full historic build
         run : |
           ccache --show-stats
+      - name: Testeth historic
+        run : |
+          cd build/test
+          export NO_NTP_CHECK=1
+          export NO_ULIMIT_CHECK=1
+          ./testeth -t JsonRpcSuite -- --express --verbosity 4

From 4881ccd0650ce90e0ee7471225c7c3a9145a9497 Mon Sep 17 00:00:00 2001
From: Dima Litvinov <dima.litvinov@skalelabs.com>
Date: Fri, 29 Dec 2023 16:09:07 +0000
Subject: [PATCH 2/7] SKALED-1714 Temporarily disable normal build

---
 .github/workflows/test.yml | 149 -------------------------------------
 1 file changed, 149 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 2c955ca7f..08ec93804 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -122,7 +122,6 @@ jobs:
           ccache --show-stats
       - name: Build dependencies
         run: |
-          
           export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
           export CC=gcc-9
           export CXX=g++-9
@@ -134,154 +133,6 @@ jobs:
           rm -f ./libwebsockets-from-git.tar.gz
           ./build.sh DEBUG=1 PARALLEL_COUNT=$(nproc)
           cd ..
-      - name: Configure all
-        run: |
-          export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
-          export CC=gcc-9
-          export CXX=g++-9
-          export TARGET=all
-          export CMAKE_BUILD_TYPE=Debug
-          export CODE_COVERAGE=ON
-          mkdir -p build
-          cd build
-          # -DCMAKE_C_FLAGS=-O3 -DCMAKE_CXX_FLAGS=-O3
-          cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCOVERAGE=$CODE_COVERAGE ..
-          cd ..
-      - name: Print ccache stats for deps
-        run: |
-          ccache --show-stats
-      - name: Build all
-        run: |
-          export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
-          export CC=gcc-9
-          export CXX=g++-9
-          export TARGET=all
-          export CMAKE_BUILD_TYPE=Debug
-          export CODE_COVERAGE=ON
-          cd build
-          make testeth -j$(nproc)
-          cd ..
-      - name: Print ccache stats after full build
-        run : |
-          ccache --show-stats
-      - name: Testeth verbosity 1
-        run : |
-          #first run with verbosity 1. If test fails, rerun with verbosity 4
-          cd build/test
-          export NO_NTP_CHECK=1
-          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 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
-          ./testeth -t ClientBase -- --express && touch /tmp/ClientBasePassed
-          ./testeth -t EstimateGas -- --express && touch /tmp/EstimateGasPassed
-          ./testeth -t IMABLSPublicKey -- --express && touch /tmp/IMABLSPublicKeyPassed
-          ./testeth -t ExtVmSuite -- --express && touch /tmp/ExtVmSuitePassed
-          ./testeth -t GasPricer -- --express && touch /tmp/GasPricerPassed
-          ./testeth -t BasicTests -- --express && touch /tmp/BasicTestsPassed
-          ./testeth -t InstanceMonitorSuite -- --express && touch /tmp/InstanceMonitorSuitePassed
-          ./testeth -t PrecompiledTests -- --express && touch /tmp/PrecompiledTestsPassed
-          ./testeth -t SkaleHostSuite -- --express && touch /tmp/SkaleHostSuitePassed
-          ./testeth -t StateUnitTests -- --express && touch /tmp/StateUnitTestsPassed
-          ./testeth -t libethereum -- --express && touch /tmp/libethereumPassed
-          ./testeth -t TransactionQueueSuite -- --express && touch /tmp/TransactionQueueSuitePassed
-          ./testeth -t LegacyVMSuite -- --express && touch /tmp/LegacyVMSuitePassed
-          ./testeth -t SkaleInterpreterSuite -- --express && touch /tmp/SkaleInterpreterSuitePassed
-          ./testeth -t SnapshotSigningTestSuite -- --express && touch /tmp/SnapshotSigningTestSuitePassed
-          ./testeth -t SkUtils -- --express && touch /tmp/SkUtilsPassed
-          ./testeth -t BlockChainTestSuite -- --express && touch /tmp/BlockChainTestSuitePassed
-          ./testeth -t TestHelperSuite -- --express && touch /tmp/TestHelperSuitePassed
-          ./testeth -t LevelDBHashBase -- --express && touch /tmp/LevelDBHashBasePassed
-          ./testeth -t memDB -- --express && touch /tmp/memDBPassed
-          ./testeth -t OverlayDBTests -- --express && touch /tmp/OverlayDBTestsPassed
-          ./testeth -t AccountHolderTest -- --express && touch /tmp/AccountHolderTestPassed
-          ./testeth -t ClientTests -- --express && touch /tmp/ClientTestsPassed
-          ./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 : |
-          # Since a tests failed, we are rerunning the failed test with higher verbosity          
-          cd build/test      
-          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
-          ls /tmp/ClientBasePassed || ./testeth -t ClientBase -- --express --verbosity 4
-          ls /tmp/EstimateGasPassed || ./testeth -t EstimateGas -- --express --verbosity 4
-          ls /tmp/IMABLSPublicKeyPassed || ./testeth -t IMABLSPublicKey -- --express --verbosity 4
-          ls /tmp/ExtVmSuitePassed || ./testeth -t ExtVmSuite -- --express --verbosity 4
-          ls /tmp/GasPricerPassed || ./testeth -t GasPricer -- --express --verbosity 4
-          ls /tmp/BasicTestsPassed || ./testeth -t BasicTests -- --express --verbosity 4
-          ls /tmp/InstanceMonitorSuitePassed || ./testeth -t InstanceMonitorSuite -- --express --verbosity 4
-          ls /tmp/PrecompiledTestsPassed || ./testeth -t PrecompiledTests -- --express --verbosity 4
-          ls /tmp/SkaleHostSuitePassed || ./testeth -t SkaleHostSuite -- --express --verbosity 4
-          ls /tmp/StateUnitTestsPassed || ./testeth -t StateUnitTests -- --express --verbosity 4
-          ls /tmp/libethereumPassed || ./testeth -t libethereum -- --express --verbosity 4
-          ls /tmp/TransactionQueueSuitePassed || ./testeth -t TransactionQueueSuite -- --express --verbosity 4
-          ls /tmp/LegacyVMSuitePassed || ./testeth -t LegacyVMSuite -- --express --verbosity 4
-          ls /tmp/SkaleInterpreterSuitePassed || ./testeth -t SkaleInterpreterSuite -- --express --verbosity 4
-          ls /tmp/SnapshotSigningTestSuitePassed || ./testeth -t SnapshotSigningTestSuite -- --express --verbosity 4
-          ls /tmp/SkUtilsPassed || ./testeth -t SkUtils -- --express --verbosity 4
-          ls /tmp/BlockChainTestSuitePassed || ./testeth -t BlockChainTestSuite -- --express --verbosity 4
-          ls /tmp/TestHelperSuitePassed || ./testeth -t TestHelperSuite -- --express --verbosity 4
-          ls /tmp/LevelDBHashBasePassed || ./testeth -t LevelDBHashBase -- --express --verbosity 4
-          ls /tmp/memDBPassed || ./testeth -t memDB -- --express --verbosity 4
-          ls /tmp/OverlayDBTestsPassed || ./testeth -t OverlayDBTests -- --express --verbosity 4
-          ls /tmp/AccountHolderTestPassed || ./testeth -t AccountHolderTest -- --express --verbosity 4
-          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/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
-
-      - name: Create lcov report
-        run: |
-          lcov --capture --directory build/test --output-file coverage.info
-          lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter system-files
-          lcov --remove coverage.info 'deps/*' --output-file coverage.info # filter dependency files
-          lcov --remove coverage.info 'libconsensus/deps/*' --output-file coverage.info # filter dependency files
-          lcov --remove coverage.info 'libconsensus/libBLS/deps/*' --output-file coverage.info # filter dependency files
-          lcov --remove coverage.info '.hunter/*' --output-file coverage.info # filter dependency files
-
-      - name: Upload to Codecov
-        uses: codecov/codecov-action@v3
-        with:
-          token: ${{ secrets.CODECOV_TOKEN }}
-          files: ./coverage.info
-
       - name: Configure all as historic
         run: |
           export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"

From 6a8e6c9d76088f659a9baf3e4b8a40da4b7dab18 Mon Sep 17 00:00:00 2001
From: Dima Litvinov <dima.litvinov@skalelabs.com>
Date: Fri, 29 Dec 2023 17:04:37 +0000
Subject: [PATCH 3/7] SKALED-1714 Fix ChainParams& in Net.h

---
 libweb3jsonrpc/Net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libweb3jsonrpc/Net.h b/libweb3jsonrpc/Net.h
index bc53e0c2b..dbf63c355 100644
--- a/libweb3jsonrpc/Net.h
+++ b/libweb3jsonrpc/Net.h
@@ -44,7 +44,7 @@ class Net : public NetFace {
     virtual bool net_listening() override;
 
 private:
-    const dev::eth::ChainParams& m_chainParams;
+    const dev::eth::ChainParams m_chainParams;
 };
 
 }  // namespace rpc

From 5bcc89829011673c17766f2fe85fcccc4e68e252 Mon Sep 17 00:00:00 2001
From: Dima Litvinov <dima.litvinov@skalelabs.com>
Date: Thu, 4 Jan 2024 20:10:27 +0000
Subject: [PATCH 4/7] SKALED-1714 Proper handling of LatestBlock in
 GappedTransactionIndexCache

---
 libweb3jsonrpc/Eth.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libweb3jsonrpc/Eth.cpp b/libweb3jsonrpc/Eth.cpp
index 849664172..da6e1bfc6 100644
--- a/libweb3jsonrpc/Eth.cpp
+++ b/libweb3jsonrpc/Eth.cpp
@@ -66,6 +66,12 @@ void GappedTransactionIndexCache::ensureCached( BlockNumber _bn,
     _readLock.unlock();
     _writeLock.lock();
 
+    unsigned realBn = _bn;
+    if ( _bn == LatestBlock )
+        realBn = client.number();
+    else if ( _bn == PendingBlock )
+        realBn = 0;  // TODO test this case and decide
+
     assert( real2gappedCache.size() <= cacheSize );
     if ( real2gappedCache.size() >= cacheSize ) {
         real2gappedCache.erase( real2gappedCache.begin() );
@@ -89,7 +95,7 @@ void GappedTransactionIndexCache::ensureCached( BlockNumber _bn,
         pair< h256, unsigned > loc = client.transactionLocation( th );
 
         // ignore transactions with 0 gas usage OR different location!
-        if ( diff == 0 || client.numberFromHash( loc.first ) != _bn || loc.second != realIndex )
+        if ( diff == 0 || client.numberFromHash( loc.first ) != realBn || loc.second != realIndex )
             continue;
 
         // cache it

From a600e09dbe504765d7dd6cec58111c62b34c041c Mon Sep 17 00:00:00 2001
From: Dima Litvinov <dima.litvinov@skalelabs.com>
Date: Thu, 4 Jan 2024 21:32:17 +0000
Subject: [PATCH 5/7] SKALED-1714 Extended tests

---
 test/unittests/libweb3jsonrpc/jsonrpc.cpp | 43 +++++++++++++++++------
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/test/unittests/libweb3jsonrpc/jsonrpc.cpp b/test/unittests/libweb3jsonrpc/jsonrpc.cpp
index 7640a5b24..e75d7c9ef 100644
--- a/test/unittests/libweb3jsonrpc/jsonrpc.cpp
+++ b/test/unittests/libweb3jsonrpc/jsonrpc.cpp
@@ -3023,15 +3023,36 @@ BOOST_AUTO_TEST_CASE( skip_invalid_transactions ) {
 #ifdef HISTORIC_STATE
     // 3 check that historic node sees only 3 txns
 
+    string explicitNumberStr = to_string(fixture.client->number());
+
     // 1 Block
     Json::Value block = fixture.rpcClient->eth_getBlockByNumber("latest", "false");
 
+    string bh = block["hash"].asString();
+
+    // 2 transaction count
+    Json::Value cnt = fixture.rpcClient->eth_getBlockTransactionCountByNumber("latest");
+    BOOST_REQUIRE_EQUAL(cnt.asString(), "0x3");
+    cnt = fixture.rpcClient->eth_getBlockTransactionCountByNumber(explicitNumberStr);
+    BOOST_REQUIRE_EQUAL(cnt.asString(), "0x3");
+    cnt = fixture.rpcClient->eth_getBlockTransactionCountByHash(bh);
+    BOOST_REQUIRE_EQUAL(cnt.asString(), "0x3");
+
+
+    BOOST_REQUIRE_EQUAL(block["transactions"].size(), 3);
+    BOOST_REQUIRE_EQUAL(block["transactions"][0]["transactionIndex"], "0x0");
+    BOOST_REQUIRE_EQUAL(block["transactions"][1]["transactionIndex"], "0x1");
+    BOOST_REQUIRE_EQUAL(block["transactions"][2]["transactionIndex"], "0x2");
+
+    // same with explicit number
+    block = fixture.rpcClient->eth_getBlockByNumber(explicitNumberStr, "false");
+
     BOOST_REQUIRE_EQUAL(block["transactions"].size(), 3);
     BOOST_REQUIRE_EQUAL(block["transactions"][0]["transactionIndex"], "0x0");
     BOOST_REQUIRE_EQUAL(block["transactions"][1]["transactionIndex"], "0x1");
     BOOST_REQUIRE_EQUAL(block["transactions"][2]["transactionIndex"], "0x2");
 
-    // 2 receipts
+    // 3 receipts
     Json::Value r1,r3,r4;
     BOOST_REQUIRE_NO_THROW(r1 = fixture.rpcClient->eth_getTransactionReceipt(toJS(h1)));
     BOOST_REQUIRE_THROW   (fixture.rpcClient->eth_getTransactionReceipt(toJS(h2)), jsonrpc::JsonRpcException);
@@ -3042,16 +3063,24 @@ BOOST_AUTO_TEST_CASE( skip_invalid_transactions ) {
     BOOST_REQUIRE_EQUAL(r3["transactionIndex"], "0x1");
     BOOST_REQUIRE_EQUAL(r4["transactionIndex"], "0x2");
 
-    // 3 transaction by index
+    // 4 transaction by index
     Json::Value t0 = fixture.rpcClient->eth_getTransactionByBlockNumberAndIndex("latest", "0");
     Json::Value t1 = fixture.rpcClient->eth_getTransactionByBlockNumberAndIndex("latest", "1");
     Json::Value t2 = fixture.rpcClient->eth_getTransactionByBlockNumberAndIndex("latest", "2");
+    BOOST_REQUIRE_EQUAL(jsToFixed<32>(t0["hash"].asString()), h1);
+    BOOST_REQUIRE_EQUAL(jsToFixed<32>(t1["hash"].asString()), h3);
+    BOOST_REQUIRE_EQUAL(jsToFixed<32>(t2["hash"].asString()), h4);
 
+    // same with explicit block number
+
+    t0 = fixture.rpcClient->eth_getTransactionByBlockNumberAndIndex(explicitNumberStr, "0");
+    t1 = fixture.rpcClient->eth_getTransactionByBlockNumberAndIndex(explicitNumberStr, "1");
+    t2 = fixture.rpcClient->eth_getTransactionByBlockNumberAndIndex(explicitNumberStr, "2");
     BOOST_REQUIRE_EQUAL(jsToFixed<32>(t0["hash"].asString()), h1);
     BOOST_REQUIRE_EQUAL(jsToFixed<32>(t1["hash"].asString()), h3);
     BOOST_REQUIRE_EQUAL(jsToFixed<32>(t2["hash"].asString()), h4);
 
-    string bh = r1["blockHash"].asString();
+    BOOST_REQUIRE_EQUAL(bh, r1["blockHash"].asString());
 
     t0 = fixture.rpcClient->eth_getTransactionByBlockHashAndIndex(bh, "0");
     t1 = fixture.rpcClient->eth_getTransactionByBlockHashAndIndex(bh, "1");
@@ -3061,15 +3090,9 @@ BOOST_AUTO_TEST_CASE( skip_invalid_transactions ) {
     BOOST_REQUIRE_EQUAL(jsToFixed<32>(t1["hash"].asString()), h3);
     BOOST_REQUIRE_EQUAL(jsToFixed<32>(t2["hash"].asString()), h4);
 
-    // 4 transaction by hash
+    // 5 transaction by hash
     BOOST_REQUIRE_THROW   (fixture.rpcClient->eth_getTransactionByHash(toJS(h2)), jsonrpc::JsonRpcException);
 
-    // 5 transaction count
-    Json::Value cnt = fixture.rpcClient->eth_getBlockTransactionCountByNumber("latest");
-    BOOST_REQUIRE_EQUAL(cnt.asString(), "0x3");
-    cnt = fixture.rpcClient->eth_getBlockTransactionCountByHash(bh);
-    BOOST_REQUIRE_EQUAL(cnt.asString(), "0x3");
-
     // send it successfully
 
     // make money

From bff82992ff16dd3bcf70021344e2c1324f67491c Mon Sep 17 00:00:00 2001
From: Dima Litvinov <dima.litvinov@skalelabs.com>
Date: Fri, 5 Jan 2024 18:36:57 +0000
Subject: [PATCH 6/7] SKALED-1714 Assume that PendingBlock = latest+1

---
 libweb3jsonrpc/Eth.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libweb3jsonrpc/Eth.cpp b/libweb3jsonrpc/Eth.cpp
index da6e1bfc6..63d4a8ff3 100644
--- a/libweb3jsonrpc/Eth.cpp
+++ b/libweb3jsonrpc/Eth.cpp
@@ -70,7 +70,7 @@ void GappedTransactionIndexCache::ensureCached( BlockNumber _bn,
     if ( _bn == LatestBlock )
         realBn = client.number();
     else if ( _bn == PendingBlock )
-        realBn = 0;  // TODO test this case and decide
+        realBn = client.number() + 1;  // TODO test this case and decide
 
     assert( real2gappedCache.size() <= cacheSize );
     if ( real2gappedCache.size() >= cacheSize ) {

From b66157ef62635a9df82afd7d138229821d69b962 Mon Sep 17 00:00:00 2001
From: Dima Litvinov <dima.litvinov@skalelabs.com>
Date: Fri, 5 Jan 2024 18:37:34 +0000
Subject: [PATCH 7/7] SKALED-1714 Get back normal build

---
 .github/workflows/test.yml | 150 +++++++++++++++++++++++++++++++++++++
 1 file changed, 150 insertions(+)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 08ec93804..88d95350a 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -133,6 +133,156 @@ jobs:
           rm -f ./libwebsockets-from-git.tar.gz
           ./build.sh DEBUG=1 PARALLEL_COUNT=$(nproc)
           cd ..
+
+      - name: Configure all
+        run: |
+          export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
+          export CC=gcc-9
+          export CXX=g++-9
+          export TARGET=all
+          export CMAKE_BUILD_TYPE=Debug
+          export CODE_COVERAGE=ON
+          mkdir -p build
+          cd build
+          # -DCMAKE_C_FLAGS=-O3 -DCMAKE_CXX_FLAGS=-O3
+          cmake -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DCOVERAGE=$CODE_COVERAGE ..
+          cd ..
+      - name: Print ccache stats for deps
+        run: |
+          ccache --show-stats
+      - name: Build all
+        run: |
+          export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
+          export CC=gcc-9
+          export CXX=g++-9
+          export TARGET=all
+          export CMAKE_BUILD_TYPE=Debug
+          export CODE_COVERAGE=ON
+          cd build
+          make testeth -j$(nproc)
+          cd ..
+      - name: Print ccache stats after full build
+        run : |
+          ccache --show-stats
+      - name: Testeth verbosity 1
+        run : |
+          #first run with verbosity 1. If test fails, rerun with verbosity 4
+          cd build/test
+          export NO_NTP_CHECK=1
+          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 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
+          ./testeth -t ClientBase -- --express && touch /tmp/ClientBasePassed
+          ./testeth -t EstimateGas -- --express && touch /tmp/EstimateGasPassed
+          ./testeth -t getHistoricNodesData -- --express && touch /tmp/getHistoricNodesDataPassed
+          ./testeth -t ExtVmSuite -- --express && touch /tmp/ExtVmSuitePassed
+          ./testeth -t GasPricer -- --express && touch /tmp/GasPricerPassed
+          ./testeth -t BasicTests -- --express && touch /tmp/BasicTestsPassed
+          ./testeth -t InstanceMonitorSuite -- --express && touch /tmp/InstanceMonitorSuitePassed
+          ./testeth -t PrecompiledTests -- --express && touch /tmp/PrecompiledTestsPassed
+          ./testeth -t SkaleHostSuite -- --express && touch /tmp/SkaleHostSuitePassed
+          ./testeth -t StateUnitTests -- --express && touch /tmp/StateUnitTestsPassed
+          ./testeth -t libethereum -- --express && touch /tmp/libethereumPassed
+          ./testeth -t TransactionQueueSuite -- --express && touch /tmp/TransactionQueueSuitePassed
+          ./testeth -t LegacyVMSuite -- --express && touch /tmp/LegacyVMSuitePassed
+          ./testeth -t SkaleInterpreterSuite -- --express && touch /tmp/SkaleInterpreterSuitePassed
+          ./testeth -t SnapshotSigningTestSuite -- --express && touch /tmp/SnapshotSigningTestSuitePassed
+          ./testeth -t SkUtils -- --express && touch /tmp/SkUtilsPassed
+          ./testeth -t BlockChainTestSuite -- --express && touch /tmp/BlockChainTestSuitePassed
+          ./testeth -t TestHelperSuite -- --express && touch /tmp/TestHelperSuitePassed
+          ./testeth -t LevelDBHashBase -- --express && touch /tmp/LevelDBHashBasePassed
+          ./testeth -t memDB -- --express && touch /tmp/memDBPassed
+          ./testeth -t OverlayDBTests -- --express && touch /tmp/OverlayDBTestsPassed
+          ./testeth -t AccountHolderTest -- --express && touch /tmp/AccountHolderTestPassed
+          ./testeth -t ClientTests -- --express && touch /tmp/ClientTestsPassed
+          ./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 : |
+          # Since a tests failed, we are rerunning the failed test with higher verbosity          
+          cd build/test      
+          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
+          ls /tmp/ClientBasePassed || ./testeth -t ClientBase -- --express --verbosity 4
+          ls /tmp/EstimateGasPassed || ./testeth -t EstimateGas -- --express --verbosity 4
+          ls /tmp/getHistoricNodesDataPassed || ./testeth -t getHistoricNodesData -- --express --verbosity 4
+          ls /tmp/ExtVmSuitePassed || ./testeth -t ExtVmSuite -- --express --verbosity 4
+          ls /tmp/GasPricerPassed || ./testeth -t GasPricer -- --express --verbosity 4
+          ls /tmp/BasicTestsPassed || ./testeth -t BasicTests -- --express --verbosity 4
+          ls /tmp/InstanceMonitorSuitePassed || ./testeth -t InstanceMonitorSuite -- --express --verbosity 4
+          ls /tmp/PrecompiledTestsPassed || ./testeth -t PrecompiledTests -- --express --verbosity 4
+          ls /tmp/SkaleHostSuitePassed || ./testeth -t SkaleHostSuite -- --express --verbosity 4
+          ls /tmp/StateUnitTestsPassed || ./testeth -t StateUnitTests -- --express --verbosity 4
+          ls /tmp/libethereumPassed || ./testeth -t libethereum -- --express --verbosity 4
+          ls /tmp/TransactionQueueSuitePassed || ./testeth -t TransactionQueueSuite -- --express --verbosity 4
+          ls /tmp/LegacyVMSuitePassed || ./testeth -t LegacyVMSuite -- --express --verbosity 4
+          ls /tmp/SkaleInterpreterSuitePassed || ./testeth -t SkaleInterpreterSuite -- --express --verbosity 4
+          ls /tmp/SnapshotSigningTestSuitePassed || ./testeth -t SnapshotSigningTestSuite -- --express --verbosity 4
+          ls /tmp/SkUtilsPassed || ./testeth -t SkUtils -- --express --verbosity 4
+          ls /tmp/BlockChainTestSuitePassed || ./testeth -t BlockChainTestSuite -- --express --verbosity 4
+          ls /tmp/TestHelperSuitePassed || ./testeth -t TestHelperSuite -- --express --verbosity 4
+          ls /tmp/LevelDBHashBasePassed || ./testeth -t LevelDBHashBase -- --express --verbosity 4
+          ls /tmp/memDBPassed || ./testeth -t memDB -- --express --verbosity 4
+          ls /tmp/OverlayDBTestsPassed || ./testeth -t OverlayDBTests -- --express --verbosity 4
+          ls /tmp/AccountHolderTestPassed || ./testeth -t AccountHolderTest -- --express --verbosity 4
+          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/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: Create lcov report
+        run: |
+          lcov --capture --directory . --output-file coverage.info
+          lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter system-files
+          lcov --remove coverage.info 'deps/*' --output-file coverage.info # filter dependency files
+          lcov --remove coverage.info 'libconsensus/deps/*' --output-file coverage.info # filter dependency files
+          lcov --remove coverage.info 'libconsensus/libBLS/deps/*' --output-file coverage.info # filter dependency files
+          lcov --remove coverage.info '.hunter/*' --output-file coverage.info # filter dependency files
+           
+      - name: Upload to Codecov
+        uses: codecov/codecov-action@v3
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
+          files: ./coverage.info
+
       - name: Configure all as historic
         run: |
           export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"