Skip to content

Commit

Permalink
IS 1074
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed Sep 24, 2024
1 parent 13d7638 commit d6fd0af
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 10 deletions.
95 changes: 88 additions & 7 deletions libskale/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,31 @@ std::pair< ExecutionResult, TransactionReceipt > State::execute( EnvInfo const&
onOp = e.simpleTrace();
#endif
u256 const startGasUsed = _envInfo.gasUsed();
bool const statusCode = executeTransaction( e, _t, onOp );
bool statusCodeTmp = false;
if ( ( _chainParams.chainID == 1020352220 &&
_t.sha3() ==
dev::h256(
"0x3464b9a165a29fde2ce644882e82d99edbff5f530413f6cc18b26bf97e6478fb" ) ) ||
( _chainParams.chainID == 1482601649 &&
_t.sha3() ==
dev::h256(
"0xd3f25440b752f4ad048b618554f71cec08a73af7bf88b6a7d55581f3a792d823" ) ) ||
( _chainParams.chainID == 974399131 &&
_t.sha3() ==
dev::h256(
"0xfcd7ecb7c359af0a93a02e5d84957e0c6f90da4584c058e9c5e988b27a237693" ) ) ||
( _chainParams.chainID == 1482601649 &&
_t.sha3() ==
dev::h256(
"0x6f2074cfe73a258c049ac2222101b7020461c2d40dcd5ab9587d5bbdd13e4c68" ) ) ) {
e.initialize( _t );
e.execute();
// e.finalize();
statusCodeTmp = false;
} else {
statusCodeTmp = executeTransaction( e, _t, onOp );
}
bool const statusCode = statusCodeTmp;

std::string strRevertReason;
if ( res.excepted == dev::eth::TransactionException::RevertInstruction ) {
Expand Down Expand Up @@ -1056,9 +1080,38 @@ std::pair< ExecutionResult, TransactionReceipt > State::execute( EnvInfo const&
// shaLastTx.hex() << "\n";

TransactionReceipt receipt =
_envInfo.number() >= _chainParams.byzantiumForkBlock ?
TransactionReceipt( statusCode, startGasUsed + e.gasUsed(), e.logs() ) :
TransactionReceipt( EmptyTrie, startGasUsed + e.gasUsed(), e.logs() );
TransactionReceipt( statusCode, startGasUsed + e.gasUsed(), e.logs() );
if ( _chainParams.chainID == 1020352220 &&
_t.sha3() ==
dev::h256(
"0x3464b9a165a29fde2ce644882e82d99edbff5f530413f6cc18b26bf97e6478fb" ) ) {
receipt = TransactionReceipt( statusCode, startGasUsed + 40729, e.logs() );
} else {
if ( _chainParams.chainID == 1482601649 &&
_t.sha3() ==
dev::h256(
"0xd3f25440b752f4ad048b618554f71cec08a73af7bf88b6a7d55581f3a792d823" ) ) {
receipt = TransactionReceipt( statusCode, startGasUsed + 32151, e.logs() );
} else {
if ( _chainParams.chainID == 974399131 &&
_t.sha3() == dev::h256( "0xfcd7ecb7c359af0a93a02e5d84957e0c6f90da4584c058e9c5e"
"988b27a237693" ) ) {
receipt = TransactionReceipt( statusCode, startGasUsed + 23700, e.logs() );
} else {
if ( ( _chainParams.chainID == 1482601649 &&
_t.sha3() == dev::h256( "0x6f2074cfe73a258c049ac2222101b7020461c2d40dc"
"d5ab9587d5bbdd13e4c68" ) ) ) {
receipt = TransactionReceipt( statusCode, startGasUsed + 55293, e.logs() );
} else {
receipt = _envInfo.number() >= _chainParams.byzantiumForkBlock ?
TransactionReceipt(
statusCode, startGasUsed + e.gasUsed(), e.logs() ) :
TransactionReceipt(
EmptyTrie, startGasUsed + e.gasUsed(), e.logs() );
}
}
}
}
receipt.setRevertReason( strRevertReason );
m_db_ptr->addReceiptToPartials( receipt );
m_fs_ptr->commit();
Expand All @@ -1075,9 +1128,37 @@ std::pair< ExecutionResult, TransactionReceipt > State::execute( EnvInfo const&
}

TransactionReceipt receipt =
_envInfo.number() >= _chainParams.byzantiumForkBlock ?
TransactionReceipt( statusCode, startGasUsed + e.gasUsed(), e.logs() ) :
TransactionReceipt( EmptyTrie, startGasUsed + e.gasUsed(), e.logs() );
TransactionReceipt( statusCode, startGasUsed + e.gasUsed(), e.logs() );
if ( _chainParams.chainID == 1020352220 &&
_t.sha3() ==
dev::h256( "0x3464b9a165a29fde2ce644882e82d99edbff5f530413f6cc18b26bf97e6478fb" ) ) {
receipt = TransactionReceipt( statusCode, startGasUsed + 40729, e.logs() );
} else {
if ( _chainParams.chainID == 1482601649 &&
_t.sha3() ==
dev::h256(
"0xd3f25440b752f4ad048b618554f71cec08a73af7bf88b6a7d55581f3a792d823" ) ) {
receipt = TransactionReceipt( statusCode, startGasUsed + 32151, e.logs() );
} else {
if ( _chainParams.chainID == 974399131 &&
_t.sha3() ==
dev::h256(
"0xfcd7ecb7c359af0a93a02e5d84957e0c6f90da4584c058e9c5e988b27a237693" ) ) {
receipt = TransactionReceipt( statusCode, startGasUsed + 23700, e.logs() );
} else {
if ( ( _chainParams.chainID == 1482601649 &&
_t.sha3() == dev::h256( "0x6f2074cfe73a258c049ac2222101b7020461c2d40dcd5ab"
"9587d5bbdd13e4c68" ) ) ) {
receipt = TransactionReceipt( statusCode, startGasUsed + 55293, e.logs() );
} else {
receipt =
_envInfo.number() >= _chainParams.byzantiumForkBlock ?
TransactionReceipt( statusCode, startGasUsed + e.gasUsed(), e.logs() ) :
TransactionReceipt( EmptyTrie, startGasUsed + e.gasUsed(), e.logs() );
}
}
}
}
receipt.setRevertReason( strRevertReason );

return make_pair( res, receipt );
Expand Down
6 changes: 3 additions & 3 deletions test/unittests/libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ BOOST_AUTO_TEST_CASE( transactionDropReceive

// 1st tx
Transaction tx1 = fixture.tx_from_json( json );
tx1.checkOutExternalGas( client->chainParams(), client->latestBlock().info().timestamp(), client->number(), false );
tx1.checkOutExternalGas( client->chainParams(), client->latestBlock().info().timestamp(), client->number() );

// submit it!
tq->import( tx1 );
Expand Down Expand Up @@ -1025,7 +1025,7 @@ BOOST_AUTO_TEST_CASE( transactionDropByGasPrice

// 1st tx
Transaction tx1 = fixture.tx_from_json( json );
tx1.checkOutExternalGas( client->chainParams(), client->latestBlock().info().timestamp(), client->number(), false );
tx1.checkOutExternalGas( client->chainParams(), client->latestBlock().info().timestamp(), client->number() );

// submit it!
tq->import( tx1 );
Expand Down Expand Up @@ -1094,7 +1094,7 @@ BOOST_AUTO_TEST_CASE( transactionDropByGasPriceReceive

// 1st tx
Transaction tx1 = fixture.tx_from_json( json );
tx1.checkOutExternalGas( client->chainParams(), client->latestBlock().info().timestamp(), client->number(), false );
tx1.checkOutExternalGas( client->chainParams(), client->latestBlock().info().timestamp(), client->number() );

// receive it!
skaleHost->receiveTransaction( toJS( tx1.toBytes() ) );
Expand Down

0 comments on commit d6fd0af

Please sign in to comment.