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

feat: post upgrade 2024 changes #30

Merged
merged 2 commits into from
May 21, 2024
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
2 changes: 1 addition & 1 deletion BCH release table.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Date Knuth name BCHN name Timestamp
2023-May-15 Descartes Upgrade9 1684152000
2024-May-15 Lobachevski Upgrade10 1715774400
2025-May-15 Galois Upgrade11 1747310400
2026-May-15 Leibniz Upgrade12 1778846400

????-???-?? Leibniz ? ?
????-???-?? Cantor ? ?
????-???-?? Peano ? ?
????-???-?? Hilbert ? ?
Expand Down
2 changes: 1 addition & 1 deletion ci_utils
10 changes: 6 additions & 4 deletions conan.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"version": "0.5",
"requires": [
"zlib/1.2.13#e377bee636333ae348d51ca90874e353%1682597484.674",
"zlib/1.3#06023034579559bb64357db3a53f88a4%1692672716.907",
"spdlog/1.13.0#2775cc949e26b339029a852785b6b276%1705707717.233",
"secp256k1/0.18.0#c2e7e05855c71cb8f4e350a7aa10bfa9%1698921631.178",
"libiconv/1.17#fa54397801cd96911a8294bc5fc76335%1675449822.495",
"libbacktrace/cci.20210118#ec1aa63bbc10145c6a299e68e711670c%1676205469.545",
"infrastructure/0.32.0#ca438a22e0ec5b0e3f3bfe421227e761%1706979702.4233263",
"infrastructure/0.32.0#ca438a22e0ec5b0e3f3bfe421227e761%1706978102.691",
"gmp/6.3.0#df20ffb6d21c34d67704305bcd1dea9e%1698225617.026",
"fmt/10.2.1#9199a7a0611866dea5c8849a77467b25%1704415120.216",
"expected-lite/0.6.3#262026767cf9d5ab1fdccb25c9bdbac2%1692807329.641",
Expand All @@ -14,8 +15,9 @@
"boost/1.84.0#695713218cdeec6aef61de1f34bf57ee%1706382844.645"
],
"build_requires": [
"m4/1.4.19#c1c4b1ee919e34630bb9b50046253d3c%1676610086.39",
"m4/1.4.19#b38ced39a01e31fef5435bc634461fd2%1700758725.451",
"b2/4.10.1#8dc3df1cc73ad65d86cbdfd31fdb011f%1690006205.975"
],
"python_requires": []
"python_requires": [],
"config_requires": []
}
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class KnuthDomainConan(KnuthConanFileV2):

def build_requirements(self):
if self.options.tests:
self.test_requires("catch2/3.5.2")
self.test_requires("catch2/3.6.0")

def requirements(self):
self.requires("infrastructure/0.32.0", transitive_headers=True, transitive_libs=True)
Expand Down
32 changes: 24 additions & 8 deletions include/kth/domain/chain/chain_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ class KD_API chain_state {
// , euler_t euler_activation_time
// , gauss_t gauss_activation_time
// , descartes_t descartes_activation_time
, lobachevski_t lobachevski_activation_time
// , lobachevski_t lobachevski_activation_time
, galois_t galois_activation_time
, leibniz_t leibniz_activation_time
#endif //KTH_CURRENCY_BCH
);

Expand Down Expand Up @@ -220,11 +221,14 @@ class KD_API chain_state {
// [[nodiscard]]
// descartes_t descartes_activation_time() const;

[[nodiscard]]
lobachevski_t lobachevski_activation_time() const;
// [[nodiscard]]
// lobachevski_t lobachevski_activation_time() const;

[[nodiscard]]
galois_t galois_activation_time() const;

[[nodiscard]]
leibniz_t leibniz_activation_time() const;
#endif //KTH_CURRENCY_BCH

/// Construction with zero height or any empty array causes invalid state.
Expand Down Expand Up @@ -287,6 +291,9 @@ class KD_API chain_state {
[[nodiscard]]
bool is_galois_enabled() const;

[[nodiscard]]
bool is_leibniz_enabled() const;

#endif //KTH_CURRENCY_BCH

static
Expand All @@ -312,8 +319,9 @@ class KD_API chain_state {
// , euler_t euler_activation_time
// , gauss_t gauss_activation_time
// , descartes_t descartes_activation_time
, lobachevski_t lobachevski_activation_time
// , lobachevski_t lobachevski_activation_time
, galois_t galois_activation_time
, leibniz_t leibniz_activation_time
#endif //KTH_CURRENCY_BCH
);

Expand All @@ -323,8 +331,9 @@ class KD_API chain_state {
// , euler_t euler_activation_time
// , gauss_t gauss_activation_time
// , descartes_t descartes_activation_time
, lobachevski_t lobachevski_activation_time
// , lobachevski_t lobachevski_activation_time
, galois_t galois_activation_time
, leibniz_t leibniz_activation_time
, assert_anchor_block_info_t const& assert_anchor_block_info
, uint32_t asert_half_life
#endif
Expand Down Expand Up @@ -356,6 +365,7 @@ class KD_API chain_state {
size_t bip9_bit1_height(size_t height, uint32_t forks);
#endif

public:
// static
// bool is_rule_enabled(size_t height, uint32_t forks, size_t mainnet_height, size_t testnet_height);
static
Expand Down Expand Up @@ -404,14 +414,19 @@ class KD_API chain_state {
static
bool is_descartes_enabled(size_t height, config::network network);

// static
// bool is_lobachevski_enabled(size_t height, config::network network);
static
bool is_lobachevski_enabled(size_t height, config::network network);

// static
// bool is_galois_enabled(size_t height, config::network network);

// static
// bool is_leibniz_enabled(size_t height, config::network network);

#endif // KTH_CURRENCY_BCH
// ------------------------------------------------------------------------

private:
static
data to_block(chain_state const& pool, block const& block);

Expand Down Expand Up @@ -492,8 +507,9 @@ class KD_API chain_state {
// euler_t const euler_activation_time_;
// gauss_t const gauss_activation_time_;
// descartes_t const descartes_activation_time_;
lobachevski_t const lobachevski_activation_time_;
// lobachevski_t const lobachevski_activation_time_;
galois_t const galois_activation_time_;
leibniz_t const leibniz_activation_time_;
#endif //KTH_CURRENCY_BCH
};

Expand Down
79 changes: 39 additions & 40 deletions include/kth/domain/chain/token_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <utility>
#include <variant>
#include <vector>
#include <version> // for __cpp_lib_three_way_comparison

#include <kth/domain/chain/script.hpp>
#include <kth/domain/define.hpp>
Expand All @@ -37,7 +38,7 @@ template<class> inline constexpr bool always_false_v = false;

namespace encoding {
static constexpr uint8_t PREFIX_BYTE = uint8_t(::kth::domain::machine::opcode::special_token_prefix);
}
} // namespace encoding

using token_id_t = hash_digest;
enum class amount_t : int64_t {};
Expand All @@ -54,44 +55,43 @@ using commitment_t = std::vector<uint8_t>;
// #endif

//TODO(fernando): move to a helper library
#if __cpp_lib_three_way_comparison < 201907L
template <typename I1, typename I2> //, typename Cmp>
constexpr
// auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2, Cmp comp) { //-> decltype(comp(*f1, *f2)) {
auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2) { //-> decltype(comp(*f1, *f2)) {
// using ret_t = decltype(comp(*f1, *f2));
using ret_t = decltype(*f1 <=> *f2);
static_assert(std::disjunction_v<
std::is_same<ret_t, std::strong_ordering>,
std::is_same<ret_t, std::weak_ordering>,
std::is_same<ret_t, std::partial_ordering>>,
"The return type must be a comparison category type.");

bool exhaust1 = (f1 == l1);
bool exhaust2 = (f2 == l2);
for (; !exhaust1 && !exhaust2; exhaust1 = (++f1 == l1), exhaust2 = (++f2 == l2)) {
// if (auto c = comp(*f1, *f2); c != 0) {
if (auto c = *f1 <=> *f2; c != 0) {
return c;
}
}

return !exhaust1 ? std::strong_ordering::greater:
!exhaust2 ? std::strong_ordering::less:
std::strong_ordering::equal;
}

constexpr
auto operator<=>(commitment_t const& x, commitment_t const& y) {
return lexicographical_compare_three_way(x.begin(), x.end(), y.begin(), y.end());
}

constexpr
auto operator<=>(token_id_t const& x, token_id_t const& y) {
return lexicographical_compare_three_way(x.begin(), x.end(), y.begin(), y.end());
}
#endif

// #if __cpp_lib_three_way_comparison < 201907L
// template <typename I1, typename I2> //, typename Cmp>
// constexpr
// // auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2, Cmp comp) { //-> decltype(comp(*f1, *f2)) {
// auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2) { //-> decltype(comp(*f1, *f2)) {
// // using ret_t = decltype(comp(*f1, *f2));
// using ret_t = decltype(*f1 <=> *f2);
// static_assert(std::disjunction_v<
// std::is_same<ret_t, std::strong_ordering>,
// std::is_same<ret_t, std::weak_ordering>,
// std::is_same<ret_t, std::partial_ordering>>,
// "The return type must be a comparison category type.");

// bool exhaust1 = (f1 == l1);
// bool exhaust2 = (f2 == l2);
// for (; !exhaust1 && !exhaust2; exhaust1 = (++f1 == l1), exhaust2 = (++f2 == l2)) {
// // if (auto c = comp(*f1, *f2); c != 0) {
// if (auto c = *f1 <=> *f2; c != 0) {
// return c;
// }
// }

// return !exhaust1 ? std::strong_ordering::greater:
// !exhaust2 ? std::strong_ordering::less:
// std::strong_ordering::equal;
// }

// constexpr
// auto operator<=>(commitment_t const& x, commitment_t const& y) {
// return lexicographical_compare_three_way(x.begin(), x.end(), y.begin(), y.end());
// }

// constexpr
// auto operator<=>(token_id_t const& x, token_id_t const& y) {
// return lexicographical_compare_three_way(x.begin(), x.end(), y.begin(), y.end());
// }
// #endif // __cpp_lib_three_way_comparison

// The values assigned to the low-order nibble of the bitfield byte represent the "permissions" of an NFT.
// For pure-fungible tokens, the value must be none (0x0).
Expand All @@ -102,7 +102,6 @@ enum class capability_t : uint8_t {
minting = 0x02, // If the minting capability is present, it indicates that the encoded token is a non-fungible token used for minting.
};


struct fungible {
amount_t amount;

Expand Down
9 changes: 7 additions & 2 deletions include/kth/domain/config/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,17 @@ kth::infrastructure::config::checkpoint::list default_checkpoints(config::networ
checkpoints.emplace_back("000000000000000002fc0cdadaef1857bbd2936d37ea94f80ba3db4a5e8353e8", 792773);
checkpoints.emplace_back("00000000000000000340a607ca5e9a8b56b620297216edb818eb09e3c6e95609", 792774);

// //2024-May Hardfork - lobachevski - (1715774400)
//2024-May Hardfork - lobachevski - (1715774400)
checkpoints.emplace_back("000000000000000001806bcdde19c47f088a8026e24905ac6f75afe3ef83594c", 845'890);
checkpoints.emplace_back("0000000000000000017012058e7b67032926f1f20f96d1a2cd66abff9aaf8244", 845'891);
checkpoints.emplace_back("0000000000000000016e3353d5da435ef5d374abe90d9bb430c0408e423632d5", 845'892);

// //2025-May Hardfork - galois - (1747310400)
// checkpoints.emplace_back("", 0);
// checkpoints.emplace_back("", 0);
// checkpoints.emplace_back("", 0);

// //2025-May Hardfork - galois - (1747310400)
// //2026-May Hardfork - leibniz - (1778846400)
// checkpoints.emplace_back("", 0);
// checkpoints.emplace_back("", 0);
// checkpoints.emplace_back("", 0);
Expand Down
34 changes: 25 additions & 9 deletions include/kth/domain/constants/bch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ const infrastructure::config::checkpoint chipnet_bip34_active_checkpoint {
// enum class euler_t : uint64_t {};
// enum class gauss_t : uint64_t {};
// enum class descartes_t : uint64_t {};
enum class lobachevski_t : uint64_t {};
// enum class lobachevski_t : uint64_t {};
enum class galois_t : uint64_t {};
enum class leibniz_t : uint64_t {};
enum class unnamed_t : uint64_t {}; //TODO(fernando): rename it

// constexpr size_t bch_activation_height = 478559 //478558; // 2017-Aug-01 HF
Expand All @@ -100,8 +101,9 @@ enum class unnamed_t : uint64_t {}; //TODO(fernando): rename it
// 2021-May-15 (skipped, not a HF)
// constexpr gauss_t bch_gauss_activation_time{1652616000}; // 2022-May-15 HF
// constexpr descartes_t bch_descartes_activation_time{1684152000}; // 2023-May-15 HF
constexpr lobachevski_t bch_lobachevski_activation_time{1715774400}; // 2024-May-15 HF
constexpr galois_t bch_galois_activation_time{1747310400}; // 2025-May-15 HF
// constexpr lobachevski_t bch_lobachevski_activation_time{1715774400}; // 2024-May-15 HF
constexpr galois_t bch_galois_activation_time{1747310400}; // 2025-May-15 HF
constexpr leibniz_t bch_leibniz_activation_time{1778846400}; // 2026-May-15 HF


// Block height at which CSV (BIP68, BIP112 and BIP113) becomes active
Expand Down Expand Up @@ -212,12 +214,26 @@ constexpr size_t testnet4_descartes_activation_height = 95'465; //FIXME(fern
constexpr size_t scalenet_descartes_activation_height = 10'007; //FIXME(fernando): check this
constexpr size_t chipnet_descartes_activation_height = 95'465; //FIXME(fernando): check this

// //2024-May hard fork
// constexpr size_t mainnet_lobachevski_activation_height = ???;
// constexpr size_t testnet_lobachevski_activation_height = ???;
// constexpr size_t testnet4_lobachevski_activation_height = ???;
// constexpr size_t scalenet_lobachevski_activation_height = ???;
// constexpr size_t chipnet_lobachevski_activation_height = ???;
//2024-May hard fork
constexpr size_t mainnet_lobachevski_activation_height = 845'891;
constexpr size_t testnet_lobachevski_activation_height = 1'500'206; //FIXME(fernando): check this
constexpr size_t testnet4_lobachevski_activation_height = 95'465; //FIXME(fernando): check this
constexpr size_t scalenet_lobachevski_activation_height = 10'007; //FIXME(fernando): check this
constexpr size_t chipnet_lobachevski_activation_height = 95'465; //FIXME(fernando): check this

// //2025-May hard fork
// constexpr size_t mainnet_galois_activation_height = ???;
// constexpr size_t testnet_galois_activation_height = ???;
// constexpr size_t testnet4_galois_activation_height = ???;
// constexpr size_t scalenet_galois_activation_height = ???;
// constexpr size_t chipnet_galois_activation_height = ???;

// //2026-May hard fork
// constexpr size_t mainnet_leibniz_activation_height = ???;
// constexpr size_t testnet_leibniz_activation_height = ???;
// constexpr size_t testnet4_leibniz_activation_height = ???;
// constexpr size_t scalenet_leibniz_activation_height = ???;
// constexpr size_t chipnet_leibniz_activation_height = ???;

} // namespace kth

Expand Down
3 changes: 2 additions & 1 deletion include/kth/domain/machine/rule_fork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ enum rule_fork : uint32_t {
bch_descartes = 1U << 20, //2023-May Hardfork - descartes - (1684152000)
bch_lobachevski = 1U << 21, //2024-May Hardfork - lobachevski - (1715774400)
bch_galois = 1U << 22, //2025-May Hardfork - galois - (1747310400)
// bch_unnamed = 1U << 23, //2026-May Hardfork - unnamed - (9999999999)
bch_leibniz = 1U << 23, //2025-May Hardfork - leibniz - (1778846400)
// bch_unnamed = 1U << 24, //2026-May Hardfork - unnamed - (9999999999)
#else
// Just for segwit coins
/// Segregated witness consensus layer (soft fork, feature).
Expand Down
Loading
Loading