diff --git a/.gitignore b/.gitignore index 9ada4fd9..7e477b3d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ Makefile compile_commands.json moc_* *.moc +hardfork.hpp libraries/utilities/git_revision.cpp diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 18f52f16..663a396e 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -1,3 +1,9 @@ + +add_custom_target( build_hardfork_hpp + COMMAND cat-parts hardfork.d include/graphene/chain/hardfork.hpp ) + +add_dependencies( build_hardfork_hpp cat-parts ) + file(GLOB HEADERS "include/graphene/chain/*.hpp") if( GRAPHENE_DISABLE_UNITY_BUILD ) @@ -78,8 +84,10 @@ add_library( graphene_chain block_database.cpp ${HEADERS} + include/graphene/chain/hardfork.hpp ) +add_dependencies( graphene_chain build_hardfork_hpp ) target_link_libraries( graphene_chain fc graphene_db ) target_include_directories( graphene_chain PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/chain/hardfork.d/000-200-preamble.hf b/libraries/chain/hardfork.d/000-200-preamble.hf new file mode 100644 index 00000000..52458dcf --- /dev/null +++ b/libraries/chain/hardfork.d/000-200-preamble.hf @@ -0,0 +1,10 @@ +/***************************************** + * * + * This file is automatically generated. * + * To create new hardfork, please modify * + * the .hf files in hardfork.d instead * + * of modifying this file. * + * * + *****************************************/ + +#pragma once diff --git a/libraries/chain/hardfork.d/357.hf b/libraries/chain/hardfork.d/357.hf new file mode 100644 index 00000000..650b9a7a --- /dev/null +++ b/libraries/chain/hardfork.d/357.hf @@ -0,0 +1,4 @@ +// #357 Disallow publishing certain malformed price feeds +#ifndef HARDFORK_357_TIME +#define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 )) +#endif diff --git a/libraries/chain/hardfork.d/359.hf b/libraries/chain/hardfork.d/359.hf new file mode 100644 index 00000000..c52576d0 --- /dev/null +++ b/libraries/chain/hardfork.d/359.hf @@ -0,0 +1,4 @@ +// #359 Allow digits in asset name +#ifndef HARDFORK_359_TIME +#define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 )) +#endif diff --git a/libraries/chain/hardfork.d/409.hf b/libraries/chain/hardfork.d/409.hf new file mode 100644 index 00000000..87629140 --- /dev/null +++ b/libraries/chain/hardfork.d/409.hf @@ -0,0 +1,4 @@ +// #409 Allow creation of sub-assets +#ifndef HARDFORK_409_TIME +#define HARDFORK_409_TIME (fc::time_point_sec( 1446652800 )) +#endif diff --git a/libraries/chain/hardfork.d/413.hf b/libraries/chain/hardfork.d/413.hf new file mode 100644 index 00000000..c0ce3690 --- /dev/null +++ b/libraries/chain/hardfork.d/413.hf @@ -0,0 +1,4 @@ +// #413 Add operation to claim asset fees +#ifndef HARDFORK_413_TIME +#define HARDFORK_413_TIME (fc::time_point_sec( 1446652800 )) +#endif diff --git a/libraries/chain/hardfork.d/415.hf b/libraries/chain/hardfork.d/415.hf new file mode 100644 index 00000000..94645270 --- /dev/null +++ b/libraries/chain/hardfork.d/415.hf @@ -0,0 +1,4 @@ +// #415 Default accept policy for asset with no whitelist authorities +#ifndef HARDFORK_415_TIME +#define HARDFORK_415_TIME (fc::time_point_sec( 1446652800 )) +#endif diff --git a/libraries/chain/hardfork.d/416.hf b/libraries/chain/hardfork.d/416.hf new file mode 100644 index 00000000..2c3319d1 --- /dev/null +++ b/libraries/chain/hardfork.d/416.hf @@ -0,0 +1,4 @@ +// #416 enforce_white_list is inconsistently applied +#ifndef HARDFORK_416_TIME +#define HARDFORK_416_TIME (fc::time_point_sec( 1446652800 )) +#endif diff --git a/libraries/chain/hardfork.d/419.hf b/libraries/chain/hardfork.d/419.hf new file mode 100644 index 00000000..c5bbf68d --- /dev/null +++ b/libraries/chain/hardfork.d/419.hf @@ -0,0 +1,4 @@ +// #419 Account can pay fees in blacklisted asset +#ifndef HARDFORK_419_TIME +#define HARDFORK_419_TIME (fc::time_point_sec( 1446652800 )) +#endif diff --git a/libraries/chain/hardfork.d/436.hf b/libraries/chain/hardfork.d/436.hf new file mode 100644 index 00000000..1c030eb6 --- /dev/null +++ b/libraries/chain/hardfork.d/436.hf @@ -0,0 +1,4 @@ +// #436 Prevent margin call from being triggered unless feed < call price +#ifndef HARDFORK_436_TIME +#define HARDFORK_436_TIME (fc::time_point_sec( 1450288800 )) +#endif diff --git a/libraries/chain/hardfork.d/445.hf b/libraries/chain/hardfork.d/445.hf new file mode 100644 index 00000000..30178b7a --- /dev/null +++ b/libraries/chain/hardfork.d/445.hf @@ -0,0 +1,4 @@ +// #445 Refund create order fees on cancel +#ifndef HARDFORK_445_TIME +#define HARDFORK_445_TIME (fc::time_point_sec( 1450288800 )) +#endif diff --git a/libraries/chain/hardfork.d/453.hf b/libraries/chain/hardfork.d/453.hf new file mode 100644 index 00000000..6b5226c8 --- /dev/null +++ b/libraries/chain/hardfork.d/453.hf @@ -0,0 +1,4 @@ +// #453 Hardfork to retroactively correct referral percentages +#ifndef HARDFORK_453_TIME +#define HARDFORK_453_TIME (fc::time_point_sec( 1450288800 )) +#endif diff --git a/libraries/chain/hardfork.d/480.hf b/libraries/chain/hardfork.d/480.hf new file mode 100644 index 00000000..a8283ba7 --- /dev/null +++ b/libraries/chain/hardfork.d/480.hf @@ -0,0 +1,4 @@ +// #480 Fix non-BTS MIA core_exchange_rate check +#ifndef HARDFORK_480_TIME +#define HARDFORK_480_TIME (fc::time_point_sec( 1450378800 )) +#endif diff --git a/libraries/chain/hardfork.d/483.hf b/libraries/chain/hardfork.d/483.hf new file mode 100644 index 00000000..f242a74f --- /dev/null +++ b/libraries/chain/hardfork.d/483.hf @@ -0,0 +1,4 @@ +// #483 Operation history numbering change +#ifndef HARDFORK_483_TIME +#define HARDFORK_483_TIME (fc::time_point_sec( 1450378800 )) +#endif diff --git a/libraries/chain/include/graphene/chain/hardfork.hpp b/libraries/chain/include/graphene/chain/hardfork.hpp deleted file mode 100644 index 94eaa5fd..00000000 --- a/libraries/chain/include/graphene/chain/hardfork.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#pragma once - -#define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 )) -#define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 )) -#define HARDFORK_409_TIME (fc::time_point_sec( 1446652800 )) -#define HARDFORK_413_TIME (fc::time_point_sec( 1446652800 )) -#define HARDFORK_415_TIME (fc::time_point_sec( 1446652800 )) -#define HARDFORK_416_TIME (fc::time_point_sec( 1446652800 )) -#define HARDFORK_419_TIME (fc::time_point_sec( 1446652800 )) - -// #436 Prevent margin call from being triggered unless feed < call price -#define HARDFORK_436_TIME (fc::time_point_sec( 1450288800 )) - -// #445 Refund create order fees on cancel -#define HARDFORK_445_TIME (fc::time_point_sec( 1450288800 )) - -// #453 Hardfork to retroactively correct referral percentages -#define HARDFORK_453_TIME (fc::time_point_sec( 1450288800 )) -#define HARDFORK_480_TIME (fc::time_point_sec( 1450378800 )) -// #483 Operation history numbering change -#define HARDFORK_483_TIME (fc::time_point_sec( 1450378800 )) diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 4dee4f68..b17a972c 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -1,3 +1,4 @@ +add_subdirectory( build_helpers ) add_subdirectory( cli_wallet ) add_subdirectory( genesis_util ) add_subdirectory( witness_node ) diff --git a/programs/build_helpers/CMakeLists.txt b/programs/build_helpers/CMakeLists.txt new file mode 100644 index 00000000..678663e2 --- /dev/null +++ b/programs/build_helpers/CMakeLists.txt @@ -0,0 +1,8 @@ + +add_executable( cat-parts cat-parts.cpp ) +if( UNIX AND NOT APPLE ) + set(rt_library rt ) +endif() + +# we only actually need Boost, but link against FC for now so we don't duplicate it. +target_link_libraries( cat-parts PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) diff --git a/programs/build_helpers/cat-parts.cpp b/programs/build_helpers/cat-parts.cpp new file mode 100644 index 00000000..0f06d2dc --- /dev/null +++ b/programs/build_helpers/cat-parts.cpp @@ -0,0 +1,77 @@ + +#include +#include + +#include +#include +#include +#include +#include + +int main( int argc, char** argv, char** envp ) +{ + if( argc != 3 ) + { + std::cerr << "syntax: cat-parts DIR OUTFILE" << std::endl; + return 1; + } + + boost::filesystem::path p(argv[1]); + + try + { + std::vector< boost::filesystem::path > v; + + for( boost::filesystem::directory_iterator it(p); + it != boost::filesystem::directory_iterator(); + ++it ) + { + boost::filesystem::path pit = it->path(); + std::string spit = pit.generic_string(); + size_t n = spit.length(); + if( n <= 3 ) + continue; + if( spit.substr(n-3, 3) != ".hf" ) + continue; + v.push_back( pit ); + } + std::sort( v.begin(), v.end() ); + + // open each file and grab its contents, concatenating into single stringstream + std::stringstream ss_data; + for( const boost::filesystem::path& p : v ) + { + boost::filesystem::ifstream ifs(p); + ss_data << ifs.rdbuf(); + } + std::string new_data = ss_data.str(); + + boost::filesystem::path opath(argv[2]); + + if( boost::filesystem::exists( opath ) ) + { + boost::filesystem::ifstream ifs(opath); + std::stringstream ss_old_data; + ss_old_data << ifs.rdbuf(); + std::string old_data = ss_old_data.str(); + if( old_data == new_data ) + { + std::cerr << "File " << opath << " up-to-date with .d directory" << std::endl; + return 0; + } + } + + { + boost::filesystem::ofstream ofs(opath); + ofs.write( new_data.c_str(), new_data.length() ); + } + + std::cerr << "Built " << opath << " from .d directory" << std::endl; + } + catch( const boost::filesystem::filesystem_error& e ) + { + std::cout << e.what() << std::endl; + return 1; + } + return 0; +}