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

State dump #97

Merged
merged 57 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
e271747
initial MutableBlock definition
jcarraror Mar 4, 2024
ddcf788
Add definition for FinalizedBlock and refine MutableBlock
Jean-Lessa Mar 4, 2024
f189fd8
initial impl for mutable block
jcarraror Mar 5, 2024
6d630cb
add remaining functions
jcarraror Mar 7, 2024
163c3a7
finish finalized class
jcarraror Mar 7, 2024
069f950
ex
jcarraror Mar 7, 2024
4ee91c4
change block tests
jcarraror Mar 7, 2024
f9f6b46
change Block usage for Mutable/Finalized
jcarraror Mar 11, 2024
8b3c1e2
fix storage tests
jcarraror Mar 11, 2024
5179678
Add dump first version
lambdart Mar 19, 2024
27e42c3
Fix tests constructors initialization
lambdart Mar 19, 2024
0592264
Add dump manager to the constructor signature
lambdart Mar 19, 2024
492e370
Declare storage as a dumpable entity
lambdart Mar 19, 2024
6e2268a
Implement dump virtual method
lambdart Mar 19, 2024
c82038a
Add dump message prefix
lambdart Mar 28, 2024
384963f
Remove dumpable inheritance
lambdart Mar 28, 2024
7de4d8d
Add DumpWorker entity
lambdart Mar 28, 2024
c73272d
Implement Dump-Worker/Manager methods
lambdart Mar 28, 2024
c1afe9c
Add dump files do cmakelist
lambdart Mar 28, 2024
9496a47
Adapt rdpos to be dumpable
lambdart Mar 28, 2024
59bc2e4
Setup dbState and dump entities
lambdart Mar 28, 2024
64a84db
Fix dump.h includes and remove DumpManager object
lambdart Mar 28, 2024
945e298
Implement the register method
lambdart Apr 9, 2024
16fbdb9
Fix dumpable auto register
lambdart Apr 9, 2024
9ccb6b0
Add Dump Manager object to the state
lambdart Apr 9, 2024
4f25ad5
Remove Dump Manager
lambdart Apr 9, 2024
3e434f5
Add extra functionalities
itamarcps Apr 9, 2024
aebca67
Include EVM Libraries, prototype EVM Host
itamarcps Apr 12, 2024
3fb2f71
Add vector size verification
lambdart Apr 12, 2024
61b7377
Add dump manager test
lambdart Apr 12, 2024
58135b9
Fix variable name
lambdart Apr 12, 2024
8405284
Add override and dump documentation
lambdart Apr 12, 2024
cce8eca
Add override
lambdart Apr 12, 2024
2af8dad
Merge pull request #100 from SparqNet/feature/dump_manager
lambdart Apr 13, 2024
a7b409e
Update EthCallInfo to include fullData
itamarcps Apr 15, 2024
450951b
Fix ProjectEVMOne when compiling for debug
itamarcps Apr 15, 2024
9f83f69
Implement StorageKey
itamarcps Apr 15, 2024
98bf44c
Integrate EVM, implement ContractHost and ContractStack
itamarcps Apr 18, 2024
d63e483
Fix Contract Tests
itamarcps Apr 19, 2024
6a127cf
Fix State tests
itamarcps Apr 20, 2024
cb792b7
Fix remaining tests
itamarcps Apr 22, 2024
749bf76
Fix EVM Contract deployment, Storage access and memory leaks
itamarcps Apr 22, 2024
e738ff6
Add more EVM tests
itamarcps Apr 22, 2024
2034142
Replace EthCallInfo with evmc_message
itamarcps Apr 23, 2024
02af7ff
Fix ContractHost::createNewContract missing details
itamarcps Apr 23, 2024
9686355
Add return to Utils::makeFunctor
itamarcps Apr 23, 2024
0458928
Fix ABI tests
itamarcps Apr 23, 2024
8d77d37
Fix State tests
itamarcps Apr 23, 2024
cd88834
Add NonNullUniquePointer<Account> for State::accounts_
itamarcps Apr 23, 2024
3cbc700
Improve State::accounts_ map usage
itamarcps Apr 23, 2024
3b6212e
Add EVM -> CPP interoperability
itamarcps Apr 24, 2024
50723b4
Fix ContractAbiGenerator tests
itamarcps Apr 24, 2024
04ba383
Add TContract::registerContract() to SDKTestSuite::callViewFunction
itamarcps Apr 24, 2024
2762893
Add CPP -> EVM interoperability
itamarcps Apr 24, 2024
a2b507b
Merge pull request #102 from SparqNet/evm
itamarcps Apr 25, 2024
da42a29
Merge branch 'evm-statedump-integration' into state_dump
itamarcps Apr 25, 2024
96a6ed5
Make it compilable
itamarcps Apr 25, 2024
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
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS OFF)
SET(DEBUG ON CACHE BOOL "Debug mode")
if(DEBUG)
set(CMAKE_CXX_FLAGS "-O0 -g -fsanitize=address -fno-inline -fno-eliminate-unused-debug-types -fstack-protector -Werror=unused-variable") # Provides faster compile time.
set(CMAKE_CXX_FLAGS "-O0 -g -fno-inline -fno-eliminate-unused-debug-types -Werror=unused-variable") # Provides faster compile time.
elseif(SONARQUBE_ANALYSIS)
set(CMAKE_CXX_FLAGS "-O0 -g --coverage")
else()
Expand All @@ -34,9 +34,9 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") # Always look for static libraries - "ZLIB
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # For clang-tidy

# Set project version inside the code (forcefully so changes in the .in file are always reflected correctly to the compiler)
if (EXISTS ${CMAKE_SOURCE_DIR}/src/utils/options.h)
file(REMOVE ${CMAKE_SOURCE_DIR}/src/utils/options.h)
endif()
# if (EXISTS ${CMAKE_SOURCE_DIR}/src/utils/options.h)
# file(REMOVE ${CMAKE_SOURCE_DIR}/src/utils/options.h)
# endif()
configure_file(
${CMAKE_SOURCE_DIR}/src/utils/options.h.in
${CMAKE_SOURCE_DIR}/src/utils/options.h
Expand Down Expand Up @@ -88,6 +88,8 @@ include(cmake/ProjectBoostCertify.cmake) # Boost Certify
include(cmake/ProjectEthash.cmake) # Ethash
include(cmake/ProjectSecp256k1.cmake) # Bitcoin core fast implementation
include(cmake/ProjectSpeedb.cmake) # Speedb (Level/RocksDB drop-in replacement)
include(cmake/ProjectEVMOne.cmake) # EVMOne (EVMOne + EVMC)


# Add catch2 as a library
add_library(catch2
Expand Down Expand Up @@ -382,7 +384,7 @@ if(BUILD_AVALANCHEGO)
${NET_SOURCES}
)

add_dependencies(orbitersdk_lib gen-grpc ProtoFiles)
add_dependencies(orbitersdk_lib gen-grpc ProtoFiles Evmc)

target_include_directories(orbitersdk_lib PUBLIC ${CMAKE_SOURCE_DIR}/include ${OPENSSL_INCLUDE_DIR})

Expand All @@ -408,7 +410,7 @@ else()

target_include_directories(orbitersdk_lib PRIVATE ${CMAKE_SOURCE_DIR}/include ${OPENSSL_INCLUDE_DIR})

target_link_libraries(orbitersdk_lib PRIVATE
target_link_libraries(orbitersdk_lib PRIVATE EvmcInstructions EvmcLoader EvmcTooling Evmone
${CRYPTOPP_LIBRARIES} ${SCRYPT_LIBRARY} Secp256k1 Ethash ${ETHASH_BYPRODUCTS}
Speedb ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES}
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/ProjectBoostCertify.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ExternalProject_Add(
URL_HASH SHA256=1c964b0aba47cd90081eaacc4946ea8e58d0c14fb267856f26515219e8ca1d68
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/cmake/certifyPatch.patch
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS}
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
Expand Down
87 changes: 87 additions & 0 deletions cmake/ProjectEVMOne.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
include(ExternalProject)

if (MSVC)
set(_only_release_configuration -DCMAKE_CONFIGURATION_TYPES=Release)
set(_overwrite_install_command INSTALL_COMMAND cmake --build <BINARY_DIR> --config Release --target install)
endif()

set(prefix "${CMAKE_BINARY_DIR}/deps")
set(EVMONE_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}evmone${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(EVMONE_INCLUDE_DIR "${prefix}/include")
set(EVMONE_VERSION "0.11.0")
set(EVMC_INCLUDE_DIR "${prefix}/include")
set(EVMC_INSTRUCTIONS_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}evmc-instructions${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(EVMC_LOADER_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}evmc-loader${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(EVMC_TOOLING_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}tooling${CMAKE_STATIC_LIBRARY_SUFFIX}")

if(DEBUG)
## EVMONE Can't be compiled with address sanitizer/stack protector
## due to GCC stack size limits and GCC not accepting -Wno-stack-usage as a ignore error flag
set(EVMONE_CXX_FLAGS "-O0 -g -fno-inline -fno-eliminate-unused-debug-types -Werror=unused-variable") # Provides faster compile time.
ExternalProject_Add(
evmone
PREFIX "${prefix}"
GIT_REPOSITORY https://github.com/chfast/evmone
GIT_TAG "v${EVMONE_VERSION}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${prefix}
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${EVMONE_CXX_FLAGS}
-DBUILD_SHARED_LIBS=OFF
-DEVMC_INSTALL=ON
-DCMAKE_INSTALL_LIBDIR=lib
${_only_release_configuration}
LOG_CONFIGURE 1
${_overwrite_install_command}
LOG_INSTALL 1
BUILD_BYPRODUCTS ${EVMONE_LIBRARY}
BUILD_BYPRODUCTS ${EVMC_INSTRUCTIONS_LIBRARY}
BUILD_BYPRODUCTS ${EVMC_LOADER_LIBRARY}
BUILD_BYPRODUCTS ${EVMC_TOOLING_LIBRARY}
)
else()
ExternalProject_Add(
evmone
PREFIX "${prefix}"
GIT_REPOSITORY https://github.com/chfast/evmone
GIT_TAG "v${EVMONE_VERSION}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${prefix}
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DBUILD_SHARED_LIBS=OFF
-DEVMC_INSTALL=ON
-DCMAKE_INSTALL_LIBDIR=lib
${_only_release_configuration}
LOG_CONFIGURE 1
${_overwrite_install_command}
LOG_INSTALL 1
BUILD_BYPRODUCTS ${EVMONE_LIBRARY}
BUILD_BYPRODUCTS ${EVMC_INSTRUCTIONS_LIBRARY}
BUILD_BYPRODUCTS ${EVMC_LOADER_LIBRARY}
BUILD_BYPRODUCTS ${EVMC_TOOLING_LIBRARY}
)
endif()

# Create imported library
add_library(Evmone STATIC IMPORTED)
file(MAKE_DIRECTORY "${EVMONE_INCLUDE_DIR}") # Must exist.
set_property(TARGET Evmone PROPERTY IMPORTED_CONFIGURATIONS Release)
set_property(TARGET Evmone PROPERTY IMPORTED_LOCATION_RELEASE "${EVMONE_LIBRARY}")
set_property(TARGET Evmone PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${EVMONE_INCLUDE_DIR}")
add_dependencies(Evmone evmone ${EVMONE_LIBRARY} ${EVMONE_BYPRODUCTS})

# Create an imported target for each library
add_library(EvmcInstructions STATIC IMPORTED)
set_property(TARGET EvmcInstructions PROPERTY IMPORTED_LOCATION "${EVMC_INSTRUCTIONS_LIBRARY}")
add_dependencies(EvmcInstructions evmone)

add_library(EvmcLoader STATIC IMPORTED)
set_property(TARGET EvmcLoader PROPERTY IMPORTED_LOCATION "${EVMC_LOADER_LIBRARY}")
add_dependencies(EvmcLoader evmone)

add_library(EvmcTooling STATIC IMPORTED)
set_property(TARGET EvmcTooling PROPERTY IMPORTED_LOCATION "${EVMC_TOOLING_LIBRARY}")
add_dependencies(EvmcTooling evmone)
2 changes: 1 addition & 1 deletion cmake/ProjectEthash.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ExternalProject_Add(
GIT_REPOSITORY https://github.com/chfast/ethash
GIT_TAG "v${ETHASH_VERSION}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${prefix}
-DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS}
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
Expand Down
48 changes: 48 additions & 0 deletions cmake/ProjectEvmc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
include(ExternalProject)

if (MSVC)
set(_only_release_configuration -DCMAKE_CONFIGURATION_TYPES=Release)
set(_overwrite_install_command INSTALL_COMMAND cmake --build <BINARY_DIR> --config Release --target install)
endif()

set(prefix "${CMAKE_BINARY_DIR}/deps")
set(EVMC_INCLUDE_DIR "${prefix}/include")
set(EVMC_INSTRUCTIONS_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}evmc-instructions${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(EVMC_LOADER_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}evmc-loader${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(EVMC_TOOLING_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}tooling${CMAKE_STATIC_LIBRARY_SUFFIX}")

set(EVMC_VERSION "11.0.1")

ExternalProject_Add(
evmc
PREFIX "${prefix}"
GIT_REPOSITORY https://github.com/ethereum/evmc
GIT_TAG "v${EVMC_VERSION}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${prefix}
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_INSTALL_LIBDIR=lib
${_only_release_configuration}
LOG_CONFIGURE 1
${_overwrite_install_command}
LOG_INSTALL 1
BUILD_BYPRODUCTS ${EVMC_INSTRUCTIONS_LIBRARY}
BUILD_BYPRODUCTS ${EVMC_LOADER_LIBRARY}
BUILD_BYPRODUCTS ${EVMC_TOOLING_LIBRARY}
)

# Create an imported target for each library
add_library(EvmcInstructions STATIC IMPORTED)
set_property(TARGET EvmcInstructions PROPERTY IMPORTED_LOCATION "${EVMC_INSTRUCTIONS_LIBRARY}")
add_dependencies(EvmcInstructions evmc)

add_library(EvmcLoader STATIC IMPORTED)
set_property(TARGET EvmcLoader PROPERTY IMPORTED_LOCATION "${EVMC_LOADER_LIBRARY}")
add_dependencies(EvmcLoader evmc)

add_library(EvmcTooling STATIC IMPORTED)
set_property(TARGET EvmcTooling PROPERTY IMPORTED_LOCATION "${EVMC_TOOLING_LIBRARY}")
add_dependencies(EvmcTooling evmc)

2 changes: 1 addition & 1 deletion cmake/ProjectSecp256k1.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ExternalProject_Add(
GIT_TAG "v${SECP256K1_VERSION}"
PATCH_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_LIST_DIR}/secp256k1/CMakeLists.txt <SOURCE_DIR>
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${prefix}
-DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS}
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
Expand Down
2 changes: 1 addition & 1 deletion cmake/ProjectSpeedb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ExternalProject_Add(
GIT_REPOSITORY https://github.com/speedb-io/speedb
GIT_TAG "speedb/v${SPEEDB_VERSION}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${prefix}
-DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS}
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
Expand Down
2 changes: 1 addition & 1 deletion scripts/AIO-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ if [ "$ONLY_DEPLOY" = false ]; then
## Build the project
cd build_local_testnet
cmake -DDEBUG=$DEBUG ..
cmake --build . --target orbitersdkd orbitersdkd-discovery -- -j${CORES}
make -j${CORES}
fi

if [ "$DEPLOY" = true ]; then
Expand Down
9 changes: 9 additions & 0 deletions src/bins/orbitersdkd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ std::unique_ptr<Blockchain> blockchain = nullptr;
}

int main() {
uint256_t valueiiii = uint256_t("10000");
auto valueiiiii = Utils::uint256ToEvmcUint256(valueiiii);
auto valueiiiiii = Utils::evmcUint256ToUint256(valueiiiii);
evmc::uint256be value(10000);
uint256_t valuei = Utils::evmcUint256ToUint256(value);
evmc::uint256be valueii = {};
uint256_t valueiii = Utils::evmcUint256ToUint256(valueii);

return 0;
Utils::logToCout = true;
std::string blockchainPath = std::filesystem::current_path().string() + std::string("/blockchain");
blockchain = std::make_unique<Blockchain>(blockchainPath);
Expand Down
6 changes: 4 additions & 2 deletions src/contract/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
set(CONTRACT_HEADERS
${CMAKE_SOURCE_DIR}/src/contract/abi.h
${CMAKE_SOURCE_DIR}/src/contract/contract.h
${CMAKE_SOURCE_DIR}/src/contract/contractcalllogger.h
${CMAKE_SOURCE_DIR}/src/contract/contractstack.h
${CMAKE_SOURCE_DIR}/src/contract/contracthost.h
${CMAKE_SOURCE_DIR}/src/contract/contractfactory.h
${CMAKE_SOURCE_DIR}/src/contract/contractmanager.h
${CMAKE_SOURCE_DIR}/src/contract/customcontracts.h
Expand Down Expand Up @@ -39,8 +40,9 @@ set(CONTRACT_SOURCES
${CMAKE_SOURCE_DIR}/src/contract/abi.cpp
${CMAKE_SOURCE_DIR}/src/contract/contract.cpp
${CMAKE_SOURCE_DIR}/src/contract/contractfactory.cpp
${CMAKE_SOURCE_DIR}/src/contract/contractstack.cpp
${CMAKE_SOURCE_DIR}/src/contract/contracthost.cpp
${CMAKE_SOURCE_DIR}/src/contract/contractmanager.cpp
${CMAKE_SOURCE_DIR}/src/contract/contractcalllogger.cpp
${CMAKE_SOURCE_DIR}/src/contract/dynamiccontract.cpp
${CMAKE_SOURCE_DIR}/src/contract/event.cpp
${CMAKE_SOURCE_DIR}/src/contract/templates/erc20.cpp
Expand Down
7 changes: 5 additions & 2 deletions src/contract/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,11 @@ namespace ABI {
* @param funcSig The function signature (name).
*/
template <typename... Args> static Functor encode(const std::string& funcSig) {
Functor ret;
std::string fullSig = funcSig + "(" + listArgumentTypes<Args...>() + ")";
return Utils::sha3(Utils::create_view_span(fullSig)).view(0, 4);
auto hash = Utils::sha3(Utils::create_view_span(fullSig));
ret.value = Utils::bytesToUint32(hash.view(0,4));
return ret;
}
}; // namespace FunctorEncoder

Expand Down Expand Up @@ -581,7 +584,7 @@ namespace ABI {
template<typename T, typename Enable = void>
struct TypeEncoder {
static Bytes encode(const T&) {
static_assert(always_false<T>, "TypeName specialization for this type is not defined");
static_assert(std::is_same_v<T, void>, "TypeName specialization for this type is not defined");
return Bytes();
}
};
Expand Down
14 changes: 14 additions & 0 deletions src/contract/contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,23 @@ See the LICENSE.txt file in the project root for more information.
*/

#include "contract.h"
#include "contracthost.h"

Address ContractGlobals::coinbase_ = Address(Hex::toBytes("0x0000000000000000000000000000000000000000"));
Hash ContractGlobals::blockHash_ = Hash();
uint64_t ContractGlobals::blockHeight_ = 0;
uint64_t ContractGlobals::blockTimestamp_ = 0;

Address BaseContract::getOrigin() const {
if (this->host_ == nullptr) {
throw DynamicException("Contracts going haywire! trying to get origin without a host!");
}
return this->host_->get_tx_context().tx_origin;
}

uint64_t BaseContract::getNonce(const Address& address) const {
if (this->host_ == nullptr) {
throw DynamicException("Contracts going haywire! trying to get nonce without a host!");
}
return this->host_->getNonce(address);
}
Loading
Loading