diff --git a/rai/blockstore.cpp b/rai/blockstore.cpp index d06f9ea2..8a59b192 100644 --- a/rai/blockstore.cpp +++ b/rai/blockstore.cpp @@ -42,7 +42,7 @@ public: { fill_value (block_a); } - void utx_block (rai::utx_block const & block_a) override + void state_block (rai::state_block const & block_a) override { if (!block_a.previous ().is_zero ()) { @@ -263,7 +263,7 @@ checksum (0) error_a |= mdb_dbi_open (transaction, "receive", MDB_CREATE, &receive_blocks) != 0; error_a |= mdb_dbi_open (transaction, "open", MDB_CREATE, &open_blocks) != 0; error_a |= mdb_dbi_open (transaction, "change", MDB_CREATE, &change_blocks) != 0; - error_a |= mdb_dbi_open (transaction, "utx", MDB_CREATE, &utx_blocks) != 0; + error_a |= mdb_dbi_open (transaction, "state", MDB_CREATE, &state_blocks) != 0; error_a |= mdb_dbi_open (transaction, "pending", MDB_CREATE, &pending) != 0; error_a |= mdb_dbi_open (transaction, "blocks_info", MDB_CREATE, &blocks_info) != 0; error_a |= mdb_dbi_open (transaction, "representation", MDB_CREATE, &representation) != 0; @@ -566,8 +566,8 @@ MDB_dbi rai::block_store::block_database (rai::block_type type_a) case rai::block_type::change: result = change_blocks; break; - case rai::block_type::utx: - result = utx_blocks; + case rai::block_type::state: + result = state_blocks; break; default: assert (false); @@ -616,7 +616,7 @@ MDB_val rai::block_store::block_get_raw (MDB_txn * transaction_a, rai::block_has assert (status == 0 || status == MDB_NOTFOUND); if (status != 0) { - auto status (mdb_get (transaction_a, utx_blocks, rai::mdb_val (hash_a), result)); + auto status (mdb_get (transaction_a, state_blocks, rai::mdb_val (hash_a), result)); assert (status == 0 || status == MDB_NOTFOUND); if (status != 0) { @@ -624,7 +624,7 @@ MDB_val rai::block_store::block_get_raw (MDB_txn * transaction_a, rai::block_has } else { - type_a = rai::block_type::utx; + type_a = rai::block_type::state; } } else @@ -694,7 +694,7 @@ std::unique_ptr rai::block_store::block_random (MDB_txn * transactio } else { - result = block_random (transaction_a, utx_blocks); + result = block_random (transaction_a, state_blocks); } } } @@ -743,7 +743,7 @@ std::unique_ptr rai::block_store::block_get (MDB_txn * transaction_a void rai::block_store::block_del (MDB_txn * transaction_a, rai::block_hash const & hash_a) { - auto status (mdb_del (transaction_a, utx_blocks, rai::mdb_val (hash_a), nullptr)); + auto status (mdb_del (transaction_a, state_blocks, rai::mdb_val (hash_a), nullptr)); assert (status == 0 || status == MDB_NOTFOUND); if (status != 0) { @@ -791,7 +791,7 @@ bool rai::block_store::block_exists (MDB_txn * transaction_a, rai::block_hash co exists = status == 0; if (!exists) { - auto status (mdb_get (transaction_a, utx_blocks, rai::mdb_val (hash_a), junk)); + auto status (mdb_get (transaction_a, state_blocks, rai::mdb_val (hash_a), junk)); assert (status == 0 || status == MDB_NOTFOUND); exists = status == 0; } @@ -816,14 +816,14 @@ rai::block_counts rai::block_store::block_count (MDB_txn * transaction_a) MDB_stat change_stats; auto status4 (mdb_stat (transaction_a, change_blocks, &change_stats)); assert (status4 == 0); - MDB_stat utx_stats; - auto status5 (mdb_stat (transaction_a, utx_blocks, &utx_stats)); + MDB_stat state_stats; + auto status5 (mdb_stat (transaction_a, state_blocks, &state_stats)); assert (status5 == 0); result.send = send_stats.ms_entries; result.receive = receive_stats.ms_entries; result.open = open_stats.ms_entries; result.change = change_stats.ms_entries; - result.utx = utx_stats.ms_entries; + result.state = state_stats.ms_entries; return result; } diff --git a/rai/blockstore.hpp b/rai/blockstore.hpp index a93015ff..4a72fe19 100644 --- a/rai/blockstore.hpp +++ b/rai/blockstore.hpp @@ -161,8 +161,8 @@ public: MDB_dbi open_blocks; // block_hash -> change_block MDB_dbi change_blocks; - // block_hash -> utx_block - MDB_dbi utx_blocks; + // block_hash -> state_block + MDB_dbi state_blocks; // block_hash -> sender, amount, destination // Pending blocks to sender account, amount, destination account MDB_dbi pending; // block_hash -> account, balance // Blocks info diff --git a/rai/common.cpp b/rai/common.cpp index a6d32f83..52644118 100644 --- a/rai/common.cpp +++ b/rai/common.cpp @@ -89,7 +89,7 @@ size_t constexpr rai::send_block::size; size_t constexpr rai::receive_block::size; size_t constexpr rai::open_block::size; size_t constexpr rai::change_block::size; -size_t constexpr rai::utx_block::size; +size_t constexpr rai::state_block::size; rai::keypair const & rai::zero_key (globals.zero_key); rai::keypair const & rai::test_genesis_key (globals.test_genesis_key); @@ -256,7 +256,7 @@ change (0) size_t rai::block_counts::sum () { - return send + receive + open + change + utx; + return send + receive + open + change + state; } rai::pending_info::pending_info () : @@ -440,7 +440,7 @@ void rai::amount_visitor::open_block (rai::open_block const & block_a) } } -void rai::amount_visitor::utx_block (rai::utx_block const & block_a) +void rai::amount_visitor::state_block (rai::state_block const & block_a) { balance_visitor prev (transaction, store); prev.compute (block_a.hashables.previous); @@ -534,7 +534,7 @@ void rai::balance_visitor::change_block (rai::change_block const & block_a) } } -void rai::balance_visitor::utx_block (rai::utx_block const & block_a) +void rai::balance_visitor::state_block (rai::state_block const & block_a) { result = block_a.hashables.balance.number (); current = 0; @@ -589,7 +589,7 @@ void rai::representative_visitor::change_block (rai::change_block const & block_ result = block_a.hash (); } -void rai::representative_visitor::utx_block (rai::utx_block const & block_a) +void rai::representative_visitor::state_block (rai::state_block const & block_a) { result = block_a.hash (); } diff --git a/rai/common.hpp b/rai/common.hpp index b8e545a8..2d6efc84 100644 --- a/rai/common.hpp +++ b/rai/common.hpp @@ -37,7 +37,7 @@ public: void receive_block (rai::receive_block const &) override; void open_block (rai::open_block const &) override; void change_block (rai::change_block const &) override; - void utx_block (rai::utx_block const &) override; + void state_block (rai::state_block const &) override; MDB_txn * transaction; rai::block_store & store; rai::block_hash current; @@ -57,7 +57,7 @@ public: void receive_block (rai::receive_block const &) override; void open_block (rai::open_block const &) override; void change_block (rai::change_block const &) override; - void utx_block (rai::utx_block const &) override; + void state_block (rai::state_block const &) override; void from_send (rai::block_hash const &); MDB_txn * transaction; rai::block_store & store; @@ -77,7 +77,7 @@ public: void receive_block (rai::receive_block const & block_a) override; void open_block (rai::open_block const & block_a) override; void change_block (rai::change_block const & block_a) override; - void utx_block (rai::utx_block const & block_a) override; + void state_block (rai::state_block const & block_a) override; MDB_txn * transaction; rai::block_store & store; rai::block_hash current; @@ -173,7 +173,7 @@ public: size_t receive; size_t open; size_t change; - size_t utx; + size_t state; }; class vote { @@ -221,7 +221,7 @@ enum class process_result unreceivable, // Source block doesn't exist or has already been received gap_previous, // Block marked as previous is unknown gap_source, // Block marked as source is unknown - utx_disabled, // Awaiting UTX canary block + state_block_disabled, // Awaiting state block canary block not_receive_from_send, // Receive does not have a send source account_mismatch, // Account number in open block doesn't match send destination opened_burn_account, // The impossible happened, someone found the private key associated with the public key '0'. @@ -235,7 +235,7 @@ public: rai::account account; rai::amount amount; rai::account pending_account; - boost::optional utx_is_send; + boost::optional state_is_send; }; enum class tally_result { diff --git a/rai/core_test/block.cpp b/rai/core_test/block.cpp index 35e73863..89862ad8 100644 --- a/rai/core_test/block.cpp +++ b/rai/core_test/block.cpp @@ -326,11 +326,11 @@ TEST (block, confirm_req_serialization) ASSERT_EQ (*req.block, *req2.block); } -TEST (utx, serialization) +TEST (state_block, serialization) { rai::keypair key1; rai::keypair key2; - rai::utx_block block1 (key1.pub, 1, key2.pub, 2, 4, key1.prv, key1.pub, 5); + rai::state_block block1 (key1.pub, 1, key2.pub, 2, 4, key1.prv, key1.pub, 5); ASSERT_EQ (key1.pub, block1.hashables.account); ASSERT_EQ (rai::block_hash (1), block1.previous ()); ASSERT_EQ (key2.pub, block1.hashables.representative); @@ -341,10 +341,10 @@ TEST (utx, serialization) rai::vectorstream stream (bytes); block1.serialize (stream); } - ASSERT_EQ (rai::utx_block::size, bytes.size ()); + ASSERT_EQ (rai::state_block::size, bytes.size ()); bool error1; rai::bufferstream stream (bytes.data (), bytes.size ()); - rai::utx_block block2 (error1, stream); + rai::state_block block2 (error1, stream); ASSERT_FALSE (error1); ASSERT_EQ (block1, block2); block2.hashables.account.clear (); @@ -363,7 +363,7 @@ TEST (utx, serialization) boost::property_tree::ptree tree; boost::property_tree::read_json (body, tree); bool error2; - rai::utx_block block3 (error2, tree); + rai::state_block block3 (error2, tree); ASSERT_FALSE (error2); ASSERT_EQ (block1, block3); block3.hashables.account.clear (); @@ -377,10 +377,10 @@ TEST (utx, serialization) ASSERT_EQ (block1, block3); } -TEST (utx, hashing) +TEST (state_block, hashing) { rai::keypair key; - rai::utx_block block (key.pub, 0, key.pub, 0, 0, key.prv, key.pub, 0); + rai::state_block block (key.pub, 0, key.pub, 0, 0, key.prv, key.pub, 0); auto hash (block.hash ()); block.hashables.account.bytes[0] ^= 0x1; ASSERT_NE (hash, block.hash ()); diff --git a/rai/core_test/block_store.cpp b/rai/core_test/block_store.cpp index b75e4ba0..2203d41d 100644 --- a/rai/core_test/block_store.cpp +++ b/rai/core_test/block_store.cpp @@ -964,7 +964,7 @@ TEST (block_store, upgrade_v9_v10) ASSERT_EQ (block_info.balance.number (), rai::genesis_amount - rai::Gxrb_ratio * 31); } -TEST (block_store, utx_block) +TEST (block_store, state_block) { bool error (false); rai::block_store store (error, rai::unique_path ()); @@ -973,17 +973,17 @@ TEST (block_store, utx_block) rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair key1; - rai::utx_block block1 (1, genesis.hash (), 3, 4, 6, key1.prv, key1.pub, 7); - ASSERT_EQ (rai::block_type::utx, block1.type ()); + rai::state_block block1 (1, genesis.hash (), 3, 4, 6, key1.prv, key1.pub, 7); + ASSERT_EQ (rai::block_type::state, block1.type ()); store.block_put (transaction, block1.hash (), block1); ASSERT_TRUE (store.block_exists (transaction, block1.hash ())); auto block2 (store.block_get (transaction, block1.hash ())); ASSERT_NE (nullptr, block2); ASSERT_EQ (block1, *block2); auto count (store.block_count (transaction)); - ASSERT_EQ (1, count.utx); + ASSERT_EQ (1, count.state); store.block_del (transaction, block1.hash ()); ASSERT_FALSE (store.block_exists (transaction, block1.hash ())); auto count2 (store.block_count (transaction)); - ASSERT_EQ (0, count2.utx); + ASSERT_EQ (0, count2.state); } diff --git a/rai/core_test/ledger.cpp b/rai/core_test/ledger.cpp index 4cc22c93..2a8f069c 100644 --- a/rai/core_test/ledger.cpp +++ b/rai/core_test/ledger.cpp @@ -1589,7 +1589,7 @@ TEST (ledger, block_destination_source) ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair dest; @@ -1601,11 +1601,11 @@ TEST (ledger, block_destination_source) balance += rai::Gxrb_ratio; rai::receive_block block3 (block2.hash (), block2.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); balance -= rai::Gxrb_ratio; - rai::utx_block block4 (rai::genesis_account, block3.hash (), rai::genesis_account, balance, dest.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block block4 (rai::genesis_account, block3.hash (), rai::genesis_account, balance, dest.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); balance -= rai::Gxrb_ratio; - rai::utx_block block5 (rai::genesis_account, block4.hash (), rai::genesis_account, balance, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block block5 (rai::genesis_account, block4.hash (), rai::genesis_account, balance, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); balance += rai::Gxrb_ratio; - rai::utx_block block6 (rai::genesis_account, block5.hash (), rai::genesis_account, balance, block5.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block block6 (rai::genesis_account, block5.hash (), rai::genesis_account, balance, block5.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, block1).code); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, block2).code); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, block3).code); @@ -1627,32 +1627,32 @@ TEST (ledger, block_destination_source) ASSERT_EQ (block5.hash (), ledger.block_source (transaction, block6)); } -TEST (ledger, utx_account) +TEST (ledger, state_account) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); ASSERT_EQ (rai::genesis_account, ledger.account (transaction, send1.hash ())); } -TEST (ledger, utx_send_receive) +TEST (ledger, state_send_receive) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store.block_exists (transaction, send1.hash ())); auto send2 (store.block_get (transaction, send1.hash ())); @@ -1662,7 +1662,7 @@ TEST (ledger, utx_send_receive) ASSERT_EQ (rai::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.weight (transaction, rai::genesis_account)); ASSERT_TRUE (store.pending_exists (transaction, rai::pending_key (rai::genesis_account, send1.hash ()))); - rai::utx_block receive1 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block receive1 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_TRUE (store.block_exists (transaction, receive1.hash ())); auto receive2 (store.block_get (transaction, receive1.hash ())); @@ -1674,14 +1674,14 @@ TEST (ledger, utx_send_receive) ASSERT_FALSE (store.pending_exists (transaction, rai::pending_key (rai::genesis_account, send1.hash ()))); } -TEST (ledger, utx_receive) +TEST (ledger, state_receive) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::send_block send1 (genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); @@ -1693,7 +1693,7 @@ TEST (ledger, utx_receive) ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (rai::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.weight (transaction, rai::genesis_account)); - rai::utx_block receive1 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block receive1 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_TRUE (store.block_exists (transaction, receive1.hash ())); auto receive2 (store.block_get (transaction, receive1.hash ())); @@ -1704,18 +1704,18 @@ TEST (ledger, utx_receive) ASSERT_EQ (rai::genesis_amount, ledger.weight (transaction, rai::genesis_account)); } -TEST (ledger, utx_rep_change) +TEST (ledger, state_rep_change) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair rep; - rai::utx_block change1 (rai::genesis_account, genesis.hash (), rep.pub, rai::genesis_amount, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block change1 (rai::genesis_account, genesis.hash (), rep.pub, rai::genesis_amount, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, change1).code); ASSERT_TRUE (store.block_exists (transaction, change1.hash ())); auto change2 (store.block_get (transaction, change1.hash ())); @@ -1727,18 +1727,18 @@ TEST (ledger, utx_rep_change) ASSERT_EQ (rai::genesis_amount, ledger.weight (transaction, rep.pub)); } -TEST (ledger, utx_open) +TEST (ledger, state_open) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair destination; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store.block_exists (transaction, send1.hash ())); auto send2 (store.block_get (transaction, send1.hash ())); @@ -1748,7 +1748,7 @@ TEST (ledger, utx_open) ASSERT_EQ (rai::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.weight (transaction, rai::genesis_account)); ASSERT_TRUE (store.pending_exists (transaction, rai::pending_key (destination.pub, send1.hash ()))); - rai::utx_block open1 (destination.pub, 0, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, 0); + rai::state_block open1 (destination.pub, 0, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, open1).code); ASSERT_FALSE (store.pending_exists (transaction, rai::pending_key (destination.pub, send1.hash ()))); ASSERT_TRUE (store.block_exists (transaction, open1.hash ())); @@ -1760,66 +1760,66 @@ TEST (ledger, utx_open) ASSERT_EQ (rai::genesis_amount, ledger.weight (transaction, rai::genesis_account)); } -// Make sure old block types can't be inserted after a utx block. -TEST (ledger, send_after_utx_fail) +// Make sure old block types can't be inserted after a state block. +TEST (ledger, send_after_state_fail) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); rai::send_block send2 (send1.hash (), rai::genesis_account, rai::genesis_amount - (2 * rai::Gxrb_ratio), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::block_position, ledger.process (transaction, send2).code); } -// Make sure old block types can't be inserted after a utx block. -TEST (ledger, receive_after_utx_fail) +// Make sure old block types can't be inserted after a state block. +TEST (ledger, receive_after_state_fail) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); rai::receive_block receive1 (send1.hash (), send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::block_position, ledger.process (transaction, receive1).code); } -// Make sure old block types can't be inserted after a utx block. -TEST (ledger, change_after_utx_fail) +// Make sure old block types can't be inserted after a state block. +TEST (ledger, change_after_state_fail) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); rai::keypair rep; rai::change_block change1 (send1.hash (), rep.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::block_position, ledger.process (transaction, change1).code); } -TEST (ledger, utx_unreceivable_fail) +TEST (ledger, state_unreceivable_fail) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::send_block send1 (genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); @@ -1831,18 +1831,18 @@ TEST (ledger, utx_unreceivable_fail) ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (rai::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.weight (transaction, rai::genesis_account)); - rai::utx_block receive1 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount, 1, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block receive1 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount, 1, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::gap_source, ledger.process (transaction, receive1).code); } -TEST (ledger, utx_receive_bad_amount_fail) +TEST (ledger, state_receive_bad_amount_fail) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::send_block send1 (genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); @@ -1854,38 +1854,38 @@ TEST (ledger, utx_receive_bad_amount_fail) ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (rai::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.weight (transaction, rai::genesis_account)); - rai::utx_block receive1 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block receive1 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::balance_mismatch, ledger.process (transaction, receive1).code); } -TEST (ledger, utx_no_link_amount_fail) +TEST (ledger, state_no_link_amount_fail) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); rai::keypair rep; - rai::utx_block change1 (rai::genesis_account, send1.hash (), rep.pub, rai::genesis_amount, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block change1 (rai::genesis_account, send1.hash (), rep.pub, rai::genesis_amount, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::balance_mismatch, ledger.process (transaction, change1).code); } -TEST (ledger, utx_receive_wrong_account_fail) +TEST (ledger, state_receive_wrong_account_fail) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store.block_exists (transaction, send1.hash ())); auto send2 (store.block_get (transaction, send1.hash ())); @@ -1895,96 +1895,96 @@ TEST (ledger, utx_receive_wrong_account_fail) ASSERT_EQ (rai::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.weight (transaction, rai::genesis_account)); rai::keypair key; - rai::utx_block receive1 (key.pub, 0, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), key.prv, key.pub, 0); + rai::state_block receive1 (key.pub, 0, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), key.prv, key.pub, 0); ASSERT_EQ (rai::process_result::unreceivable, ledger.process (transaction, receive1).code); } -TEST (ledger, utx_open_utx_fork) +TEST (ledger, state_open_state_fork) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair destination; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); - rai::utx_block open1 (destination.pub, 0, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, 0); + rai::state_block open1 (destination.pub, 0, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, open1).code); rai::open_block open2 (send1.hash (), rai::genesis_account, destination.pub, destination.prv, destination.pub, 0); ASSERT_EQ (rai::process_result::fork, ledger.process (transaction, open2).code); ASSERT_EQ (open1.root (), open2.root ()); } -TEST (ledger, utx_utx_open_fork) +TEST (ledger, state_state_open_fork) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair destination; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); rai::open_block open1 (send1.hash (), rai::genesis_account, destination.pub, destination.prv, destination.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, open1).code); - rai::utx_block open2 (destination.pub, 0, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, 0); + rai::state_block open2 (destination.pub, 0, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, 0); ASSERT_EQ (rai::process_result::fork, ledger.process (transaction, open2).code); ASSERT_EQ (open1.root (), open2.root ()); } -TEST (ledger, utx_open_previous_fail) +TEST (ledger, state_open_previous_fail) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair destination; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); - rai::utx_block open1 (destination.pub, destination.pub, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, 0); + rai::state_block open1 (destination.pub, destination.pub, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, 0); ASSERT_EQ (rai::process_result::gap_previous, ledger.process (transaction, open1).code); } -TEST (ledger, utx_open_source_fail) +TEST (ledger, state_open_source_fail) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair destination; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); - rai::utx_block open1 (destination.pub, 0, rai::genesis_account, 0, 0, destination.prv, destination.pub, 0); + rai::state_block open1 (destination.pub, 0, rai::genesis_account, 0, 0, destination.prv, destination.pub, 0); ASSERT_EQ (rai::process_result::gap_source, ledger.process (transaction, open1).code); } -TEST (ledger, utx_send_change) +TEST (ledger, state_send_change) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair rep; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rep.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rep.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store.block_exists (transaction, send1.hash ())); auto send2 (store.block_get (transaction, send1.hash ())); @@ -1996,17 +1996,17 @@ TEST (ledger, utx_send_change) ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.weight (transaction, rep.pub)); } -TEST (ledger, utx_receive_change) +TEST (ledger, state_receive_change) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store.block_exists (transaction, send1.hash ())); auto send2 (store.block_get (transaction, send1.hash ())); @@ -2016,7 +2016,7 @@ TEST (ledger, utx_receive_change) ASSERT_EQ (rai::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.weight (transaction, rai::genesis_account)); rai::keypair rep; - rai::utx_block receive1 (rai::genesis_account, send1.hash (), rep.pub, rai::genesis_amount, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block receive1 (rai::genesis_account, send1.hash (), rep.pub, rai::genesis_amount, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_TRUE (store.block_exists (transaction, receive1.hash ())); auto receive2 (store.block_get (transaction, receive1.hash ())); @@ -2028,18 +2028,18 @@ TEST (ledger, utx_receive_change) ASSERT_EQ (rai::genesis_amount, ledger.weight (transaction, rep.pub)); } -TEST (ledger, utx_open_old) +TEST (ledger, state_open_old) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair destination; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); rai::open_block open1 (send1.hash (), rai::genesis_account, destination.pub, destination.prv, destination.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, open1).code); @@ -2048,20 +2048,20 @@ TEST (ledger, utx_open_old) ASSERT_EQ (rai::genesis_amount, ledger.weight (transaction, rai::genesis_account)); } -TEST (ledger, utx_receive_old) +TEST (ledger, state_receive_old) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair destination; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); - rai::utx_block send2 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount - (2 * rai::Gxrb_ratio), destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send2 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount - (2 * rai::Gxrb_ratio), destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send2).code); rai::open_block open1 (send1.hash (), rai::genesis_account, destination.pub, destination.prv, destination.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, open1).code); @@ -2072,17 +2072,17 @@ TEST (ledger, utx_receive_old) ASSERT_EQ (rai::genesis_amount, ledger.weight (transaction, rai::genesis_account)); } -TEST (ledger, utx_rollback_send) +TEST (ledger, state_rollback_send) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store.block_exists (transaction, send1.hash ())); auto send2 (store.block_get (transaction, send1.hash ())); @@ -2102,19 +2102,19 @@ TEST (ledger, utx_rollback_send) ASSERT_TRUE (store.block_successor (transaction, genesis.hash ()).is_zero ()); } -TEST (ledger, utx_rollback_receive) +TEST (ledger, state_rollback_receive) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); - rai::utx_block receive1 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block receive1 (rai::genesis_account, send1.hash (), rai::genesis_account, rai::genesis_amount, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_FALSE (store.pending_exists (transaction, rai::pending_key (rai::genesis_account, receive1.hash ()))); ledger.rollback (transaction, receive1.hash ()); @@ -2127,20 +2127,20 @@ TEST (ledger, utx_rollback_receive) ASSERT_EQ (rai::genesis_amount - rai::Gxrb_ratio, ledger.weight (transaction, rai::genesis_account)); } -TEST (ledger, utx_rollback_received_send) +TEST (ledger, state_rollback_received_send) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair key; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); - rai::utx_block receive1 (key.pub, 0, key.pub, rai::Gxrb_ratio, send1.hash (), key.prv, key.pub, 0); + rai::state_block receive1 (key.pub, 0, key.pub, rai::Gxrb_ratio, send1.hash (), key.prv, key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_FALSE (store.pending_exists (transaction, rai::pending_key (rai::genesis_account, receive1.hash ()))); ledger.rollback (transaction, send1.hash ()); @@ -2153,18 +2153,18 @@ TEST (ledger, utx_rollback_received_send) ASSERT_EQ (0, ledger.weight (transaction, key.pub)); } -TEST (ledger, utx_rep_change_rollback) +TEST (ledger, state_rep_change_rollback) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair rep; - rai::utx_block change1 (rai::genesis_account, genesis.hash (), rep.pub, rai::genesis_amount, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block change1 (rai::genesis_account, genesis.hash (), rep.pub, rai::genesis_amount, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, change1).code); ledger.rollback (transaction, change1.hash ()); ASSERT_FALSE (store.block_exists (transaction, change1.hash ())); @@ -2173,20 +2173,20 @@ TEST (ledger, utx_rep_change_rollback) ASSERT_EQ (0, ledger.weight (transaction, rep.pub)); } -TEST (ledger, utx_open_rollback) +TEST (ledger, state_open_rollback) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair destination; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, destination.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); - rai::utx_block open1 (destination.pub, 0, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, 0); + rai::state_block open1 (destination.pub, 0, rai::genesis_account, rai::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, open1).code); ledger.rollback (transaction, open1.hash ()); ASSERT_FALSE (store.block_exists (transaction, open1.hash ())); @@ -2198,18 +2198,18 @@ TEST (ledger, utx_open_rollback) ASSERT_EQ (rai::Gxrb_ratio, info.amount.number ()); } -TEST (ledger, utx_send_change_rollback) +TEST (ledger, state_send_change_rollback) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); rai::keypair rep; - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rep.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rep.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); ledger.rollback (transaction, send1.hash ()); ASSERT_FALSE (store.block_exists (transaction, send1.hash ())); @@ -2218,20 +2218,20 @@ TEST (ledger, utx_send_change_rollback) ASSERT_EQ (0, ledger.weight (transaction, rep.pub)); } -TEST (ledger, utx_receive_change_rollback) +TEST (ledger, state_receive_change_rollback) { bool init (false); rai::block_store store (init, rai::unique_path ()); ASSERT_TRUE (!init); rai::ledger ledger (store); rai::genesis genesis; - ledger.utx_parse_canary = genesis.hash (); + ledger.state_block_parse_canary = genesis.hash (); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block send1 (rai::genesis_account, genesis.hash (), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, send1).code); rai::keypair rep; - rai::utx_block receive1 (rai::genesis_account, send1.hash (), rep.pub, rai::genesis_amount, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block receive1 (rai::genesis_account, send1.hash (), rep.pub, rai::genesis_amount, send1.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, receive1).code); ledger.rollback (transaction, receive1.hash ()); ASSERT_FALSE (store.block_exists (transaction, receive1.hash ())); @@ -2240,7 +2240,7 @@ TEST (ledger, utx_receive_change_rollback) ASSERT_EQ (0, ledger.weight (transaction, rep.pub)); } -TEST (ledger, utx_canary_blocks) +TEST (ledger, state_canary_blocks) { bool init (false); rai::block_store store (init, rai::unique_path ()); @@ -2251,14 +2251,14 @@ TEST (ledger, utx_canary_blocks) rai::ledger ledger (store, 0, parse_canary.hash (), generate_canary.hash ()); rai::transaction transaction (store.environment, nullptr, true); genesis.initialize (transaction, store); - rai::utx_block utx (rai::test_genesis_key.pub, genesis.hash (), rai::test_genesis_key.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); - ASSERT_FALSE (ledger.utx_parsing_enabled (transaction)); - ASSERT_FALSE (ledger.utx_generation_enabled (transaction)); - ASSERT_EQ (rai::process_result::utx_disabled, ledger.process (transaction, utx).code); + rai::state_block state (rai::test_genesis_key.pub, genesis.hash (), rai::test_genesis_key.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + ASSERT_FALSE (ledger.state_block_parsing_enabled (transaction)); + ASSERT_FALSE (ledger.state_block_generation_enabled (transaction)); + ASSERT_EQ (rai::process_result::state_block_disabled, ledger.process (transaction, state).code); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, parse_canary).code); - ASSERT_TRUE (ledger.utx_parsing_enabled (transaction)); - ASSERT_FALSE (ledger.utx_generation_enabled (transaction)); + ASSERT_TRUE (ledger.state_block_parsing_enabled (transaction)); + ASSERT_FALSE (ledger.state_block_generation_enabled (transaction)); ASSERT_EQ (rai::process_result::progress, ledger.process (transaction, generate_canary).code); - ASSERT_TRUE (ledger.utx_parsing_enabled (transaction)); - ASSERT_TRUE (ledger.utx_generation_enabled (transaction)); + ASSERT_TRUE (ledger.state_block_parsing_enabled (transaction)); + ASSERT_TRUE (ledger.state_block_generation_enabled (transaction)); } diff --git a/rai/core_test/network.cpp b/rai/core_test/network.cpp index 480e902c..37d113c9 100644 --- a/rai/core_test/network.cpp +++ b/rai/core_test/network.cpp @@ -551,22 +551,22 @@ TEST (bootstrap_processor, process_two) } // Bootstrap can pull universal blocks -TEST (bootstrap_processor, process_utx) +TEST (bootstrap_processor, process_state) { rai::system system (24000, 1); rai::genesis genesis; system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv); auto node0 (system.nodes[0]); - node0->ledger.utx_parse_canary = genesis.hash (); - std::unique_ptr block1 (new rai::utx_block (rai::test_genesis_key.pub, node0->latest (rai::test_genesis_key.pub), rai::test_genesis_key.pub, rai::genesis_amount - 100, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0)); - std::unique_ptr block2 (new rai::utx_block (rai::test_genesis_key.pub, block1->hash (), rai::test_genesis_key.pub, rai::genesis_amount, block1->hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0)); + node0->ledger.state_block_parse_canary = genesis.hash (); + std::unique_ptr block1 (new rai::state_block (rai::test_genesis_key.pub, node0->latest (rai::test_genesis_key.pub), rai::test_genesis_key.pub, rai::genesis_amount - 100, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0)); + std::unique_ptr block2 (new rai::state_block (rai::test_genesis_key.pub, block1->hash (), rai::test_genesis_key.pub, rai::genesis_amount, block1->hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0)); node0->generate_work (*block1); node0->generate_work (*block2); node0->process (*block1); node0->process (*block2); rai::node_init init1; auto node1 (std::make_shared (init1, system.service, 24001, rai::unique_path (), system.alarm, system.logging, system.work)); - node1->ledger.utx_parse_canary = genesis.hash (); + node1->ledger.state_block_parse_canary = genesis.hash (); ASSERT_EQ (node0->latest (rai::test_genesis_key.pub), block2->hash ()); ASSERT_NE (node1->latest (rai::test_genesis_key.pub), block2->hash ()); node1->bootstrap_initiator.bootstrap (node0->network.endpoint ()); diff --git a/rai/core_test/node.cpp b/rai/core_test/node.cpp index 508f72cf..5ad541bc 100644 --- a/rai/core_test/node.cpp +++ b/rai/core_test/node.cpp @@ -42,7 +42,7 @@ TEST (node, inactive_supply) node->stop (); } -TEST (node, utx_canaries) +TEST (node, state_canaries) { rai::node_init init; auto service (boost::make_shared ()); @@ -51,11 +51,11 @@ TEST (node, utx_canaries) rai::node_config config; config.logging.init (path); rai::work_pool work (std::numeric_limits::max (), nullptr); - config.utx_parse_canary = 10; - config.utx_generate_canary = 20; + config.state_block_parse_canary = 10; + config.state_block_generate_canary = 20; auto node (std::make_shared (init, *service, path, alarm, config, work)); - ASSERT_EQ (rai::block_hash (10), node->ledger.utx_parse_canary); - ASSERT_EQ (rai::block_hash (20), node->ledger.utx_generate_canary); + ASSERT_EQ (rai::block_hash (10), node->ledger.state_block_parse_canary); + ASSERT_EQ (rai::block_hash (20), node->ledger.state_block_generate_canary); node->stop (); } @@ -512,8 +512,8 @@ TEST (node_config, serialization) config1.callback_port = 10; config1.callback_target = "test"; config1.lmdb_max_dbs = 256; - config1.utx_parse_canary = 10; - config1.utx_generate_canary = 10; + config1.state_block_parse_canary = 10; + config1.state_block_generate_canary = 10; boost::property_tree::ptree tree; config1.serialize_json (tree); rai::logging logging2; @@ -530,8 +530,8 @@ TEST (node_config, serialization) ASSERT_NE (config2.callback_port, config1.callback_port); ASSERT_NE (config2.callback_target, config1.callback_target); ASSERT_NE (config2.lmdb_max_dbs, config1.lmdb_max_dbs); - ASSERT_NE (config2.utx_parse_canary, config1.utx_parse_canary); - ASSERT_NE (config2.utx_generate_canary, config1.utx_generate_canary); + ASSERT_NE (config2.state_block_parse_canary, config1.state_block_parse_canary); + ASSERT_NE (config2.state_block_generate_canary, config1.state_block_generate_canary); bool upgraded (false); config2.deserialize_json (upgraded, tree); @@ -546,8 +546,8 @@ TEST (node_config, serialization) ASSERT_EQ (config2.callback_port, config1.callback_port); ASSERT_EQ (config2.callback_target, config1.callback_target); ASSERT_EQ (config2.lmdb_max_dbs, config1.lmdb_max_dbs); - ASSERT_EQ (config2.utx_parse_canary, config1.utx_parse_canary); - ASSERT_EQ (config2.utx_generate_canary, config1.utx_generate_canary); + ASSERT_EQ (config2.state_block_parse_canary, config1.state_block_parse_canary); + ASSERT_EQ (config2.state_block_generate_canary, config1.state_block_generate_canary); } TEST (node_config, v1_v2_upgrade) diff --git a/rai/core_test/rpc.cpp b/rai/core_test/rpc.cpp index 004cb01f..b1627e32 100644 --- a/rai/core_test/rpc.cpp +++ b/rai/core_test/rpc.cpp @@ -881,10 +881,10 @@ TEST (rpc, history) ASSERT_NE (nullptr, receive); auto node0 (system.nodes[0]); rai::genesis genesis; - node0->ledger.utx_parse_canary = genesis.hash (); - rai::utx_block usend (rai::genesis_account, node0->latest (rai::genesis_account), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); - rai::utx_block ureceive (rai::genesis_account, usend.hash (), rai::genesis_account, rai::genesis_amount, usend.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); - rai::utx_block uchange (rai::genesis_account, ureceive.hash (), rai::keypair ().pub, rai::genesis_amount, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + node0->ledger.state_block_parse_canary = genesis.hash (); + rai::state_block usend (rai::genesis_account, node0->latest (rai::genesis_account), rai::genesis_account, rai::genesis_amount - rai::Gxrb_ratio, rai::genesis_account, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block ureceive (rai::genesis_account, usend.hash (), rai::genesis_account, rai::genesis_amount, usend.hash (), rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + rai::state_block uchange (rai::genesis_account, ureceive.hash (), rai::keypair ().pub, rai::genesis_amount, 0, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); { rai::transaction transaction (node0->store.environment, nullptr, true); ASSERT_EQ (rai::process_result::progress, node0->ledger.process (transaction, usend).code); @@ -2943,8 +2943,8 @@ TEST (rpc, block_count_type) ASSERT_EQ ("1", open_count); std::string change_count (response.json.get ("change")); ASSERT_EQ ("0", change_count); - std::string utx_count (response.json.get ("utx")); - ASSERT_EQ ("0", utx_count); + std::string state_count (response.json.get ("state")); + ASSERT_EQ ("0", state_count); } TEST (rpc, ledger) @@ -3168,16 +3168,16 @@ TEST (rpc, block_create) ASSERT_EQ (receive_hash, latest.to_string ()); } -TEST (rpc, block_create_utx) +TEST (rpc, block_create_state) { rai::system system (24000, 1); rai::keypair key; rai::genesis genesis; - system.nodes[0]->ledger.utx_parse_canary = genesis.hash (); + system.nodes[0]->ledger.state_block_parse_canary = genesis.hash (); system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv); boost::property_tree::ptree request; request.put ("action", "block_create"); - request.put ("type", "utx"); + request.put ("type", "state"); request.put ("wallet", system.nodes[0]->wallets.items.begin ()->first.to_string ()); request.put ("account", rai::test_genesis_key.pub.to_account ()); request.put ("previous", genesis.hash ().to_string ()); @@ -3193,31 +3193,32 @@ TEST (rpc, block_create_utx) system.poll (); } ASSERT_EQ (200, response.status); - std::string utx_hash (response.json.get ("hash")); - auto utx_text (response.json.get ("block")); - std::stringstream block_stream (utx_text); + std::string state_hash (response.json.get ("hash")); + auto state_text (response.json.get ("block")); + std::stringstream block_stream (state_text); boost::property_tree::ptree block_l; boost::property_tree::read_json (block_stream, block_l); - auto utx_block (rai::deserialize_block_json (block_l)); - ASSERT_NE (nullptr, utx_block); - ASSERT_EQ (rai::block_type::utx, utx_block->type ()); - ASSERT_EQ (utx_hash, utx_block->hash ().to_string ()); - auto process_result (system.nodes[0]->process (*utx_block)); + auto state_block (rai::deserialize_block_json (block_l)); + ASSERT_NE (nullptr, state_block); + ASSERT_EQ (rai::block_type::state, state_block->type ()); + ASSERT_EQ (state_hash, state_block->hash ().to_string ()); + auto process_result (system.nodes[0]->process (*state_block)); ASSERT_EQ (rai::process_result::progress, process_result.code); } -TEST (rpc, block_create_utx_open) + +TEST (rpc, block_create_state_open) { rai::system system (24000, 1); rai::keypair key; rai::genesis genesis; - system.nodes[0]->ledger.utx_parse_canary = genesis.hash (); + system.nodes[0]->ledger.state_block_parse_canary = genesis.hash (); system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv); system.wallet (0)->insert_adhoc (key.prv); auto send_block (system.wallet (0)->send_action (rai::test_genesis_key.pub, key.pub, rai::Gxrb_ratio)); ASSERT_NE (nullptr, send_block); boost::property_tree::ptree request; request.put ("action", "block_create"); - request.put ("type", "utx"); + request.put ("type", "state"); request.put ("wallet", system.nodes[0]->wallets.items.begin ()->first.to_string ()); request.put ("account", key.pub.to_account ()); request.put ("previous", 0); @@ -3233,17 +3234,17 @@ TEST (rpc, block_create_utx_open) system.poll (); } ASSERT_EQ (200, response.status); - std::string utx_hash (response.json.get ("hash")); - auto utx_text (response.json.get ("block")); - std::stringstream block_stream (utx_text); + std::string state_hash (response.json.get ("hash")); + auto state_text (response.json.get ("block")); + std::stringstream block_stream (state_text); boost::property_tree::ptree block_l; boost::property_tree::read_json (block_stream, block_l); - auto utx_block (rai::deserialize_block_json (block_l)); - ASSERT_NE (nullptr, utx_block); - ASSERT_EQ (rai::block_type::utx, utx_block->type ()); - ASSERT_EQ (utx_hash, utx_block->hash ().to_string ()); + auto state_block (rai::deserialize_block_json (block_l)); + ASSERT_NE (nullptr, state_block); + ASSERT_EQ (rai::block_type::state, state_block->type ()); + ASSERT_EQ (state_hash, state_block->hash ().to_string ()); ASSERT_TRUE (system.nodes[0]->latest (key.pub).is_zero ()); - auto process_result (system.nodes[0]->process (*utx_block)); + auto process_result (system.nodes[0]->process (*state_block)); ASSERT_EQ (rai::process_result::progress, process_result.code); ASSERT_FALSE (system.nodes[0]->latest (key.pub).is_zero ()); } diff --git a/rai/core_test/wallet.cpp b/rai/core_test/wallet.cpp index 321b5fe8..3a752ea1 100644 --- a/rai/core_test/wallet.cpp +++ b/rai/core_test/wallet.cpp @@ -979,18 +979,18 @@ TEST (wallet, password_race_corrupt_seed) } } -TEST (wallet, utx_implicit_generate) +TEST (wallet, state_implicit_generate) { rai::system system (24000, 1); system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv); rai::genesis genesis; - system.nodes[0]->ledger.utx_parse_canary = genesis.hash (); + system.nodes[0]->ledger.state_block_parse_canary = genesis.hash (); { rai::transaction transaction (system.nodes[0]->store.environment, nullptr, true); - ASSERT_FALSE (system.wallet (0)->should_generate_utx (transaction, genesis.hash ())); - rai::utx_block block (rai::test_genesis_key.pub, genesis.hash (), rai::test_genesis_key.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); + ASSERT_FALSE (system.wallet (0)->should_generate_state_block (transaction, genesis.hash ())); + rai::state_block block (rai::test_genesis_key.pub, genesis.hash (), rai::test_genesis_key.pub, rai::genesis_amount - rai::Gxrb_ratio, rai::test_genesis_key.pub, rai::test_genesis_key.prv, rai::test_genesis_key.pub, 0); ASSERT_EQ (rai::process_result::progress, system.nodes[0]->ledger.process (transaction, block).code); - ASSERT_TRUE (system.wallet (0)->should_generate_utx (transaction, block.hash ())); + ASSERT_TRUE (system.wallet (0)->should_generate_state_block (transaction, block.hash ())); } ASSERT_FALSE (system.wallet (0)->search_pending ()); auto iterations (0); diff --git a/rai/ledger.cpp b/rai/ledger.cpp index 2def6910..bd88cd11 100644 --- a/rai/ledger.cpp +++ b/rai/ledger.cpp @@ -95,7 +95,7 @@ public: ledger.store.block_info_del (transaction, hash); } } - void utx_block (rai::utx_block const & block_a) override + void state_block (rai::state_block const & block_a) override { auto hash (block_a.hash ()); rai::block_hash representative (0); @@ -166,23 +166,23 @@ public: void receive_block (rai::receive_block const &) override; void open_block (rai::open_block const &) override; void change_block (rai::change_block const &) override; - void utx_block (rai::utx_block const &) override; - void utx_block_impl (rai::utx_block const &); + void state_block (rai::state_block const &) override; + void state_block_impl (rai::state_block const &); rai::ledger & ledger; MDB_txn * transaction; rai::process_return result; }; -void ledger_processor::utx_block (rai::utx_block const & block_a) +void ledger_processor::state_block (rai::state_block const & block_a) { - result.code = ledger.utx_parsing_enabled (transaction) ? rai::process_result::progress : rai::process_result::utx_disabled; + result.code = ledger.state_block_parsing_enabled (transaction) ? rai::process_result::progress : rai::process_result::state_block_disabled; if (result.code == rai::process_result::progress) { - utx_block_impl (block_a); + state_block_impl (block_a); } } -void ledger_processor::utx_block_impl (rai::utx_block const & block_a) +void ledger_processor::state_block_impl (rai::state_block const & block_a) { auto hash (block_a.hash ()); auto existing (ledger.store.block_exists (transaction, hash)); @@ -250,7 +250,7 @@ void ledger_processor::utx_block_impl (rai::utx_block const & block_a) } if (result.code == rai::process_result::progress) { - result.utx_is_send = is_send; + result.state_is_send = is_send; ledger.store.block_put (transaction, hash, block_a); if (!info.rep_block.is_zero ()) @@ -277,7 +277,7 @@ void ledger_processor::utx_block_impl (rai::utx_block const & block_a) { ledger.store.frontier_del (transaction, info.head); } - // Frontier table is unnecessary for utx blocks and this also prevents old blocks from being inserted on top of utx blocks + // Frontier table is unnecessary for state blocks and this also prevents old blocks from being inserted on top of state blocks result.account = block_a.hashables.account; } } @@ -495,12 +495,12 @@ bool rai::shared_ptr_block_hash::operator() (std::shared_ptr const & return *lhs == *rhs; } -rai::ledger::ledger (rai::block_store & store_a, rai::uint128_t const & inactive_supply_a, rai::block_hash const & utx_parse_canary_a, rai::block_hash const & utx_generate_canary_a) : +rai::ledger::ledger (rai::block_store & store_a, rai::uint128_t const & inactive_supply_a, rai::block_hash const & state_block_parse_canary_a, rai::block_hash const & state_block_generate_canary_a) : store (store_a), inactive_supply (inactive_supply_a), check_bootstrap_weights (true), -utx_parse_canary (utx_parse_canary_a), -utx_generate_canary (utx_generate_canary_a) +state_block_parse_canary (state_block_parse_canary_a), +state_block_generate_canary (state_block_generate_canary_a) { } @@ -625,7 +625,7 @@ std::string rai::ledger::block_text (rai::block_hash const & hash_a) return result; } -bool rai::ledger::is_utx_send (MDB_txn * transaction_a, rai::utx_block const & block_a) +bool rai::ledger::is_send (MDB_txn * transaction_a, rai::state_block const & block_a) { bool result (false); rai::block_hash previous (block_a.hashables.previous); @@ -643,14 +643,14 @@ rai::block_hash rai::ledger::block_destination (MDB_txn * transaction_a, rai::bl { rai::block_hash result (0); rai::send_block const * send_block (dynamic_cast (&block_a)); - rai::utx_block const * utx_block (dynamic_cast (&block_a)); + rai::state_block const * state_block (dynamic_cast (&block_a)); if (send_block != nullptr) { result = send_block->hashables.destination; } - else if (utx_block != nullptr && is_utx_send (transaction_a, *utx_block)) + else if (state_block != nullptr && is_send (transaction_a, *state_block)) { - result = utx_block->hashables.link; + result = state_block->hashables.link; } return result; } @@ -660,10 +660,10 @@ rai::block_hash rai::ledger::block_source (MDB_txn * transaction_a, rai::block c // If block_a.source () is nonzero, then we have our source. // However, universal blocks will always return zero. rai::block_hash result (block_a.source ()); - rai::utx_block const * utx_block (dynamic_cast (&block_a)); - if (utx_block != nullptr && !is_utx_send (transaction_a, *utx_block)) + rai::state_block const * state_block (dynamic_cast (&block_a)); + if (state_block != nullptr && !is_send (transaction_a, *state_block)) { - result = utx_block->hashables.link; + result = state_block->hashables.link; } return result; } @@ -714,7 +714,7 @@ rai::account rai::ledger::account (MDB_txn * transaction_a, rai::block_hash cons rai::block_hash successor (1); rai::block_info block_info; std::unique_ptr block (store.block_get (transaction_a, hash)); - while (!successor.is_zero () && block->type () != rai::block_type::utx && store.block_info_get (transaction_a, successor, block_info)) + while (!successor.is_zero () && block->type () != rai::block_type::state && store.block_info_get (transaction_a, successor, block_info)) { successor = store.block_successor (transaction_a, hash); if (!successor.is_zero ()) @@ -723,10 +723,10 @@ rai::account rai::ledger::account (MDB_txn * transaction_a, rai::block_hash cons block = store.block_get (transaction_a, hash); } } - if (block->type () == rai::block_type::utx) + if (block->type () == rai::block_type::state) { - auto utx_block (dynamic_cast (block.get ())); - result = utx_block->hashables.account; + auto state_block (dynamic_cast (block.get ())); + result = state_block->hashables.account; } else if (successor.is_zero ()) { @@ -794,14 +794,14 @@ void rai::ledger::dump_account_chain (rai::account const & account_a) } } -bool rai::ledger::utx_parsing_enabled (MDB_txn * transaction_a) +bool rai::ledger::state_block_parsing_enabled (MDB_txn * transaction_a) { - return store.block_exists (transaction_a, utx_parse_canary); + return store.block_exists (transaction_a, state_block_parse_canary); } -bool rai::ledger::utx_generation_enabled (MDB_txn * transaction_a) +bool rai::ledger::state_block_generation_enabled (MDB_txn * transaction_a) { - return utx_parsing_enabled (transaction_a) && store.block_exists (transaction_a, utx_generate_canary); + return state_block_parsing_enabled (transaction_a) && store.block_exists (transaction_a, state_block_generate_canary); } void rai::ledger::checksum_update (MDB_txn * transaction_a, rai::block_hash const & hash_a) @@ -813,7 +813,7 @@ void rai::ledger::checksum_update (MDB_txn * transaction_a, rai::block_hash cons store.checksum_put (transaction_a, 0, 0, value); } -void rai::ledger::change_latest (MDB_txn * transaction_a, rai::account const & account_a, rai::block_hash const & hash_a, rai::block_hash const & rep_block_a, rai::amount const & balance_a, uint64_t block_count_a, bool is_utx) +void rai::ledger::change_latest (MDB_txn * transaction_a, rai::account const & account_a, rai::block_hash const & hash_a, rai::block_hash const & rep_block_a, rai::amount const & balance_a, uint64_t block_count_a, bool is_state) { rai::account_info info; auto exists (!store.account_get (transaction_a, account_a, info)); @@ -834,7 +834,7 @@ void rai::ledger::change_latest (MDB_txn * transaction_a, rai::account const & a info.modified = rai::seconds_since_epoch (); info.block_count = block_count_a; store.account_put (transaction_a, account_a, info); - if (!(block_count_a % store.block_info_max) && !is_utx) + if (!(block_count_a % store.block_info_max) && !is_state) { rai::block_info block_info; block_info.account = account_a; diff --git a/rai/ledger.hpp b/rai/ledger.hpp index a2c49ee3..6d199282 100644 --- a/rai/ledger.hpp +++ b/rai/ledger.hpp @@ -35,7 +35,7 @@ public: bool block_exists (rai::block_hash const &); std::string block_text (char const *); std::string block_text (rai::block_hash const &); - bool is_utx_send (MDB_txn *, rai::utx_block const &); + bool is_send (MDB_txn *, rai::state_block const &); rai::block_hash block_destination (MDB_txn *, rai::block const &); rai::block_hash block_source (MDB_txn *, rai::block const &); rai::uint128_t supply (MDB_txn *); @@ -45,15 +45,15 @@ public: void checksum_update (MDB_txn *, rai::block_hash const &); rai::checksum checksum (MDB_txn *, rai::account const &, rai::account const &); void dump_account_chain (rai::account const &); - bool utx_parsing_enabled (MDB_txn *); - bool utx_generation_enabled (MDB_txn *); + bool state_block_parsing_enabled (MDB_txn *); + bool state_block_generation_enabled (MDB_txn *); static rai::uint128_t const unit; rai::block_store & store; rai::uint128_t inactive_supply; std::unordered_map bootstrap_weights; uint64_t bootstrap_weight_max_blocks; std::atomic check_bootstrap_weights; - rai::block_hash utx_parse_canary; - rai::block_hash utx_generate_canary; + rai::block_hash state_block_parse_canary; + rai::block_hash state_block_generate_canary; }; }; diff --git a/rai/lib/blocks.cpp b/rai/lib/blocks.cpp index cc8e9fc3..cb671e05 100644 --- a/rai/lib/blocks.cpp +++ b/rai/lib/blocks.cpp @@ -831,7 +831,7 @@ void rai::change_block::signature_set (rai::uint512_union const & signature_a) signature = signature_a; } -rai::utx_hashables::utx_hashables (rai::account const & account_a, rai::block_hash const & previous_a, rai::account const & representative_a, rai::amount const & balance_a, rai::uint256_union const & link_a) : +rai::state_hashables::state_hashables (rai::account const & account_a, rai::block_hash const & previous_a, rai::account const & representative_a, rai::amount const & balance_a, rai::uint256_union const & link_a) : account (account_a), previous (previous_a), representative (representative_a), @@ -840,7 +840,7 @@ link (link_a) { } -rai::utx_hashables::utx_hashables (bool & error_a, rai::stream & stream_a) +rai::state_hashables::state_hashables (bool & error_a, rai::stream & stream_a) { error_a = rai::read (stream_a, account); if (!error_a) @@ -861,7 +861,7 @@ rai::utx_hashables::utx_hashables (bool & error_a, rai::stream & stream_a) } } -rai::utx_hashables::utx_hashables (bool & error_a, boost::property_tree::ptree const & tree_a) +rai::state_hashables::state_hashables (bool & error_a, boost::property_tree::ptree const & tree_a) { try { @@ -894,7 +894,7 @@ rai::utx_hashables::utx_hashables (bool & error_a, boost::property_tree::ptree c } } -void rai::utx_hashables::hash (blake2b_state & hash_a) const +void rai::state_hashables::hash (blake2b_state & hash_a) const { blake2b_update (&hash_a, account.bytes.data (), sizeof (account.bytes)); blake2b_update (&hash_a, previous.bytes.data (), sizeof (previous.bytes)); @@ -903,14 +903,14 @@ void rai::utx_hashables::hash (blake2b_state & hash_a) const blake2b_update (&hash_a, link.bytes.data (), sizeof (link.bytes)); } -rai::utx_block::utx_block (rai::account const & account_a, rai::block_hash const & previous_a, rai::account const & representative_a, rai::amount const & balance_a, rai::uint256_union const & link_a, rai::raw_key const & prv_a, rai::public_key const & pub_a, uint64_t work_a) : +rai::state_block::state_block (rai::account const & account_a, rai::block_hash const & previous_a, rai::account const & representative_a, rai::amount const & balance_a, rai::uint256_union const & link_a, rai::raw_key const & prv_a, rai::public_key const & pub_a, uint64_t work_a) : hashables (account_a, previous_a, representative_a, balance_a, link_a), signature (rai::sign_message (prv_a, pub_a, hash ())), work (work_a) { } -rai::utx_block::utx_block (bool & error_a, rai::stream & stream_a) : +rai::state_block::state_block (bool & error_a, rai::stream & stream_a) : hashables (error_a, stream_a) { if (!error_a) @@ -923,7 +923,7 @@ hashables (error_a, stream_a) } } -rai::utx_block::utx_block (bool & error_a, boost::property_tree::ptree const & tree_a) : +rai::state_block::state_block (bool & error_a, boost::property_tree::ptree const & tree_a) : hashables (error_a, tree_a) { if (!error_a) @@ -933,7 +933,7 @@ hashables (error_a, tree_a) auto type_l (tree_a.get ("type")); auto signature_l (tree_a.get ("signature")); auto work_l (tree_a.get ("work")); - error_a = type_l != "utx"; + error_a = type_l != "state"; if (!error_a) { error_a = rai::from_string_hex (work_l, work); @@ -950,29 +950,29 @@ hashables (error_a, tree_a) } } -void rai::utx_block::hash (blake2b_state & hash_a) const +void rai::state_block::hash (blake2b_state & hash_a) const { - rai::uint256_union preamble (static_cast (rai::block_type::utx)); + rai::uint256_union preamble (static_cast (rai::block_type::state)); blake2b_update (&hash_a, preamble.bytes.data (), preamble.bytes.size ()); hashables.hash (hash_a); } -uint64_t rai::utx_block::block_work () const +uint64_t rai::state_block::block_work () const { return work; } -void rai::utx_block::block_work_set (uint64_t work_a) +void rai::state_block::block_work_set (uint64_t work_a) { work = work_a; } -rai::block_hash rai::utx_block::previous () const +rai::block_hash rai::state_block::previous () const { return hashables.previous; } -void rai::utx_block::serialize (rai::stream & stream_a) const +void rai::state_block::serialize (rai::stream & stream_a) const { write (stream_a, hashables.account); write (stream_a, hashables.previous); @@ -983,10 +983,10 @@ void rai::utx_block::serialize (rai::stream & stream_a) const write (stream_a, work); } -void rai::utx_block::serialize_json (std::string & string_a) const +void rai::state_block::serialize_json (std::string & string_a) const { boost::property_tree::ptree tree; - tree.put ("type", "utx"); + tree.put ("type", "state"); tree.put ("account", hashables.account.to_account ()); tree.put ("previous", hashables.previous.to_string ()); tree.put ("representative", representative ().to_account ()); @@ -1002,7 +1002,7 @@ void rai::utx_block::serialize_json (std::string & string_a) const string_a = ostream.str (); } -bool rai::utx_block::deserialize (rai::stream & stream_a) +bool rai::state_block::deserialize (rai::stream & stream_a) { auto error (read (stream_a, hashables.account)); if (!error) @@ -1032,12 +1032,12 @@ bool rai::utx_block::deserialize (rai::stream & stream_a) return error; } -bool rai::utx_block::deserialize_json (boost::property_tree::ptree const & tree_a) +bool rai::state_block::deserialize_json (boost::property_tree::ptree const & tree_a) { auto error (false); try { - assert (tree_a.get ("type") == "utx"); + assert (tree_a.get ("type") == "state"); auto account_l (tree_a.get ("account")); auto previous_l (tree_a.get ("previous")); auto representative_l (tree_a.get ("representative")); @@ -1078,19 +1078,19 @@ bool rai::utx_block::deserialize_json (boost::property_tree::ptree const & tree_ return error; } -void rai::utx_block::visit (rai::block_visitor & visitor_a) const +void rai::state_block::visit (rai::block_visitor & visitor_a) const { - visitor_a.utx_block (*this); + visitor_a.state_block (*this); } -rai::block_type rai::utx_block::type () const +rai::block_type rai::state_block::type () const { - return rai::block_type::utx; + return rai::block_type::state; } -bool rai::utx_block::operator== (rai::block const & other_a) const +bool rai::state_block::operator== (rai::block const & other_a) const { - auto other_l (dynamic_cast (&other_a)); + auto other_l (dynamic_cast (&other_a)); auto result (other_l != nullptr); if (result) { @@ -1099,37 +1099,37 @@ bool rai::utx_block::operator== (rai::block const & other_a) const return result; } -bool rai::utx_block::operator== (rai::utx_block const & other_a) const +bool rai::state_block::operator== (rai::state_block const & other_a) const { return hashables.account == other_a.hashables.account && hashables.previous == other_a.hashables.previous && hashables.representative == other_a.hashables.representative && hashables.balance == other_a.hashables.balance && hashables.link == other_a.hashables.link && signature == other_a.signature && work == other_a.work; } -bool rai::utx_block::valid_predecessor (rai::block const & block_a) const +bool rai::state_block::valid_predecessor (rai::block const & block_a) const { return true; } -rai::block_hash rai::utx_block::source () const +rai::block_hash rai::state_block::source () const { return 0; } -rai::block_hash rai::utx_block::root () const +rai::block_hash rai::state_block::root () const { return !hashables.previous.is_zero () ? hashables.previous : hashables.account; } -rai::account rai::utx_block::representative () const +rai::account rai::state_block::representative () const { return hashables.representative; } -rai::signature rai::utx_block::block_signature () const +rai::signature rai::state_block::block_signature () const { return signature; } -void rai::utx_block::signature_set (rai::uint512_union const & signature_a) +void rai::state_block::signature_set (rai::uint512_union const & signature_a) { signature = signature_a; } @@ -1176,10 +1176,10 @@ std::unique_ptr rai::deserialize_block_json (boost::property_tree::p result = std::move (obj); } } - else if (type == "utx") + else if (type == "state") { bool error; - std::unique_ptr obj (new rai::utx_block (error, tree_a)); + std::unique_ptr obj (new rai::state_block (error, tree_a)); if (!error) { result = std::move (obj); @@ -1249,10 +1249,10 @@ std::unique_ptr rai::deserialize_block (rai::stream & stream_a, rai: } break; } - case rai::block_type::utx: + case rai::block_type::state: { bool error; - std::unique_ptr obj (new rai::utx_block (error, stream_a)); + std::unique_ptr obj (new rai::state_block (error, stream_a)); if (!error) { result = std::move (obj); diff --git a/rai/lib/blocks.hpp b/rai/lib/blocks.hpp index 1d641dbb..2b39ca98 100644 --- a/rai/lib/blocks.hpp +++ b/rai/lib/blocks.hpp @@ -37,7 +37,7 @@ enum class block_type : uint8_t receive = 3, open = 4, change = 5, - utx = 6 + state = 6 }; class block { @@ -232,12 +232,12 @@ public: rai::signature signature; uint64_t work; }; -class utx_hashables +class state_hashables { public: - utx_hashables (rai::account const &, rai::block_hash const &, rai::account const &, rai::amount const &, rai::uint256_union const &); - utx_hashables (bool &, rai::stream &); - utx_hashables (bool &, boost::property_tree::ptree const &); + state_hashables (rai::account const &, rai::block_hash const &, rai::account const &, rai::amount const &, rai::uint256_union const &); + state_hashables (bool &, rai::stream &); + state_hashables (bool &, boost::property_tree::ptree const &); void hash (blake2b_state &) const; // Account# / public key that operates this account // Uses: @@ -254,13 +254,13 @@ public: // Link field contains source block_hash if receiving, destination account if sending rai::uint256_union link; }; -class utx_block : public rai::block +class state_block : public rai::block { public: - utx_block (rai::account const &, rai::block_hash const &, rai::account const &, rai::amount const &, rai::uint256_union const &, rai::raw_key const &, rai::public_key const &, uint64_t); - utx_block (bool &, rai::stream &); - utx_block (bool &, boost::property_tree::ptree const &); - virtual ~utx_block () = default; + state_block (rai::account const &, rai::block_hash const &, rai::account const &, rai::amount const &, rai::uint256_union const &, rai::raw_key const &, rai::public_key const &, uint64_t); + state_block (bool &, rai::stream &); + state_block (bool &, boost::property_tree::ptree const &); + virtual ~state_block () = default; using rai::block::hash; void hash (blake2b_state &) const override; uint64_t block_work () const override; @@ -278,10 +278,10 @@ public: rai::signature block_signature () const override; void signature_set (rai::uint512_union const &) override; bool operator== (rai::block const &) const override; - bool operator== (rai::utx_block const &) const; + bool operator== (rai::state_block const &) const; bool valid_predecessor (rai::block const &) const override; static size_t constexpr size = sizeof (rai::account) + sizeof (rai::block_hash) + sizeof (rai::account) + sizeof (rai::amount) + sizeof (rai::uint256_union) + sizeof (rai::signature) + sizeof (uint64_t); - rai::utx_hashables hashables; + rai::state_hashables hashables; rai::signature signature; uint64_t work; // Only least 48 least significant bits are encoded }; @@ -292,7 +292,7 @@ public: virtual void receive_block (rai::receive_block const &) = 0; virtual void open_block (rai::open_block const &) = 0; virtual void change_block (rai::change_block const &) = 0; - virtual void utx_block (rai::utx_block const &) = 0; + virtual void state_block (rai::state_block const &) = 0; virtual ~block_visitor () = default; }; std::unique_ptr deserialize_block (rai::stream &); diff --git a/rai/node/bootstrap.cpp b/rai/node/bootstrap.cpp index fcad9509..7c2b73bc 100644 --- a/rai/node/bootstrap.cpp +++ b/rai/node/bootstrap.cpp @@ -52,7 +52,7 @@ public: { add_dependency (block_a.hashables.previous); } - void utx_block (rai::utx_block const & block_a) override + void state_block (rai::state_block const & block_a) override { if (!block_a.hashables.previous.is_zero ()) { @@ -594,10 +594,10 @@ void rai::bulk_pull_client::received_type () }); break; } - case rai::block_type::utx: + case rai::block_type::state: { connection->start_timeout (); - boost::asio::async_read (connection->socket, boost::asio::buffer (connection->receive_buffer.data () + 1, rai::utx_block::size), [this_l](boost::system::error_code const & ec, size_t size_a) { + boost::asio::async_read (connection->socket, boost::asio::buffer (connection->receive_buffer.data () + 1, rai::state_block::size), [this_l](boost::system::error_code const & ec, size_t size_a) { this_l->connection->stop_timeout (); this_l->received_block (ec, size_a); }); @@ -2060,9 +2060,9 @@ void rai::bulk_push_server::received_type () }); break; } - case rai::block_type::utx: + case rai::block_type::state: { - boost::asio::async_read (*connection->socket, boost::asio::buffer (receive_buffer.data () + 1, rai::utx_block::size), [this_l](boost::system::error_code const & ec, size_t size_a) { + boost::asio::async_read (*connection->socket, boost::asio::buffer (receive_buffer.data () + 1, rai::state_block::size), [this_l](boost::system::error_code const & ec, size_t size_a) { this_l->received_block (ec, size_a); }); break; diff --git a/rai/node/common.cpp b/rai/node/common.cpp index 84853c7e..d68a5df8 100644 --- a/rai/node/common.cpp +++ b/rai/node/common.cpp @@ -389,7 +389,7 @@ bool rai::confirm_ack::deserialize (rai::stream & stream_a) void rai::confirm_ack::serialize (rai::stream & stream_a) { - assert (block_type () == rai::block_type::send || block_type () == rai::block_type::receive || block_type () == rai::block_type::open || block_type () == rai::block_type::change || block_type () == rai::block_type::utx); + assert (block_type () == rai::block_type::send || block_type () == rai::block_type::receive || block_type () == rai::block_type::open || block_type () == rai::block_type::change || block_type () == rai::block_type::state); write_header (stream_a); vote->serialize (stream_a, block_type ()); } diff --git a/rai/node/node.cpp b/rai/node/node.cpp index 0dd7e240..f069868b 100644 --- a/rai/node/node.cpp +++ b/rai/node/node.cpp @@ -800,8 +800,8 @@ bootstrap_connections (4), bootstrap_connections_max (64), callback_port (0), lmdb_max_dbs (128), -utx_parse_canary (0), -utx_generate_canary (0) +state_block_parse_canary (0), +state_block_generate_canary (0) { switch (rai::rai_network) { @@ -811,8 +811,8 @@ utx_generate_canary (0) case rai::rai_networks::rai_beta_network: preconfigured_peers.push_back ("rai-beta.raiblocks.net"); preconfigured_representatives.push_back (rai::account ("C93F714298E6061E549E52BB8885085319BE977B3FE8F03A1B726E9BE4BE38DE")); - utx_parse_canary = rai::block_hash ("5005F5283DE8D2DAB0DAC41DE9BD23640F962B4F0EA7D3128C2EA3D78D578E27"); - utx_generate_canary = rai::block_hash ("FC18E2265FB835E8CF60E63531053A768CEDF5194263B01A5C95574944E4660D"); + state_block_parse_canary = rai::block_hash ("5005F5283DE8D2DAB0DAC41DE9BD23640F962B4F0EA7D3128C2EA3D78D578E27"); + state_block_generate_canary = rai::block_hash ("FC18E2265FB835E8CF60E63531053A768CEDF5194263B01A5C95574944E4660D"); break; case rai::rai_networks::rai_live_network: preconfigured_peers.push_back ("rai.raiblocks.net"); @@ -824,8 +824,8 @@ utx_generate_canary (0) preconfigured_representatives.push_back (rai::account ("2399A083C600AA0572F5E36247D978FCFC840405F8D4B6D33161C0066A55F431")); preconfigured_representatives.push_back (rai::account ("2298FAB7C61058E77EA554CB93EDEEDA0692CBFCC540AB213B2836B29029E23A")); preconfigured_representatives.push_back (rai::account ("3FE80B4BC842E82C1C18ABFEEC47EA989E63953BC82AC411F304D13833D52A56")); - utx_parse_canary = rai::block_hash ("89F1C0AC4C5AD23964AB880571E3EA67FDC41BD11AB20E67F0A29CF94CD4E24A"); - utx_generate_canary = rai::block_hash ("B6DC4D64801BEC7D81DAA086A5733D251E8CBA0E9226FD6173D97C0569EC2998"); + state_block_parse_canary = rai::block_hash ("89F1C0AC4C5AD23964AB880571E3EA67FDC41BD11AB20E67F0A29CF94CD4E24A"); + state_block_generate_canary = rai::block_hash ("B6DC4D64801BEC7D81DAA086A5733D251E8CBA0E9226FD6173D97C0569EC2998"); break; default: assert (false); @@ -877,8 +877,8 @@ void rai::node_config::serialize_json (boost::property_tree::ptree & tree_a) con tree_a.put ("callback_port", std::to_string (callback_port)); tree_a.put ("callback_target", callback_target); tree_a.put ("lmdb_max_dbs", lmdb_max_dbs); - tree_a.put ("utx_parse_canary", utx_parse_canary.to_string ()); - tree_a.put ("utx_generate_canary", utx_generate_canary.to_string ()); + tree_a.put ("state_block_parse_canary", state_block_parse_canary.to_string ()); + tree_a.put ("state_block_generate_canary", state_block_generate_canary.to_string ()); } bool rai::node_config::upgrade_json (unsigned version, boost::property_tree::ptree & tree_a) @@ -953,8 +953,8 @@ bool rai::node_config::upgrade_json (unsigned version, boost::property_tree::ptr tree_a.put ("version", "9"); result = true; case 9: - tree_a.put ("utx_parse_canary", utx_parse_canary.to_string ()); - tree_a.put ("utx_generate_canary", utx_generate_canary.to_string ()); + tree_a.put ("state_block_parse_canary", state_block_parse_canary.to_string ()); + tree_a.put ("state_block_generate_canary", state_block_generate_canary.to_string ()); tree_a.erase ("version"); tree_a.put ("version", "10"); result = true; @@ -1032,8 +1032,8 @@ bool rai::node_config::deserialize_json (bool & upgraded_a, boost::property_tree callback_target = tree_a.get ("callback_target"); auto lmdb_max_dbs_l = tree_a.get ("lmdb_max_dbs"); result |= parse_port (callback_port_l, callback_port); - auto utx_parse_canary_l = tree_a.get ("utx_parse_canary"); - auto utx_generate_canary_l = tree_a.get ("utx_generate_canary"); + auto state_block_parse_canary_l = tree_a.get ("state_block_parse_canary"); + auto state_block_generate_canary_l = tree_a.get ("state_block_generate_canary"); try { peering_port = std::stoul (peering_port_l); @@ -1052,8 +1052,8 @@ bool rai::node_config::deserialize_json (bool & upgraded_a, boost::property_tree result |= password_fanout > 1024 * 1024; result |= io_threads == 0; result |= work_threads == 0; - result |= utx_parse_canary.decode_hex (utx_parse_canary_l); - result |= utx_generate_canary.decode_hex (utx_generate_canary_l); + result |= state_block_parse_canary.decode_hex (state_block_parse_canary_l); + result |= state_block_generate_canary.decode_hex (state_block_generate_canary_l); } catch (std::logic_error const &) { @@ -1322,13 +1322,13 @@ rai::process_return rai::block_processor::process_receive_one (MDB_txn * transac node.gap_cache.add (transaction_a, block_a); break; } - case rai::process_result::utx_disabled: + case rai::process_result::state_block_disabled: { if (node.config.logging.ledger_logging ()) { - BOOST_LOG (node.log) << boost::str (boost::format ("UTX blocks are disabled: %1%") % block_a->hash ().to_string ()); + BOOST_LOG (node.log) << boost::str (boost::format ("State blocks are disabled: %1%") % block_a->hash ().to_string ()); } - node.store.unchecked_put (transaction_a, node.ledger.utx_parse_canary, block_a); + node.store.unchecked_put (transaction_a, node.ledger.state_block_parse_canary, block_a); node.gap_cache.add (transaction_a, block_a); break; } @@ -1430,7 +1430,7 @@ alarm (alarm_a), work (work_a), store (init_a.block_store_init, application_path_a / "data.ldb", config_a.lmdb_max_dbs), gap_cache (*this), -ledger (store, config_a.inactive_supply.number (), config.utx_parse_canary, config.utx_generate_canary), +ledger (store, config_a.inactive_supply.number (), config.state_block_parse_canary, config.state_block_generate_canary), active (*this), wallets (init_a.block_store_init, *this), network (*this, config.peering_port), @@ -1474,9 +1474,9 @@ block_processor_thread ([this]() { this->block_processor.process_blocks (); }) block_a->serialize_json (block_text); event.add ("block", block_text); event.add ("amount", result_a.amount.to_string_dec ()); - if (result_a.utx_is_send) + if (result_a.state_is_send) { - event.add ("is_send", *result_a.utx_is_send); + event.add ("is_send", *result_a.state_is_send); } std::stringstream ostream; boost::property_tree::write_json (ostream, event); @@ -2377,7 +2377,7 @@ public: } } } - void utx_block (rai::utx_block const & block_a) override + void state_block (rai::state_block const & block_a) override { scan_receivable (block_a.hashables.link); } diff --git a/rai/node/node.hpp b/rai/node/node.hpp index 7774be06..8a9db526 100644 --- a/rai/node/node.hpp +++ b/rai/node/node.hpp @@ -409,8 +409,8 @@ public: uint16_t callback_port; std::string callback_target; int lmdb_max_dbs; - rai::block_hash utx_parse_canary; - rai::block_hash utx_generate_canary; + rai::block_hash state_block_parse_canary; + rai::block_hash state_block_generate_canary; static std::chrono::seconds constexpr keepalive_period = std::chrono::seconds (60); static std::chrono::seconds constexpr keepalive_cutoff = keepalive_period * 5; static std::chrono::minutes constexpr wallet_backup_interval = std::chrono::minutes (5); diff --git a/rai/node/rpc.cpp b/rai/node/rpc.cpp index 01e4774d..d859e964 100644 --- a/rai/node/rpc.cpp +++ b/rai/node/rpc.cpp @@ -1042,7 +1042,7 @@ void rai::rpc_handler::block_count_type () response_l.put ("receive", std::to_string (count.receive)); response_l.put ("open", std::to_string (count.open)); response_l.put ("change", std::to_string (count.change)); - response_l.put ("utx", std::to_string (count.utx)); + response_l.put ("state", std::to_string (count.state)); response (response_l); } @@ -1201,15 +1201,15 @@ void rai::rpc_handler::block_create () { rai::uint256_union pub; ed25519_publickey (prv.data.bytes.data (), pub.bytes.data ()); - if (type == "utx") + if (type == "state") { if (!account.is_zero () && previous_text.is_initialized () && !representative.is_zero () && !balance.is_zero () && link_text.is_initialized ()) { - rai::utx_block utx (account, previous, representative, balance, link, prv, pub, work); + rai::state_block state (account, previous, representative, balance, link, prv, pub, work); boost::property_tree::ptree response_l; - response_l.put ("hash", utx.hash ().to_string ()); + response_l.put ("hash", state.hash ().to_string ()); std::string contents; - utx.serialize_json (contents); + state.serialize_json (contents); response_l.put ("block", contents); response (response_l); } @@ -1653,11 +1653,11 @@ public: tree.put ("representative", block_a.hashables.representative.to_account ()); } } - void utx_block (rai::utx_block const & block_a) + void state_block (rai::state_block const & block_a) { if (raw) { - tree.put ("type", "utx"); + tree.put ("type", "state"); tree.put ("representative", block_a.hashables.representative.to_account ()); tree.put ("link", block_a.hashables.link.to_string ()); } @@ -2511,9 +2511,9 @@ void rai::rpc_handler::process () error_response (response, "Gap source block"); break; } - case rai::process_result::utx_disabled: + case rai::process_result::state_block_disabled: { - error_response (response, "UTX blocks are disabled"); + error_response (response, "State blocks are disabled"); break; } case rai::process_result::old: diff --git a/rai/node/testing.cpp b/rai/node/testing.cpp index 9703fd5f..93f43ede 100644 --- a/rai/node/testing.cpp +++ b/rai/node/testing.cpp @@ -296,14 +296,14 @@ void rai::system::generate_mass_activity (uint32_t count_a, rai::node & node_a) auto now (std::chrono::steady_clock::now ()); auto us (std::chrono::duration_cast (now - previous).count ()); uint64_t count (0); - uint64_t utx (0); + uint64_t state (0); { rai::transaction transaction (node_a.store.environment, nullptr, false); auto block_counts (node_a.store.block_count (transaction)); count = block_counts.sum (); - utx = block_counts.utx; + state = block_counts.state; } - std::cerr << boost::str (boost::format ("Mass activity iteration %1% us %2% us/t %3% utx: %4% old: %5%\n") % i % us % (us / 256) % utx % (count - utx)); + std::cerr << boost::str (boost::format ("Mass activity iteration %1% us %2% us/t %3% state: %4% old: %5%\n") % i % us % (us / 256) % state % (count - state)); previous = now; } generate_activity (node_a, accounts); diff --git a/rai/node/wallet.cpp b/rai/node/wallet.cpp index fb6889c5..7315acd0 100644 --- a/rai/node/wallet.cpp +++ b/rai/node/wallet.cpp @@ -865,9 +865,9 @@ std::shared_ptr rai::wallet::receive_action (rai::block const & send { std::shared_ptr rep_block = node.ledger.store.block_get (transaction, info.rep_block); assert (rep_block != nullptr); - if (should_generate_utx (transaction, info.head)) + if (should_generate_state_block (transaction, info.head)) { - block.reset (new rai::utx_block (account, info.head, rep_block->representative (), info.balance.number () + pending_info.amount.number (), hash, prv, account, generate_work_a ? work_fetch (transaction, account, info.head) : 0)); + block.reset (new rai::state_block (account, info.head, rep_block->representative (), info.balance.number () + pending_info.amount.number (), hash, prv, account, generate_work_a ? work_fetch (transaction, account, info.head) : 0)); } else { @@ -876,9 +876,9 @@ std::shared_ptr rai::wallet::receive_action (rai::block const & send } else { - if (node.ledger.utx_generation_enabled (transaction)) + if (node.ledger.state_block_generation_enabled (transaction)) { - block.reset (new rai::utx_block (account, 0, representative_a, pending_info.amount, hash, prv, account, generate_work_a ? work_fetch (transaction, account, account) : 0)); + block.reset (new rai::state_block (account, 0, representative_a, pending_info.amount, hash, prv, account, generate_work_a ? work_fetch (transaction, account, account) : 0)); } else { @@ -940,9 +940,9 @@ std::shared_ptr rai::wallet::change_action (rai::account const & sou rai::raw_key prv; auto error2 (store.fetch (transaction, source_a, prv)); assert (!error2); - if (should_generate_utx (transaction, info.head)) + if (should_generate_state_block (transaction, info.head)) { - block.reset (new rai::utx_block (source_a, info.head, representative_a, info.balance, 0, prv, source_a, generate_work_a ? work_fetch (transaction, source_a, info.head) : 0)); + block.reset (new rai::state_block (source_a, info.head, representative_a, info.balance, 0, prv, source_a, generate_work_a ? work_fetch (transaction, source_a, info.head) : 0)); } else { @@ -1017,9 +1017,9 @@ std::shared_ptr rai::wallet::send_action (rai::account const & sourc assert (!error2); std::shared_ptr rep_block = node.ledger.store.block_get (transaction, info.rep_block); assert (rep_block != nullptr); - if (should_generate_utx (transaction, info.head)) + if (should_generate_state_block (transaction, info.head)) { - block.reset (new rai::utx_block (source_a, info.head, rep_block->representative (), balance - amount_a, account_a, prv, source_a, generate_work_a ? work_fetch (transaction, source_a, info.head) : 0)); + block.reset (new rai::state_block (source_a, info.head, rep_block->representative (), balance - amount_a, account_a, prv, source_a, generate_work_a ? work_fetch (transaction, source_a, info.head) : 0)); } else { @@ -1052,12 +1052,12 @@ std::shared_ptr rai::wallet::send_action (rai::account const & sourc return block; } -bool rai::wallet::should_generate_utx (MDB_txn * transaction_a, rai::block_hash const & hash_a) +bool rai::wallet::should_generate_state_block (MDB_txn * transaction_a, rai::block_hash const & hash_a) { auto head (node.store.block_get (transaction_a, hash_a)); assert (head != nullptr); - auto is_utx (dynamic_cast (head.get ()) != nullptr); - return is_utx || node.ledger.utx_generation_enabled (transaction_a); + auto is_state (dynamic_cast (head.get ()) != nullptr); + return is_state || node.ledger.state_block_generation_enabled (transaction_a); } bool rai::wallet::change_sync (rai::account const & source_a, rai::account const & representative_a) diff --git a/rai/node/wallet.hpp b/rai/node/wallet.hpp index 198d552e..67e1c9f1 100644 --- a/rai/node/wallet.hpp +++ b/rai/node/wallet.hpp @@ -151,7 +151,7 @@ public: void work_ensure (MDB_txn *, rai::account const &); bool search_pending (); void init_free_accounts (MDB_txn *); - bool should_generate_utx (MDB_txn *, rai::block_hash const &); + bool should_generate_state_block (MDB_txn *, rai::block_hash const &); /** Changes the wallet seed and returns the first account */ rai::public_key change_seed (MDB_txn * transaction_a, rai::raw_key const & prv_a); std::unordered_set free_accounts; diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index 15fc8ea9..8544ccd2 100644 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -518,7 +518,7 @@ public: amount = 0; account = block_a.hashables.representative; } - void utx_block (rai::utx_block const & block_a) + void state_block (rai::state_block const & block_a) { auto balance (block_a.hashables.balance.number ()); auto previous_balance (ledger.balance (transaction, block_a.hashables.previous)); diff --git a/rai/slow_test/node.cpp b/rai/slow_test/node.cpp index 0a8a771e..bb49e866 100644 --- a/rai/slow_test/node.cpp +++ b/rai/slow_test/node.cpp @@ -34,26 +34,26 @@ TEST (system, generate_mass_activity_long) runner.join (); } -TEST (system, generate_mass_activity_utx_enable) +TEST (system, generate_mass_activity_state_block_enable) { rai::system system (24000, 1); rai::thread_runner runner (system.service, system.nodes[0]->config.io_threads); system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv); system.nodes[0]->alarm.add (std::chrono::steady_clock::now () + std::chrono::minutes (1), [&system]() { - std::cerr << boost::str (boost::format ("Enabling utx block parsing\n")); + std::cerr << boost::str (boost::format ("Enabling state block parsing\n")); rai::transaction transaction (system.nodes[0]->store.environment, nullptr, true); - ASSERT_FALSE (system.nodes[0]->ledger.utx_parsing_enabled (transaction)); + ASSERT_FALSE (system.nodes[0]->ledger.state_block_parsing_enabled (transaction)); rai::genesis genesis; - system.nodes[0]->ledger.utx_parse_canary = genesis.hash (); - ASSERT_TRUE (system.nodes[0]->ledger.utx_parsing_enabled (transaction)); + system.nodes[0]->ledger.state_block_parse_canary = genesis.hash (); + ASSERT_TRUE (system.nodes[0]->ledger.state_block_parsing_enabled (transaction)); }); system.nodes[0]->alarm.add (std::chrono::steady_clock::now () + std::chrono::minutes (2), [&system]() { - std::cerr << boost::str (boost::format ("Enabling utx block generation\n")); + std::cerr << boost::str (boost::format ("Enabling state block generation\n")); rai::transaction transaction (system.nodes[0]->store.environment, nullptr, true); - ASSERT_FALSE (system.nodes[0]->ledger.utx_generation_enabled (transaction)); + ASSERT_FALSE (system.nodes[0]->ledger.state_block_generation_enabled (transaction)); rai::genesis genesis; - system.nodes[0]->ledger.utx_generate_canary = genesis.hash (); - ASSERT_TRUE (system.nodes[0]->ledger.utx_generation_enabled (transaction)); + system.nodes[0]->ledger.state_block_generate_canary = genesis.hash (); + ASSERT_TRUE (system.nodes[0]->ledger.state_block_generation_enabled (transaction)); }); size_t count (1000000000); system.generate_mass_activity (count, *system.nodes[0]);