Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New beta #1706

Merged
merged 31 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e495a68
IS-869 SkipInvalidTransactionsPatch
dimalit Oct 4, 2023
9307158
IS-869 Skip invalid transactions in historic mode
dimalit Oct 5, 2023
0972058
IS-869 Tests and fixes for transaction skipping
dimalit Oct 6, 2023
c716b3b
Merge branch 'develop' into bug/IS-869-transaction-duplicates
dimalit Oct 6, 2023
3292ae9
Forgot to commit SkipInvalidTransaction patch + minor readability imp…
dimalit Oct 9, 2023
774a6fb
Merge branch 'bug/IS-869-transaction-duplicates' of github.com:/skale…
dimalit Oct 9, 2023
38c6a2f
IS-869 Remove unused parameter
dimalit Oct 9, 2023
352d5bb
IS-869 Print patch info
dimalit Oct 9, 2023
3735ea8
IS-869 Style changes
dimalit Oct 9, 2023
e519313
IS-869 Speed up with gapped cache
dimalit Oct 11, 2023
3b2b736
IS-869 Forgot ifdef
dimalit Oct 11, 2023
25a6318
IS-869 New function in SkipInvalidTransactionsPatch
dimalit Oct 11, 2023
65cc6b5
IS-869 Do not compute transaction gaps in new blocks
dimalit Oct 12, 2023
a7512d7
IS-869 Re-architecture SkipInvalidTransactionsPatch
dimalit Oct 12, 2023
a75dbbd
IS-869 Fix some tests
dimalit Oct 12, 2023
b8ef14c
IS-869 SkipInvalidTransactionsPatch re-architecture
dimalit Oct 13, 2023
d580980
Fix for duplicatiing transactions (IS-869)
dimalit Oct 13, 2023
65a5113
IS-869 Fix problem with new block removal
dimalit Oct 16, 2023
ff99191
Merge branch 'develop' into bug/IS-869-transaction-duplicates
dimalit Oct 16, 2023
b96e9c8
IS-869 Fix problem with new block removal
dimalit Oct 17, 2023
db9d248
IS-869 Fixed filtering condition in Eth.cpp
dimalit Oct 18, 2023
17f1ec7
Merge branch 'develop' into bug/IS-869-transaction-duplicates
dimalit Oct 18, 2023
d33f194
IS-869 Rename skippedInvalidTransactionsInBlock
dimalit Oct 19, 2023
b3b8133
IS-869 Read-write lock
dimalit Oct 19, 2023
dab6cfa
Merge branch 'bug/IS-869-transaction-duplicates' of github.com:/skale…
dimalit Oct 19, 2023
a7c74c7
IS-869 Invalid handling of switched off patch
dimalit Oct 19, 2023
e1e3d28
1703 move tq size log to info
olehnikolaiev Oct 20, 2023
d87ca50
Merge pull request #1698 from skalenetwork/bug/IS-869-transaction-dup…
DmytroNazarenko Oct 20, 2023
2e5c854
Merge branch 'develop' into enhancement/1703-move-tq-size-log-to-info
dimalit Oct 20, 2023
18ab10c
Merge pull request #1705 from skalenetwork/enhancement/1703-move-tq-s…
DmytroNazarenko Oct 20, 2023
dbf638f
Merge branch 'beta' into develop
DmytroNazarenko Oct 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libethcore/ChainOperationParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ struct SChain {
time_t verifyDaSigsPatchTimestamp = 0;
time_t storageDestructionPatchTimestamp = 0;
time_t powCheckPatchTimestamp = 0;
time_t skipInvalidTransactionsPatchTimestamp = 0;

SChain() {
name = "TestChain";
Expand Down
47 changes: 29 additions & 18 deletions libethereum/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <libethcore/Exceptions.h>
#include <libethcore/SealEngine.h>
#include <libevm/VMFactory.h>
#include <libskale/SkipInvalidTransactionsPatch.h>
#include <boost/filesystem.hpp>
#include <boost/timer.hpp>
#include <ctime>
Expand Down Expand Up @@ -483,31 +484,38 @@ tuple< TransactionReceipts, unsigned > Block::syncEveryone(
LOG( m_logger ) << "Transaction " << tr.sha3() << " WouldNotBeInBlock: gasPrice "
<< tr.gasPrice() << " < " << _gasPrice;

// Add to the user-originated transactions that we've executed.
m_transactions.push_back( tr );
m_transactionSet.insert( tr.sha3() );
if ( SkipInvalidTransactionsPatch::isEnabled() ) {
// Add to the user-originated transactions that we've executed.
m_transactions.push_back( tr );
m_transactionSet.insert( tr.sha3() );

// TODO deduplicate
// "bad" transaction receipt for failed transactions
TransactionReceipt const null_receipt =
info().number() >= sealEngine()->chainParams().byzantiumForkBlock ?
TransactionReceipt( 0, info().gasUsed(), LogEntries() ) :
TransactionReceipt( EmptyTrie, info().gasUsed(), LogEntries() );
// TODO deduplicate
// "bad" transaction receipt for failed transactions
TransactionReceipt const null_receipt =
info().number() >= sealEngine()->chainParams().byzantiumForkBlock ?
TransactionReceipt( 0, info().gasUsed(), LogEntries() ) :
TransactionReceipt( EmptyTrie, info().gasUsed(), LogEntries() );

m_receipts.push_back( null_receipt );
receipts.push_back( null_receipt );
m_receipts.push_back( null_receipt );
receipts.push_back( null_receipt );

++count_bad;
++count_bad;
}

continue;
}

ExecutionResult res =
execute( _bc.lastBlockHashes(), tr, Permanence::Committed, OnOpFunc() );
receipts.push_back( m_receipts.back() );

if ( res.excepted == TransactionException::WouldNotBeInBlock )
++count_bad;
if ( !SkipInvalidTransactionsPatch::isEnabled() ||
res.excepted != TransactionException::WouldNotBeInBlock ) {
receipts.push_back( m_receipts.back() );

// if added but bad
if ( res.excepted == TransactionException::WouldNotBeInBlock )
++count_bad;
}

//
// Debug only, related SKALE-2814 partial catchup testing
Expand Down Expand Up @@ -862,9 +870,12 @@ ExecutionResult Block::execute(
if ( _p == Permanence::Committed || _p == Permanence::CommittedWithoutState ||
_p == Permanence::Uncommitted ) {
// Add to the user-originated transactions that we've executed.
m_transactions.push_back( _t );
m_receipts.push_back( resultReceipt.second );
m_transactionSet.insert( _t.sha3() );
if ( !SkipInvalidTransactionsPatch::isEnabled() ||
resultReceipt.first.excepted != TransactionException::WouldNotBeInBlock ) {
m_transactions.push_back( _t );
m_receipts.push_back( resultReceipt.second );
m_transactionSet.insert( _t.sha3() );
}
}
if ( _p == Permanence::Committed || _p == Permanence::Uncommitted ) {
m_state = stateSnapshot.createStateModifyCopyAndPassLock();
Expand Down
5 changes: 5 additions & 0 deletions libethereum/ChainParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ ChainParams ChainParams::loadConfig(
sChainObj.at( "powCheckPatchTimestamp" ).get_int64() :
0;

s.skipInvalidTransactionsPatchTimestamp =
sChainObj.count( "skipInvalidTransactionsPatchTimestamp" ) ?
sChainObj.at( "skipInvalidTransactionsPatchTimestamp" ).get_int64() :
0;

if ( sChainObj.count( "nodeGroups" ) ) {
std::vector< NodeGroup > nodeGroups;
for ( const auto& nodeGroupConf : sChainObj["nodeGroups"].get_obj() ) {
Expand Down
5 changes: 4 additions & 1 deletion libethereum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <libskale/ContractStorageZeroValuePatch.h>
#include <libskale/POWCheckPatch.h>
#include <libskale/RevertableFSPatch.h>
#include <libskale/SkipInvalidTransactionsPatch.h>
#include <libskale/State.h>
#include <libskale/StorageDestructionPatch.h>
#include <libskale/TotalStorageUsedPatch.h>
Expand Down Expand Up @@ -162,6 +163,8 @@ Client::Client( ChainParams const& _params, int _networkID,
RevertableFSPatch::setTimestamp( chainParams().sChain.revertableFSPatchTimestamp );
StorageDestructionPatch::setTimestamp( chainParams().sChain.storageDestructionPatchTimestamp );
POWCheckPatch::setTimestamp( chainParams().sChain.powCheckPatchTimestamp );
SkipInvalidTransactionsPatch::setTimestamp(
this->chainParams().sChain.skipInvalidTransactionsPatchTimestamp );
}


Expand Down Expand Up @@ -654,7 +657,7 @@ size_t Client::syncTransactions(
RevertableFSPatch::lastBlockTimestamp = blockChain().info().timestamp();
StorageDestructionPatch::lastBlockTimestamp = blockChain().info().timestamp();
POWCheckPatch::lastBlockTimestamp = blockChain().info().timestamp();

SkipInvalidTransactionsPatch::lastBlockTimestamp = blockChain().info().timestamp();

DEV_WRITE_GUARDED( x_working ) {
assert( !m_working.isSealed() );
Expand Down
2 changes: 1 addition & 1 deletion libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ void SkaleHost::createBlock( const ConsensusExtFace::transactions_vector& _appro

logState();

clog( VerbosityDebug, "skale-host" )
clog( VerbosityInfo, "skale-host" )
<< "TQBYTES:CTQ:" << m_tq.status().currentBytes << ":FTQ:" << m_tq.status().futureBytes
<< ":TQSIZE:CTQ:" << m_tq.status().current << ":FTQ:" << m_tq.status().future;

Expand Down
4 changes: 3 additions & 1 deletion libethereum/ValidationSchemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ void validateConfigJson( js::mObject const& _obj ) {
{ "storageDestructionPatchTimestamp",
{ { js::int_type }, JsonFieldPresence::Optional } },
{ "powCheckPatchTimestamp", { { js::int_type }, JsonFieldPresence::Optional } },
{ "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } } } );
{ "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } },
{ "skipInvalidTransactionsPatchTimestamp",
{ { js::int_type }, JsonFieldPresence::Optional } } } );

js::mArray const& nodes = sChain.at( "nodes" ).get_array();
for ( auto const& obj : nodes ) {
Expand Down
2 changes: 2 additions & 0 deletions libskale/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(sources
OverlayFS.cpp
StorageDestructionPatch.cpp
POWCheckPatch.cpp
SkipInvalidTransactionsPatch.cpp
)

set(headers
Expand All @@ -39,6 +40,7 @@ set(headers
RevertableFSPatch.h
POWCheckPatch.h
OverlayFS.h
SkipInvalidTransactionsPatch.h
)

add_library(skale ${sources} ${headers})
Expand Down
12 changes: 12 additions & 0 deletions libskale/SkipInvalidTransactionsPatch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "SkipInvalidTransactionsPatch.h"

using namespace dev::eth;

time_t SkipInvalidTransactionsPatch::activationTimestamp;
time_t SkipInvalidTransactionsPatch::lastBlockTimestamp;

bool SkipInvalidTransactionsPatch::isEnabled() {
if ( activationTimestamp == 0 )
return false;
return lastBlockTimestamp >= activationTimestamp;
}
52 changes: 52 additions & 0 deletions libskale/SkipInvalidTransactionsPatch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#ifndef SKIPINVALIDTRANSACTIONSPATCH_H
#define SKIPINVALIDTRANSACTIONSPATCH_H

#include <libethcore/BlockHeader.h>
#include <libethereum/ChainParams.h>
#include <libethereum/Interface.h>
#include <libethereum/SchainPatch.h>
#include <libethereum/Transaction.h>

namespace dev {
namespace eth {
class Client;
}
} // namespace dev

// What this patch does:
// 1. "Invalid" transactions that came with winning block proposal from consensus
// are skipped, and not included in block.
// Their "validity is determined in Block::syncEveryone:
// a) Transactions should have gasPrice >= current block min gas price
// b) State::execute should not throw (it causes WouldNotBeInBlock exception).
// Usually this exception is caused by Executive::verifyTransaction() failure.
//
// 2. Specifically for historic node - we ignore "invalid" transactions that
// are already in block as though they never came.
// This affects following JSON-RPC calls:
// 1) eth_getBlockByHash/Number
// 2) eth_getTransactionReceipt (affects "transactionIndex" field)
// 3) eth_getBlockTransactionCountByHash/Number
// 4) eth_getTransactionByHash (invalid transactions are treated as never present)
// 5) eth_getTransactionByBlockHash/NumberAndIndex
// Transactions are removed from Transaction Queue as usually.

// TODO better start to apply patches from 1st block after timestamp, not second
class SkipInvalidTransactionsPatch : public SchainPatch {
public:
static bool isEnabled();

static void setTimestamp( time_t _activationTimestamp ) {
activationTimestamp = _activationTimestamp;
printInfo( __FILE__, _activationTimestamp );
}

static time_t getActivationTimestamp() { return activationTimestamp; }

private:
friend class dev::eth::Client;
static time_t activationTimestamp;
static time_t lastBlockTimestamp;
};

#endif // SKIPINVALIDTRANSACTIONSPATCH_H
Loading
Loading