-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1706 from skalenetwork/develop
New beta
- Loading branch information
Showing
14 changed files
with
739 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.