Skip to content

Commit

Permalink
evmmax: Add naive evmmax tracing log
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiazet committed Feb 14, 2025
1 parent 8f58150 commit a4ef7ea
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/evmmax/evmmax.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class EVMMAXState
/// Size (expressed in multiples of 8 bytes) needed to represent modulus.
[[nodiscard]] size_t active_mod_value_size_multiplier() const noexcept;

void print_state(std::ostream& out) const noexcept;

void clear() noexcept;

EVMMAXState& operator=(EVMMAXState&&) noexcept;
Expand Down
20 changes: 20 additions & 0 deletions lib/evmmax/evmmax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct EXMMAXModStateInterface
size_t x_stride, size_t y_idx, size_t y_stride, size_t count) noexcept = 0;
[[nodiscard]] virtual bool mulmodx(size_t dst_idx, size_t dst_stride, size_t x_idx,
size_t x_stride, size_t y_idx, size_t y_stride, size_t count) noexcept = 0;
virtual void print(std::ostream& out) noexcept = 0;

[[nodiscard]] virtual size_t value_size_multiplier() const noexcept = 0;
[[nodiscard]] virtual size_t num_values() const noexcept = 0;
Expand Down Expand Up @@ -148,6 +149,17 @@ struct EXMMAXModState : public EXMMAXModStateInterface
dst_stride, x_idx, x_stride, y_idx, y_stride, count);
}

void print(std::ostream& out) noexcept override
{
out << "{ \n";
for (size_t i = 0; i < values.size(); ++i)
{
if (values[i] != 0)
out << "\t" << i << ": " << hex(arith.from_mont(values[i])) << ", \n";
}
out << "}\n";
}

[[nodiscard]] size_t num_values() const noexcept override { return values.size(); }
[[nodiscard]] size_t value_size_multiplier() const noexcept override { return value_size_mult; }
};
Expand Down Expand Up @@ -309,6 +321,14 @@ struct EXMMAXModState : public EXMMAXModStateInterface
return active_mod->value_size_multiplier();
}

void EVMMAXState::print_state(std::ostream& out) const noexcept
{
if (!is_activated())
return;

active_mod->print(out);
}

void EVMMAXState::clear() noexcept
{
active_mod = nullptr;
Expand Down
7 changes: 7 additions & 0 deletions lib/evmone/tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ class InstructionTracer : public Tracer
m_out << R"(,"refund":)" << std::dec << state.gas_refund;
m_out << R"(,"opName":")" << get_name(opcode) << '"';

// if (state.evmmax_state.is_activated())
// {
// m_out << R"(,"evmmax":")" << std::endl;
// m_out << "";
// state.evmmax_state.print_state(m_out);
// }

m_out << "}\n";
}

Expand Down

0 comments on commit a4ef7ea

Please sign in to comment.