Skip to content

Commit

Permalink
Merge branch 'v3.20.0' into develop-to-3.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroNazarenko authored Oct 10, 2024
2 parents b1ebaa6 + 244bcb8 commit 56a1549
Show file tree
Hide file tree
Showing 29 changed files with 601 additions and 937 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.19.3
3.20.0
2 changes: 1 addition & 1 deletion cmake/EthUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ macro(eth_add_test NAME)
add_custom_target("test.${NAME}"
DEPENDS testeth
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -DETH_TEST_NAME="${NAME}" -DCTEST_COMMAND="${CTEST_COMMAND}" -P "${ETH_SCRIPTS_DIR}/runtest.cmake"
COMMAND ${CMAKE_COMMAND} -DETH_TEST_NAME="${NAME}" -DCTEST_COMMAND="${CMAKE_CTEST_COMMAND}" -P "${ETH_SCRIPTS_DIR}/runtest.cmake"
)

endmacro()
Expand Down
32 changes: 25 additions & 7 deletions deps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1158,16 +1158,20 @@ then
#
echo -e "${COLOR_INFO}configuring it${COLOR_DOTS}...${COLOR_RESET}"
cd libuv
eval ./autogen.sh
eval ./configure "${CONF_CROSSCOMPILING_OPTS_GENERIC}" --enable-static --disable-shared --with-pic --prefix="$INSTALL_ROOT" "${CONF_DEBUG_OPTIONS}"
# eval ./autogen.sh
# eval ./configure "${CONF_CROSSCOMPILING_OPTS_GENERIC}" --enable-static --disable-shared --with-pic --prefix="$INSTALL_ROOT" "${CONF_DEBUG_OPTIONS}"
#--with-sysroot=="$INSTALL_ROOT"
cd ..
mkdir build && cd build
eval "$CMAKE" "${CMAKE_CROSSCOMPILING_OPTS}" -DCMAKE_INSTALL_PREFIX="$INSTALL_ROOT" -DCMAKE_BUILD_TYPE="$TOP_CMAKE_BUILD_TYPE" \
-DBUILD_SHARED_LIBS=OFF -DLIBUV_BUILD_SHARED=OFF\
..
cd ../..
fi
echo -e "${COLOR_INFO}building it${COLOR_DOTS}...${COLOR_RESET}"
cd libuv
cd libuv/build
eval "$MAKE" "${PARALLEL_MAKE_OPTIONS}"
eval "$MAKE" "${PARALLEL_MAKE_OPTIONS}" install
cd ..
cd ../..
cd "$SOURCES_ROOT"
else
echo -e "${COLOR_SUCCESS}SKIPPED${COLOR_RESET}"
Expand Down Expand Up @@ -1391,13 +1395,21 @@ then
cd boost_1_68_0
echo -e "${COLOR_INFO}configuring and building it${COLOR_DOTS}...${COLOR_RESET}"
eval ./bootstrap.sh --prefix="$INSTALL_ROOT" --with-libraries=atomic,context,filesystem,program_options,regex,system,thread,date_time,iostreams

if [ "$DEBUG" = "1" ]; then
variant=debug
else
variant=release
fi

if [ ${ARCH} = "arm" ]
then
sed -i -e 's#using gcc ;#using gcc : arm : /usr/local/toolchains/gcc7.2-arm/bin/arm-linux-gnueabihf-g++ ;#g' project-config.jam
eval ./b2 "${CONF_CROSSCOMPILING_OPTS_BOOST}" cxxflags=-fPIC cflags=-fPIC "${PARALLEL_MAKE_OPTIONS}" --prefix="$INSTALL_ROOT" --layout=system variant=debug link=static threading=multi install
eval ./b2 "${CONF_CROSSCOMPILING_OPTS_BOOST}" cxxflags=-fPIC cflags=-fPIC "${PARALLEL_MAKE_OPTIONS}" --prefix="$INSTALL_ROOT" --layout=system variant=$variant link=static threading=multi install
else
eval ./b2 cxxflags=-fPIC cflags=-fPIC "${PARALLEL_MAKE_OPTIONS}" --prefix="$INSTALL_ROOT" --layout=system variant=debug link=static threading=multi install
eval ./b2 cxxflags=-fPIC cflags=-fPIC "${PARALLEL_MAKE_OPTIONS}" --prefix="$INSTALL_ROOT" --layout=system variant=$variant link=static threading=multi install
fi

cd ..
cd "$SOURCES_ROOT"
else
Expand Down Expand Up @@ -2082,6 +2094,7 @@ then
eval tar -xzf folly-from-git.tar.gz
fi
echo -e "${COLOR_INFO}fixing it${COLOR_DOTS}...${COLOR_RESET}"
sed -i 's/list(APPEND FOLLY_LINK_LIBRARIES ${LIBUNWIND_LIBRARIES})/list(APPEND FOLLY_LINK_LIBRARIES ${LIBUNWIND_LIBRARIES} lzma)/' ./folly/CMake/folly-deps.cmake
sed -i 's/google::InstallFailureFunction(abort);/google::InstallFailureFunction( reinterpret_cast < google::logging_fail_func_t > ( abort ) );/g' ./folly/folly/init/Init.cpp
echo -e "${COLOR_INFO}configuring it${COLOR_DOTS}...${COLOR_RESET}"
cd folly
Expand All @@ -2091,6 +2104,8 @@ then
-DBOOST_ROOT="$INSTALL_ROOT" -DBOOST_LIBRARYDIR="$INSTALL_ROOT/lib" -DBoost_NO_WARN_NEW_VERSIONS=1 -DBoost_DEBUG=ON \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF -DBUILD_BROKEN_TESTS=OFF -DBUILD_HANGING_TESTS=OFF -DBUILD_SLOW_TESTS=OFF \
-DCMAKE_INCLUDE_PATH="${INSTALL_ROOT}/include" \
-DCMAKE_LIBRARY_PATH="${INSTALL_ROOT}/lib" \
..
cd ..
else
Expand All @@ -2100,6 +2115,9 @@ then
cd build2
eval "$MAKE" "${PARALLEL_MAKE_OPTIONS}"
eval "$MAKE" "${PARALLEL_MAKE_OPTIONS}" install
if [ "$DEBUG" = "0" ]; then
eval strip --strip-debug "${INSTALL_ROOT}"/lib/libfolly*.a
fi
cd "$SOURCES_ROOT"
else
echo -e "${COLOR_SUCCESS}SKIPPED${COLOR_RESET}"
Expand Down
4 changes: 3 additions & 1 deletion libethcore/ChainOperationParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ EVMSchedule const ChainOperationParams::makeEvmSchedule(
result = EIP158Schedule;
else if ( _workingBlockNumber >= EIP150ForkBlock )
result = EIP150Schedule;
else if ( _workingBlockNumber >= homesteadForkBlock )
return HomesteadSchedule;
else
result = HomesteadSchedule;
return FrontierSchedule;

// 2 based on previous - decide by timestamp
if ( PushZeroPatch::isEnabledWhen( _committedBlockTimestamp ) )
Expand Down
11 changes: 7 additions & 4 deletions libethcore/ChainOperationParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class PrecompiledContract {
u256 const& _blockNumber ) const {
return m_cost( _in, _chainParams, _blockNumber );
}
std::pair< bool, bytes > execute( bytesConstRef _in ) const { return m_execute( _in ); }
std::pair< bool, bytes > execute(
bytesConstRef _in, skale::OverlayFS* _overlayFS = nullptr ) const {
return m_execute( _in, _overlayFS );
}

u256 const& startingBlock() const { return m_startingBlock; }

Expand Down Expand Up @@ -270,9 +273,9 @@ struct ChainOperationParams {
Address const& _a, bytesConstRef _in, u256 const& _blockNumber ) const {
return precompiled.at( _a ).cost( _in, *this, _blockNumber );
}
std::pair< bool, bytes > executePrecompiled(
Address const& _a, bytesConstRef _in, u256 const& ) const {
return precompiled.at( _a ).execute( _in );
std::pair< bool, bytes > executePrecompiled( Address const& _a, bytesConstRef _in, u256 const&,
skale::OverlayFS* _overlayFS = nullptr ) const {
return precompiled.at( _a ).execute( _in, _overlayFS );
}
bool precompiledExecutionAllowedFrom(
Address const& _a, Address const& _from, bool _readOnly ) const {
Expand Down
2 changes: 2 additions & 0 deletions libethcore/EVMSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ struct EVMSchedule {
};

static const EVMSchedule DefaultSchedule = EVMSchedule();
// Used only in GeneralStateTests --all tests
static const EVMSchedule FrontierSchedule = EVMSchedule( false, false, 21000 );
static const EVMSchedule HomesteadSchedule = EVMSchedule( true, true, 53000 );

static const EVMSchedule EIP150Schedule = [] {
Expand Down
7 changes: 2 additions & 5 deletions libethereum/Executive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,8 @@ bool Executive::call( CallParameters const& _p, u256 const& _gasPrice, Address c
m_gas = ( u256 )( _p.gas - g );
bytes output;
bool success;
// dev::eth::g_state = m_s.delegateWrite();
dev::eth::g_overlayFS = m_s.fs();
tie( success, output ) =
m_chainParams.executePrecompiled( _p.codeAddress, _p.data, m_envInfo.number() );
// m_s = dev::eth::g_state.delegateWrite();
tie( success, output ) = m_chainParams.executePrecompiled(
_p.codeAddress, _p.data, m_envInfo.number(), m_s.fs().get() );
size_t outputSize = output.size();
m_output = owning_bytes_ref{ std::move( output ), 0, outputSize };
if ( !success ) {
Expand Down
114 changes: 31 additions & 83 deletions libethereum/Precompiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ namespace eth {

std::shared_ptr< skutils::json_config_file_accessor > g_configAccesssor;
std::shared_ptr< SkaleHost > g_skaleHost;
std::shared_ptr< skale::OverlayFS > g_overlayFS;

}; // namespace eth
}; // namespace dev
Expand Down Expand Up @@ -281,7 +280,10 @@ boost::filesystem::path getFileStorageDir( const Address& _address ) {
}

// TODO: check file name and file existance
ETH_REGISTER_PRECOMPILED( createFile )( bytesConstRef _in ) {
ETH_REGISTER_FS_PRECOMPILED( createFile )( bytesConstRef _in, skale::OverlayFS* _overlayFS ) {
if ( !_overlayFS )
throw runtime_error( "_overlayFS is nullptr " );

try {
auto rawAddress = _in.cropped( 12, 20 ).toBytes();
std::string address;
Expand All @@ -297,14 +299,14 @@ ETH_REGISTER_PRECOMPILED( createFile )( bytesConstRef _in ) {
const fs::path filePath( rawFilename );
const fs::path fsDirectoryPath = getFileStorageDir( Address( address ) );
if ( !fs::exists( fsDirectoryPath ) ) {
g_overlayFS->createDirectory( fsDirectoryPath.string() );
_overlayFS->createDirectory( fsDirectoryPath.string() );
}
const fs::path fsFilePath = fsDirectoryPath / filePath.parent_path();
if ( filePath.filename().extension() == "._hash" ) {
throw std::runtime_error(
"createFile() failed because _hash extension is not allowed" );
}
g_overlayFS->createFile( ( fsFilePath / filePath.filename() ).string(), fileSize );
_overlayFS->createFile( ( fsFilePath / filePath.filename() ).string(), fileSize );

u256 code = 1;
bytes response = toBigEndian( code );
Expand All @@ -322,7 +324,10 @@ ETH_REGISTER_PRECOMPILED( createFile )( bytesConstRef _in ) {
return { false, response };
}

ETH_REGISTER_PRECOMPILED( uploadChunk )( bytesConstRef _in ) {
ETH_REGISTER_FS_PRECOMPILED( uploadChunk )( bytesConstRef _in, skale::OverlayFS* _overlayFS ) {
if ( !_overlayFS )
throw runtime_error( "_overlayFS is nullptr " );

try {
auto rawAddress = _in.cropped( 12, 20 ).toBytes();
std::string address;
Expand All @@ -349,7 +354,7 @@ ETH_REGISTER_PRECOMPILED( uploadChunk )( bytesConstRef _in ) {
const _byte_* data =
_in.cropped( 128 + filenameBlocksCount * UINT256_SIZE, dataLength ).data();

g_overlayFS->writeChunk( filePath.string(), position, dataLength, data );
_overlayFS->writeChunk( filePath.string(), position, dataLength, data );

u256 code = 1;
bytes response = toBigEndian( code );
Expand Down Expand Up @@ -451,7 +456,10 @@ ETH_REGISTER_PRECOMPILED( getFileSize )( bytesConstRef _in ) {
return { false, response };
}

ETH_REGISTER_PRECOMPILED( deleteFile )( bytesConstRef _in ) {
ETH_REGISTER_FS_PRECOMPILED( deleteFile )( bytesConstRef _in, skale::OverlayFS* _overlayFS ) {
if ( !_overlayFS )
throw runtime_error( "_overlayFS is nullptr " );

try {
auto rawAddress = _in.cropped( 12, 20 ).toBytes();
std::string address;
Expand All @@ -462,8 +470,8 @@ ETH_REGISTER_PRECOMPILED( deleteFile )( bytesConstRef _in ) {

const fs::path filePath = getFileStorageDir( Address( address ) ) / filename;

g_overlayFS->deleteFile( filePath.string() );
g_overlayFS->deleteFile( filePath.string() + "._hash" );
_overlayFS->deleteFile( filePath.string() );
_overlayFS->deleteFile( filePath.string() + "._hash" );

u256 code = 1;
bytes response = toBigEndian( code );
Expand All @@ -481,7 +489,10 @@ ETH_REGISTER_PRECOMPILED( deleteFile )( bytesConstRef _in ) {
return { false, response };
}

ETH_REGISTER_PRECOMPILED( createDirectory )( bytesConstRef _in ) {
ETH_REGISTER_FS_PRECOMPILED( createDirectory )( bytesConstRef _in, skale::OverlayFS* _overlayFS ) {
if ( !_overlayFS )
throw runtime_error( "_overlayFS is nullptr " );

try {
auto rawAddress = _in.cropped( 12, 20 ).toBytes();
std::string address;
Expand All @@ -491,7 +502,7 @@ ETH_REGISTER_PRECOMPILED( createDirectory )( bytesConstRef _in ) {
convertBytesToString( _in, 32, directoryPath, directoryPathLength );

const fs::path absolutePath = getFileStorageDir( Address( address ) ) / directoryPath;
g_overlayFS->createDirectory( absolutePath.string() );
_overlayFS->createDirectory( absolutePath.string() );

u256 code = 1;
bytes response = toBigEndian( code );
Expand All @@ -509,7 +520,10 @@ ETH_REGISTER_PRECOMPILED( createDirectory )( bytesConstRef _in ) {
return { false, response };
}

ETH_REGISTER_PRECOMPILED( deleteDirectory )( bytesConstRef _in ) {
ETH_REGISTER_FS_PRECOMPILED( deleteDirectory )( bytesConstRef _in, skale::OverlayFS* _overlayFS ) {
if ( !_overlayFS )
throw runtime_error( "_overlayFS is nullptr " );

try {
auto rawAddress = _in.cropped( 12, 20 ).toBytes();
std::string address;
Expand All @@ -525,8 +539,8 @@ ETH_REGISTER_PRECOMPILED( deleteDirectory )( bytesConstRef _in ) {

const std::string absolutePathStr = absolutePath.string();

g_overlayFS->deleteFile( absolutePathStr + "._hash" );
g_overlayFS->deleteDirectory( absolutePath.string() );
_overlayFS->deleteFile( absolutePathStr + "._hash" );
_overlayFS->deleteDirectory( absolutePath.string() );

u256 code = 1;
bytes response = toBigEndian( code );
Expand All @@ -544,7 +558,8 @@ ETH_REGISTER_PRECOMPILED( deleteDirectory )( bytesConstRef _in ) {
return { false, response };
}

ETH_REGISTER_PRECOMPILED( calculateFileHash )( bytesConstRef _in ) {
ETH_REGISTER_FS_PRECOMPILED( calculateFileHash )
( bytesConstRef _in, skale::OverlayFS* _overlayFS ) {
try {
auto rawAddress = _in.cropped( 12, 20 ).toBytes();
std::string address;
Expand All @@ -560,7 +575,7 @@ ETH_REGISTER_PRECOMPILED( calculateFileHash )( bytesConstRef _in ) {
throw std::runtime_error( "calculateFileHash() failed because file does not exist" );
}

g_overlayFS->calculateFileHash( filePath.string() );
_overlayFS->calculateFileHash( filePath.string() );

u256 code = 1;
bytes response = toBigEndian( code );
Expand Down Expand Up @@ -1057,30 +1072,6 @@ ETH_REGISTER_PRECOMPILED( getBlockRandom )( bytesConstRef ) {
}

ETH_REGISTER_PRECOMPILED( addBalance )( [[maybe_unused]] bytesConstRef _in ) {
/*
try {
auto rawAddress = _in.cropped( 0, 20 ).toBytes();
std::string address;
boost::algorithm::hex( rawAddress.begin(), rawAddress.end(), back_inserter( address ) );
auto add = parseBigEndianRightPadded( _in, 20, 32 );
auto value = u256( add );
g_state.addBalance( Address( address ), value );
dev::u256 code = 1;
bytes response = toBigEndian( code );
return {true, response};
} catch ( std::exception& ex ) {
std::string strError = ex.what();
if ( strError.empty() )
strError = "exception without description";
LOG( getLogger( VerbosityError ) )
<< "Exception in precompiled/addBalance(): " << strError << "\n";
} catch ( ... ) {
LOG( getLogger( VerbosityError ) ) << "Unknown exception in precompiled/addBalance()\n";
}
*/
dev::u256 code = 0;
bytes response = toBigEndian( code );
return { false, response }; // 1st false - means bad error occur
Expand Down Expand Up @@ -1111,47 +1102,4 @@ ETH_REGISTER_PRECOMPILED( getIMABLSPublicKey )( bytesConstRef ) {
return { false, response }; // 1st false - means bad error occur
}

// ETH_REGISTER_PRECOMPILED( convertUint256ToString )( bytesConstRef _in ) {
// try {
// auto rawValue = _in.cropped( 0, 32 ).toBytes();
// std::string strValue = "";
// boost::algorithm::hex( rawValue.begin(), rawValue.end(), back_inserter( strValue ) );
// bytes response = stat_string_to_bytes_with_length( strValue );
// return {true, response};
// } catch ( std::exception& ex ) {
// std::string strError = ex.what();
// if ( strError.empty() )
// strError = "exception without description";
// LOG( getLogger( VerbosityError ) )
// << "Exception in precompiled/convertUint256ToString(): " << strError << "\n";
// } catch ( ... ) {
// LOG( getLogger( VerbosityError ) )
// << "Unknown exception in precompiled/convertUint256ToString()\n";
// }
// u256 code = 0;
// bytes response = toBigEndian( code );
// return {false, response}; // 1st false - means bad error occur
//}
// ETH_REGISTER_PRECOMPILED( convertAddressToString )( bytesConstRef _in ) {
// try {
// auto rawAddress = _in.cropped( 12, 20 ).toBytes();
// std::string strValue = "";
// boost::algorithm::hex( rawAddress.begin(), rawAddress.end(), back_inserter( strValue ) );
// bytes response = stat_string_to_bytes_with_length( strValue );
// return {true, response};
// } catch ( std::exception& ex ) {
// std::string strError = ex.what();
// if ( strError.empty() )
// strError = "exception without description";
// LOG( getLogger( VerbosityError ) )
// << "Exception in precompiled/convertAddressToString(): " << strError << "\n";
// } catch ( ... ) {
// LOG( getLogger( VerbosityError ) )
// << "Unknown exception in precompiled/convertAddressToString()\n";
// }
// u256 code = 0;
// bytes response = toBigEndian( code );
// return {false, response}; // 1st false - means bad error occur
//}

} // namespace
Loading

0 comments on commit 56a1549

Please sign in to comment.