forked from lthn/blockchain
commit
c7a4fb7b0f
3 changed files with 17 additions and 11 deletions
|
|
@ -29,13 +29,16 @@ extern "C" {
|
||||||
|
|
||||||
namespace crypto
|
namespace crypto
|
||||||
{
|
{
|
||||||
#define OPT_XOR_4_RES(A_, B_, C_, D_, Res) \
|
#define CONCAT_IMPL(x, y) x##y
|
||||||
crypto::hash A = A_;crypto::hash B = B_;crypto::hash C = C_; crypto::hash D = D_; \
|
#define CONCAT(x, y) CONCAT_IMPL(x, y)
|
||||||
((uint64_t*)&Res)[0] = ((const uint64_t*)&A)[0] ^ ((const uint64_t*)&B)[0] ^ ((const uint64_t*)&C)[0] ^ ((const uint64_t*)&D)[0]; \
|
#define UNIQUE(x) CONCAT(x, __LINE__)
|
||||||
((uint64_t*)&Res)[1] = ((const uint64_t*)&A)[1] ^ ((const uint64_t*)&B)[1] ^ ((const uint64_t*)&C)[1] ^ ((const uint64_t*)&D)[1]; \
|
|
||||||
((uint64_t*)&Res)[2] = ((const uint64_t*)&A)[2] ^ ((const uint64_t*)&B)[2] ^ ((const uint64_t*)&C)[2] ^ ((const uint64_t*)&D)[2]; \
|
|
||||||
((uint64_t*)&Res)[3] = ((const uint64_t*)&A)[3] ^ ((const uint64_t*)&B)[3] ^ ((const uint64_t*)&C)[3] ^ ((const uint64_t*)&D)[3];
|
|
||||||
|
|
||||||
|
#define OPT_XOR_4_RES(A_, B_, C_, D_, Res) \
|
||||||
|
crypto::hash UNIQUE(A) = A_;crypto::hash UNIQUE(B) = B_;crypto::hash UNIQUE(C) = C_; crypto::hash UNIQUE(D) = D_; \
|
||||||
|
((uint64_t*)&Res)[0] = ((const uint64_t*)&UNIQUE(A))[0] ^ ((const uint64_t*)&UNIQUE(B))[0] ^ ((const uint64_t*)&UNIQUE(C))[0] ^ ((const uint64_t*)&UNIQUE(D))[0]; \
|
||||||
|
((uint64_t*)&Res)[1] = ((const uint64_t*)&UNIQUE(A))[1] ^ ((const uint64_t*)&UNIQUE(B))[1] ^ ((const uint64_t*)&UNIQUE(C))[1] ^ ((const uint64_t*)&UNIQUE(D))[1]; \
|
||||||
|
((uint64_t*)&Res)[2] = ((const uint64_t*)&UNIQUE(A))[2] ^ ((const uint64_t*)&UNIQUE(B))[2] ^ ((const uint64_t*)&UNIQUE(C))[2] ^ ((const uint64_t*)&UNIQUE(D))[2]; \
|
||||||
|
((uint64_t*)&Res)[3] = ((const uint64_t*)&UNIQUE(A))[3] ^ ((const uint64_t*)&UNIQUE(B))[3] ^ ((const uint64_t*)&UNIQUE(C))[3] ^ ((const uint64_t*)&UNIQUE(D))[3];
|
||||||
|
|
||||||
typedef uint64_t state_t_m[25];
|
typedef uint64_t state_t_m[25];
|
||||||
typedef uint64_t mixin_t[KK_MIXIN_SIZE];
|
typedef uint64_t mixin_t[KK_MIXIN_SIZE];
|
||||||
|
|
|
||||||
|
|
@ -101,14 +101,17 @@ bool generate_events(currency::core& c, cct_events_t& events, const cct_wallets_
|
||||||
|
|
||||||
const currency::account_public_address& miner_addr = wallets[random_in_range(0, wallets.size() - 1)]->get_account().get_public_address();
|
const currency::account_public_address& miner_addr = wallets[random_in_range(0, wallets.size() - 1)]->get_account().get_public_address();
|
||||||
currency::block b = AUTO_VAL_INIT(b);
|
currency::block b = AUTO_VAL_INIT(b);
|
||||||
|
currency::scratchpad_keeper sk;
|
||||||
|
crypto::hash seed = currency::null_hash;
|
||||||
|
|
||||||
|
sk.generate(seed, height);
|
||||||
if (is_in_main_chain)
|
if (is_in_main_chain)
|
||||||
{
|
{
|
||||||
blobdata ex_nonce;
|
blobdata ex_nonce;
|
||||||
wide_difficulty_type diff = 0;
|
wide_difficulty_type diff = 0;
|
||||||
if (prev_block.height != 0)
|
if (prev_block.height != 0)
|
||||||
test_core_time::adjust(prev_block.bl.timestamp + DIFFICULTY_POW_TARGET);
|
test_core_time::adjust(prev_block.bl.timestamp + DIFFICULTY_POW_TARGET);
|
||||||
r = bcs.create_block_template(b, miner_addr, diff, height, ex_nonce);
|
r = bcs.create_block_template(b, seed, miner_addr, diff, height, ex_nonce);
|
||||||
CHECK_AND_ASSERT_MES(r, false, "create_block_template failed");
|
CHECK_AND_ASSERT_MES(r, false, "create_block_template failed");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -142,7 +145,7 @@ bool generate_events(currency::core& c, cct_events_t& events, const cct_wallets_
|
||||||
test_core_time::adjust(b.timestamp);
|
test_core_time::adjust(b.timestamp);
|
||||||
|
|
||||||
currency::wide_difficulty_type diff = 0;
|
currency::wide_difficulty_type diff = 0;
|
||||||
r = currency::miner::find_nonce_for_given_block(b, diff, height);
|
r = currency::miner::find_nonce_for_given_block(b, diff, height, seed, sk);
|
||||||
CHECK_AND_ASSERT_MES(r, false, "find_nonce_for_given_block failed");
|
CHECK_AND_ASSERT_MES(r, false, "find_nonce_for_given_block failed");
|
||||||
|
|
||||||
currency::block_verification_context bvc = AUTO_VAL_INIT(bvc);
|
currency::block_verification_context bvc = AUTO_VAL_INIT(bvc);
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ public:
|
||||||
#define SCR_I(i) m_scratchpad_vec[st[i]%m_scratchpad_vec.size()]
|
#define SCR_I(i) m_scratchpad_vec[st[i]%m_scratchpad_vec.size()]
|
||||||
for (size_t i = 0; i != 6; i++)
|
for (size_t i = 0; i != 6; i++)
|
||||||
{
|
{
|
||||||
*(crypto::hash*)&mix[i * 4] = XOR_4(SCR_I(i * 4), SCR_I(i * 4 + 1), SCR_I(i * 4 + 2), SCR_I(i * 4 + 3));
|
OPT_XOR_4_RES(SCR_I(i * 4), SCR_I(i * 4 + 1), SCR_I(i * 4 + 2), SCR_I(i * 4 + 3), *(crypto::hash*)&mix[i * 4]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -177,7 +177,7 @@ void measure_keccak_over_scratchpad()
|
||||||
crypto::hash res_to_test = { 0 };
|
crypto::hash res_to_test = { 0 };
|
||||||
crypto::hash res_etalon = { 0 };
|
crypto::hash res_etalon = { 0 };
|
||||||
OPT_XOR_4_RES(scratchpad_vec[0], scratchpad_vec[1], scratchpad_vec[2], scratchpad_vec[3], res_to_test);
|
OPT_XOR_4_RES(scratchpad_vec[0], scratchpad_vec[1], scratchpad_vec[2], scratchpad_vec[3], res_to_test);
|
||||||
res_etalon = XOR_4(scratchpad_vec[0], scratchpad_vec[1], scratchpad_vec[2], scratchpad_vec[3]);
|
OPT_XOR_4_RES(scratchpad_vec[0], scratchpad_vec[1], scratchpad_vec[2], scratchpad_vec[3], res_etalon);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -222,7 +222,7 @@ void measure_keccak_over_scratchpad()
|
||||||
uint64_t ticks_d = epee::misc_utils::get_tick_count();
|
uint64_t ticks_d = epee::misc_utils::get_tick_count();
|
||||||
for (size_t r = 0; r != measere_rounds; r++)
|
for (size_t r = 0; r != measere_rounds; r++)
|
||||||
{
|
{
|
||||||
crypto::get_wild_keccak2(has_str, res_h, 1, scratchpad_vec, i);
|
crypto::get_wild_keccak2(has_str, res_h, scratchpad_vec, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ticks_e = epee::misc_utils::get_tick_count();
|
uint64_t ticks_e = epee::misc_utils::get_tick_count();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue