Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions .github/actions/api-tests-run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ runs:
cd test/api-tests
if ! uv run --project . run.py --config run.toml --suite "${{ inputs.suite }}"; then
echo "::error::Test execution failed"
for log in logs/*.log; do
if [ -f "${log}" ]; then
for log_dir in logs */logs; do
[ -d "${log_dir}" ] || continue
find "${log_dir}" -maxdepth 1 -type f -name '*.log' | while read -r log; do
echo "::group::${log}"
cat "${log}"
echo "::endgroup::"
fi
done
done
exit 1
fi
35 changes: 35 additions & 0 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

defaults:
run:
shell: bash
Expand Down Expand Up @@ -64,6 +67,38 @@ jobs:
cmake_args: ""
make_target: skaled

- name: Prepare hardfork-compat binaries
env:
HARDFORK_COMPAT_V510_BINARY_URL: https://github.com/skalenetwork/skaled/releases/download/5.1.0-develop.35/skaled-core
HARDFORK_COMPAT_DOWNLOAD_TOKEN: ${{ secrets.HARDFORK_COMPAT_DOWNLOAD_TOKEN }}
run: |
set -euo pipefail

if [ -z "${HARDFORK_COMPAT_V510_BINARY_URL}" ]; then
echo "::error::HARDFORK_COMPAT_V510_BINARY_URL repository/org variable is not set"
exit 1
fi

curl_args=(--fail --location --retry 3 --retry-delay 5)
if [ -n "${HARDFORK_COMPAT_DOWNLOAD_TOKEN}" ]; then
curl_args+=(--header "Authorization: Bearer ${HARDFORK_COMPAT_DOWNLOAD_TOKEN}")
fi

curl "${curl_args[@]}" "${HARDFORK_COMPAT_V510_BINARY_URL}" --output bin-5-1-0
cp build/skaled/skaled bin-5-2-0

chmod +x bin-5-1-0 bin-5-2-0
file bin-5-1-0 bin-5-2-0

- name: API tests (hardfork-compat)
uses: ./.github/actions/api-tests-run
with:
suite: hardfork-compat
skaled_binary: build/skaled/skaled
build_skaled: "false"
env:
FUNC_TEST_PRIVATE_KEY: ${{ secrets.FUNC_TEST_PRIVATE_KEY }}

- name: Setup Bun
uses: oven-sh/setup-bun@v2

Expand Down
37 changes: 20 additions & 17 deletions libethcore/TransactionBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const dev::Address TransactionBase::BITE_ADDRESS =
dev::Address( std::string( BITE_ADDRESS_AS_STRING ) );
#endif

std::vector< bytes > validateAccessListRLP( const RLP& _data ) {
std::vector< bytes > validateAccessListRLP( const RLP& _data, bool _berlinForkPatchEnabled ) {
if ( !_data.isList() )
BOOST_THROW_EXCEPTION( InvalidTransactionFormat()
<< errinfo_comment( "transaction accessList RLP must be a list" ) );
Expand All @@ -74,8 +74,10 @@ std::vector< bytes > validateAccessListRLP( const RLP& _data ) {
BOOST_THROW_EXCEPTION(
InvalidTransactionFormat() << errinfo_comment(
"transaction accessList RLP must be a list of byte array and a list" ) );
// EIP-2930: address must be exactly 20 bytes.
if ( accessList[0].size() != 20 )
// EIP-2930: address must be exactly 20 bytes, storage key must be exactly 32 bytes.
// Gated by BerlinForkPatch to preserve pre-fork acceptance of non-conforming RLP
// (e.g. addresses encoded as integers with stripped leading zeros).
if ( _berlinForkPatchEnabled && accessList[0].size() != 20 )
BOOST_THROW_EXCEPTION(
InvalidTransactionFormat()
<< errinfo_comment( "transaction accessList address must be exactly 20 bytes" ) );
Expand All @@ -84,8 +86,7 @@ std::vector< bytes > validateAccessListRLP( const RLP& _data ) {
BOOST_THROW_EXCEPTION(
InvalidTransactionFormat() << errinfo_comment(
"transaction storageKeys RLP must be a list of byte array" ) );
// EIP-2930: storage key must be exactly 32 bytes.
if ( k.size() != 32 )
if ( _berlinForkPatchEnabled && k.size() != 32 )
BOOST_THROW_EXCEPTION(
InvalidTransactionFormat() << errinfo_comment(
"transaction accessList storage key must be exactly 32 bytes" ) );
Expand Down Expand Up @@ -242,7 +243,7 @@ void TransactionBase::fillFromBytesLegacy(
}

void TransactionBase::fillFromBytesType1( bytesConstRef _rlpData, CheckTransaction _checkSig,
bool _allowInvalid, bool _invalidTransactionFormatPatchEnabled ) {
bool _allowInvalid, bool _invalidTransactionFormatPatchEnabled, bool _berlinForkPatchEnabled ) {
bytes croppedRlp( _rlpData.begin() + 1, _rlpData.end() );
RLP const rlp( croppedRlp );
try {
Expand All @@ -269,7 +270,7 @@ void TransactionBase::fillFromBytesType1( bytesConstRef _rlpData, CheckTransacti

m_data = rlp[6].toBytes();

m_accessList = validateAccessListRLP( rlp[7] );
m_accessList = validateAccessListRLP( rlp[7], _berlinForkPatchEnabled );

bool const yParity = rlp[8].toInt< uint8_t >();
h256 const r = rlp[9].toInt< u256 >();
Expand Down Expand Up @@ -308,7 +309,7 @@ void TransactionBase::fillFromBytesType1( bytesConstRef _rlpData, CheckTransacti
}

void TransactionBase::fillFromBytesType2( bytesConstRef _rlpData, CheckTransaction _checkSig,
bool _allowInvalid, bool _invalidTransactionFormatPatchEnabled ) {
bool _allowInvalid, bool _invalidTransactionFormatPatchEnabled, bool _berlinForkPatchEnabled ) {
bytes croppedRlp( _rlpData.begin() + 1, _rlpData.end() );
RLP const rlp( croppedRlp );
try {
Expand Down Expand Up @@ -345,7 +346,7 @@ void TransactionBase::fillFromBytesType2( bytesConstRef _rlpData, CheckTransacti

m_data = rlp[7].toBytes();

m_accessList = validateAccessListRLP( rlp[8] );
m_accessList = validateAccessListRLP( rlp[8], _berlinForkPatchEnabled );

bool const yParity = rlp[9].toInt< uint8_t >();
h256 const r = rlp[10].toInt< u256 >();
Expand Down Expand Up @@ -384,18 +385,19 @@ void TransactionBase::fillFromBytesType2( bytesConstRef _rlpData, CheckTransacti
}

void TransactionBase::fillFromBytesByType( bytesConstRef _rlpData, CheckTransaction _checkSig,
bool _allowInvalid, TransactionType _type, bool _invalidTransactionFormatPatchEnabled ) {
bool _allowInvalid, TransactionType _type, bool _invalidTransactionFormatPatchEnabled,
bool _berlinForkPatchEnabled ) {
switch ( _type ) {
case TransactionType::Legacy:
fillFromBytesLegacy( _rlpData, _checkSig, _allowInvalid );
break;
case TransactionType::Type1:
fillFromBytesType1(
_rlpData, _checkSig, _allowInvalid, _invalidTransactionFormatPatchEnabled );
fillFromBytesType1( _rlpData, _checkSig, _allowInvalid,
_invalidTransactionFormatPatchEnabled, _berlinForkPatchEnabled );
break;
case TransactionType::Type2:
fillFromBytesType2(
_rlpData, _checkSig, _allowInvalid, _invalidTransactionFormatPatchEnabled );
fillFromBytesType2( _rlpData, _checkSig, _allowInvalid,
_invalidTransactionFormatPatchEnabled, _berlinForkPatchEnabled );
break;
default:
BOOST_THROW_EXCEPTION(
Expand Down Expand Up @@ -437,8 +439,9 @@ TransactionType TransactionBase::getTransactionType( bytesConstRef _rlp ) {
toHex( bytes{ firstByte } ) ) );
}

TransactionBase::TransactionBase( bytesConstRef _rlpData, CheckTransaction _checkSig,
bool _allowInvalid, bool _eip1559Enabled, bool _invalidTransactionFormatPatchEnabled
TransactionBase::TransactionBase(
bytesConstRef _rlpData, CheckTransaction _checkSig, bool _allowInvalid, bool _eip1559Enabled,
bool _invalidTransactionFormatPatchEnabled, bool _berlinForkPatchEnabled
#ifdef BITE
,
bool _bite2PatchEnabled
Expand All @@ -449,7 +452,7 @@ TransactionBase::TransactionBase( bytesConstRef _rlpData, CheckTransaction _chec
if ( _eip1559Enabled ) {
TransactionType txnType = getTransactionType( _rlpData );
fillFromBytesByType( _rlpData, _checkSig, _allowInvalid, txnType,
_invalidTransactionFormatPatchEnabled );
_invalidTransactionFormatPatchEnabled, _berlinForkPatchEnabled );
} else {
fillFromBytesLegacy( _rlpData, _checkSig, _allowInvalid );
}
Expand Down
21 changes: 11 additions & 10 deletions libethcore/TransactionBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,26 +160,26 @@ class TransactionBase {
m_type( ContractCreation ) {}

/// Constructs a transaction from the given RLP.
explicit TransactionBase(
bytesConstRef _rlp, CheckTransaction _checkSig, bool _allowInvalid = false,
bool _eip1559Enabled = false, bool _invalidTransactionFormatPatchEnabled = false
explicit TransactionBase( bytesConstRef _rlp, CheckTransaction _checkSig,
bool _allowInvalid = false, bool _eip1559Enabled = false,
bool _invalidTransactionFormatPatchEnabled = false, bool _berlinForkPatchEnabled = false
#ifdef BITE
,
bool _bite2PatchEnabled = false
#endif
);

/// Constructs a transaction from the given RLP.
explicit TransactionBase(
bytes const& _rlp, CheckTransaction _checkSig, bool _allowInvalid = false,
bool _eip1559Enabled = false, bool _invalidTransactionFormatPatchEnabled = false
explicit TransactionBase( bytes const& _rlp, CheckTransaction _checkSig,
bool _allowInvalid = false, bool _eip1559Enabled = false,
bool _invalidTransactionFormatPatchEnabled = false, bool _berlinForkPatchEnabled = false
#ifdef BITE
,
bool _bite2PatchEnabled = false
#endif
)
: TransactionBase( &_rlp, _checkSig, _allowInvalid, _eip1559Enabled,
_invalidTransactionFormatPatchEnabled
_invalidTransactionFormatPatchEnabled, _berlinForkPatchEnabled
#ifdef BITE
,
_bite2PatchEnabled
Expand Down Expand Up @@ -505,13 +505,14 @@ class TransactionBase {

/// Constructs a transaction from the given RLP and transaction type.
void fillFromBytesByType( bytesConstRef _rlpData, CheckTransaction _checkSig,
bool _allowInvalid, TransactionType _type, bool _invalidTransactionFormatPatchEnabled );
bool _allowInvalid, TransactionType _type, bool _invalidTransactionFormatPatchEnabled,
bool _berlinForkPatchEnabled );
void fillFromBytesLegacy(
bytesConstRef _rlpData, CheckTransaction _checkSig, bool _allowInvalid );
void fillFromBytesType1( bytesConstRef _rlpData, CheckTransaction _checkSig, bool _allowInvalid,
bool _invalidTransactionFormatPatchEnabled );
bool _invalidTransactionFormatPatchEnabled, bool _berlinForkPatchEnabled );
void fillFromBytesType2( bytesConstRef _rlpData, CheckTransaction _checkSig, bool _allowInvalid,
bool _invalidTransactionFormatPatchEnabled );
bool _invalidTransactionFormatPatchEnabled, bool _berlinForkPatchEnabled );

void streamLegacyTransaction( RLPStream& _s, IncludeSignature _sig, bool _forEip155hash ) const;
void streamType1Transaction( RLPStream& _s, IncludeSignature _sig ) const;
Expand Down
4 changes: 3 additions & 1 deletion libethereum/BlockChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,8 @@ VerifiedBlockRef BlockChain::verifyBlock( bytesConstRef _block,
CheckTransaction::Everything :
CheckTransaction::None,
false, EIP1559TransactionsPatch::isEnabledWhen( blockTimestamp ),
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp )
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp ),
BerlinForkPatch::isEnabledWhen( blockTimestamp )
#ifdef BITE
,
Bite2Patch::isEnabledWhen( blockTimestamp )
Expand Down Expand Up @@ -1937,6 +1938,7 @@ std::deque< Transaction > BlockChain::pendingCTXsList() const {
Transaction tx( entry[0].data(), CheckTransaction::None, true,
EIP1559TransactionsPatch::isEnabledWhen( prevBlockTimestamp ),
InvalidTransactionFormatPatch::isEnabledWhen( prevBlockTimestamp ),
BerlinForkPatch::isEnabledWhen( prevBlockTimestamp ),
Bite2Patch::isEnabledWhen( prevBlockTimestamp ) );
tx.setCTXOrigin( entry[1].toHash< dev::h256 >() );
ctxs.push_back( std::move( tx ) );
Expand Down
15 changes: 10 additions & 5 deletions libethereum/ClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ Transaction ClientBase::transaction( h256 _transactionHash ) const {
auto blockTimestamp = blockInfo( numberFromHash( tl.first ) - 1 ).timestamp();
return Transaction( bc().transaction( _transactionHash ), CheckTransaction::Cheap, true,
EIP1559TransactionsPatch::isEnabledWhen( blockTimestamp ),
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp )
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp ),
BerlinForkPatch::isEnabledWhen( blockTimestamp )
#ifdef BITE
,
Bite2Patch::isEnabledWhen( blockTimestamp )
Expand All @@ -408,7 +409,8 @@ Transaction ClientBase::transaction( h256 _blockHash, unsigned _i ) const {
// allow invalid
return Transaction( b[1][_i].data(), CheckTransaction::Cheap, true,
EIP1559TransactionsPatch::isEnabledWhen( blockTimestamp ),
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp )
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp ),
BerlinForkPatch::isEnabledWhen( blockTimestamp )
#ifdef BITE
,
Bite2Patch::isEnabledWhen( blockTimestamp )
Expand All @@ -423,7 +425,8 @@ LocalisedTransaction ClientBase::localisedTransaction( h256 const& _blockHash, u
// allow invalid
Transaction t = Transaction( bc().transaction( _blockHash, _i ), CheckTransaction::Cheap, true,
EIP1559TransactionsPatch::isEnabledWhen( blockTimestamp ),
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp )
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp ),
BerlinForkPatch::isEnabledWhen( blockTimestamp )
#ifdef BITE
,
Bite2Patch::isEnabledWhen( blockTimestamp )
Expand All @@ -447,7 +450,8 @@ LocalisedTransactionReceipt ClientBase::localisedTransactionReceipt(
CheckTransaction::Cheap, // Check sig
true, // allow invalid
EIP1559TransactionsPatch::isEnabledWhen( blockTimestamp ),
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp )
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp ),
BerlinForkPatch::isEnabledWhen( blockTimestamp )
#ifdef BITE
,
Bite2Patch::isEnabledWhen( blockTimestamp )
Expand Down Expand Up @@ -511,7 +515,8 @@ Transactions ClientBase::transactions( h256 _blockHash ) const {
auto txRlp = b[1][i];
res.emplace_back( bytesRefFromTransactionRlp( txRlp ), CheckTransaction::Cheap, true,
EIP1559TransactionsPatch::isEnabledWhen( blockTimestamp ),
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp )
InvalidTransactionFormatPatch::isEnabledWhen( blockTimestamp ),
BerlinForkPatch::isEnabledWhen( blockTimestamp )
#ifdef BITE
,
Bite2Patch::isEnabledWhen( blockTimestamp )
Expand Down
1 change: 1 addition & 0 deletions libethereum/Precompiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ ETH_REGISTER_PRECOMPILED( submitCTX )( bytesConstRef _in, const PrecompiledCallC
Transaction signedTransaction( signedTxnRlp, CheckTransaction::None, false,
EIP1559TransactionsPatch::isEnabledWhen( _ctx.latestBlockTimestamp ),
InvalidTransactionFormatPatch::isEnabledWhen( _ctx.latestBlockTimestamp ),
BerlinForkPatch::isEnabledWhen( _ctx.latestBlockTimestamp ),
Bite2Patch::isEnabledWhen( _ctx.latestBlockTimestamp ) );
signedTransaction.setBITE2EncryptedArgsSize( encryptedArgsCount );

Expand Down
8 changes: 5 additions & 3 deletions libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ h256 SkaleHost::receiveTransaction( const std::string& _rlp ) {

Transaction transaction( jsToBytes( _rlp, OnFailed::Throw ), CheckTransaction::None, false,
EIP1559TransactionsPatch::isEnabledInWorkingBlock(),
InvalidTransactionFormatPatch::isEnabledInWorkingBlock()
InvalidTransactionFormatPatch::isEnabledInWorkingBlock(),
BerlinForkPatch::isEnabledInWorkingBlock()
#ifdef BITE
,
Bite2Patch::isEnabledInWorkingBlock()
Expand Down Expand Up @@ -1061,7 +1062,8 @@ std::vector< Transaction > SkaleHost::processRegularTransactions(

Transaction t( data, CheckTransaction::Everything, true,
EIP1559TransactionsPatch::isEnabledInWorkingBlock(),
InvalidTransactionFormatPatch::isEnabledInWorkingBlock()
InvalidTransactionFormatPatch::isEnabledInWorkingBlock(),
BerlinForkPatch::isEnabledInWorkingBlock()
#ifdef BITE
,
Bite2Patch::isEnabledInWorkingBlock()
Expand Down Expand Up @@ -1120,7 +1122,7 @@ std::vector< Transaction > SkaleHost::processCTXTransactions(
Transaction t( data, CheckTransaction::Everything, true,
EIP1559TransactionsPatch::isEnabledInWorkingBlock(),
InvalidTransactionFormatPatch::isEnabledInWorkingBlock(),
Bite2Patch::isEnabledInWorkingBlock() );
BerlinForkPatch::isEnabledInWorkingBlock(), Bite2Patch::isEnabledInWorkingBlock() );

if ( ctxIterator != _decryptedTransactions.ctxTxsMap->end() && ctxIterator->first == i ) {
std::optional< DecryptedCTXArgs > decryptedArgs = ctxIterator->second;
Expand Down
12 changes: 6 additions & 6 deletions libethereum/Transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ Transaction::Transaction( const u256& _value, const u256& _gasPrice, const u256&
: TransactionBase( _value, _gasPrice, _gas, _data, _nonce ) {}

Transaction::Transaction( bytesConstRef _rlpData, CheckTransaction _checkSig, bool _allowInvalid,
bool _eip1559Enabled, bool _invalidTransactionFormatPatchEnabled
bool _eip1559Enabled, bool _invalidTransactionFormatPatchEnabled, bool _berlinForkPatchEnabled
#ifdef BITE
,
bool _bite2PatchEnabled
#endif
)
: TransactionBase(
_rlpData, _checkSig, _allowInvalid, _eip1559Enabled, _invalidTransactionFormatPatchEnabled
: TransactionBase( _rlpData, _checkSig, _allowInvalid, _eip1559Enabled,
_invalidTransactionFormatPatchEnabled, _berlinForkPatchEnabled
#ifdef BITE
,
_bite2PatchEnabled
Expand All @@ -211,14 +211,14 @@ Transaction::Transaction( bytesConstRef _rlpData, CheckTransaction _checkSig, bo
}

Transaction::Transaction( const bytes& _rlp, CheckTransaction _checkSig, bool _allowInvalid,
bool _eip1559Enabled, bool _invalidTransactionFormatPatchEnabled
bool _eip1559Enabled, bool _invalidTransactionFormatPatchEnabled, bool _berlinForkPatchEnabled
#ifdef BITE
,
bool _bite2PatchEnabled
#endif
)
: Transaction(
&_rlp, _checkSig, _allowInvalid, _eip1559Enabled, _invalidTransactionFormatPatchEnabled
: Transaction( &_rlp, _checkSig, _allowInvalid, _eip1559Enabled,
_invalidTransactionFormatPatchEnabled, _berlinForkPatchEnabled
#ifdef BITE
,
_bite2PatchEnabled
Expand Down
9 changes: 5 additions & 4 deletions libethereum/Transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ class Transaction : public TransactionBase {
u256 const& _nonce = Invalid256 );

/// Constructs a transaction from the given RLP.
explicit Transaction(
bytesConstRef _rlp, CheckTransaction _checkSig, bool _allowInvalid = false,
bool _eip1559Enabled = false, bool _invalidTransactionFormatPatchEnabled = false
explicit Transaction( bytesConstRef _rlp, CheckTransaction _checkSig,
bool _allowInvalid = false, bool _eip1559Enabled = false,
bool _invalidTransactionFormatPatchEnabled = false, bool _berlinForkPatchEnabled = false
#ifdef BITE
,
bool _bite2PatchEnabled = false
Expand All @@ -148,7 +148,8 @@ class Transaction : public TransactionBase {

/// Constructs a transaction from the given RLP.
explicit Transaction( bytes const& _rlp, CheckTransaction _checkSig, bool _allowInvalid = false,
bool _eip1559Enabled = false, bool _invalidTransactionFormatPatchEnabled = false
bool _eip1559Enabled = false, bool _invalidTransactionFormatPatchEnabled = false,
bool _berlinForkPatchEnabled = false
#ifdef BITE
,
bool _bite2PatchEnabled = false
Expand Down
Loading
Loading