Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update asn1 files #17

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Update asn1 files #17

wants to merge 11 commits into from

Conversation

xDimon
Copy link
Member

@xDimon xDimon commented Dec 13, 2024

Update code of parsing asn1 files in according with changes of jam-test-vectors.
Fix safrol test.

@xDimon xDimon requested review from kamilsa and turuslan December 13, 2024 14:02
@@ -7,7 +7,7 @@
#pragma once

#include <qtils/bytes.hpp>
#include <qtils/bytestr.hpp>
#include <qtils/byte_utils.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert after qdrvm/qtils#7 is merged.

Doesn't build on macos (#include <print>, std::format_string, ...) must fix qtils

Comment on lines +16 to +18
inline constexpr bool operator==(const Empty &) const {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline constexpr bool operator==(const Empty &) const {
return true;
}
constexpr bool operator==(const Empty &) const = default;


namespace jam {

template <typename T, typename = std::enable_if<std::is_scalar_v<T>>>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use Foo = Tagged<T> instead of struct Foo { T v }?

Why inherit Tagged<T> : T {} instead of Tagged<T> { T v }?

/// Special zero-size-type for some things
/// (e.g., dummy types of variant, unsupported or experimental).
template <size_t N>
using Unused = Tagged<Empty, NumTag<N>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate struct, not related to Empty (encode/decode)

Suggested change
using Unused = Tagged<Empty, NumTag<N>>;
struct Unused {};

#include <test-vectors/vectors.hpp>

namespace jam::test_vectors_disputes {
namespace jam::test_vectors::disputes {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace test_vectors_disputes was intentional, to avoid
"no type/function foo in namespace disputes, did you mean jam::disputes::foo or jam::test_vectors::disputes::foo" error

.tau = tau_tick,
.eta = {eta_tick_0, eta_tick_1, eta_tick_2, eta_tick_3},
.lambda = lambda_tick,
.kappa = kappa_tick,
.gamma_k = gamma_tick_k,
// TODO(turuslan): #3, wait for test vectors
.iota = iota,
.gamma_a = gamma_tick_a,
.gamma_a = {gamma_tick_a.begin(), gamma_tick_a.end()},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.gamma_a = {gamma_tick_a.begin(), gamma_tick_a.end()},
.gamma_a = asVec(gamma_tick_a),

#include <unordered_map>

#include <unordered_map>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate

Suggested change
#include <unordered_map>

Comment on lines +210 to +211
std::ranges::find(post_offenders, validator.ed25519)
!= post_offenders.end()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::ranges::find(post_offenders, validator.ed25519)
!= post_offenders.end()
not qtils::cxx23::ranges::contains(post_offenders, validator.ed25519)

Comment on lines +255 to +257
std::ranges::for_each(gamma_tick_a, [&](const auto &t) {
fmt::println("old: {}-{}", t.id[0], t.attempt);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug log

Suggested change
std::ranges::for_each(gamma_tick_a, [&](const auto &t) {
fmt::println("old: {}-{}", t.id[0], t.attempt);
});

@@ -146,24 +149,23 @@ namespace jam::disputes {
// Signature related judgment offenders.
const auto &faults = ext.faults;

types::EpochIndex current_epoch = state.tau / config.epoch_length;
auto current_epoch = state.tau / config.epoch_length;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Operations may change type, so types::EpochIndex was specified

Suggested change
auto current_epoch = state.tau / config.epoch_length;
types::EpochIndex current_epoch = state.tau / config.epoch_length;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants