Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
call_stack_metadata_collector.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <stack>
4#include <vector>
5
8
9namespace bb::avm2::simulation {
10
11// Forward declaration.
12class ContextInterface;
13class InternalCallStackManagerInterface;
14
16 public:
21
22 void set_phase(CoarseTransactionPhase phase) override;
24 uint32_t caller_pc,
25 const CalldataProvider& calldata_provider,
26 bool is_static_call,
27 const Gas& gas_limit) override;
28 void notify_exit_call(bool success,
29 uint32_t pc,
30 const std::optional<std::string>& halting_message,
31 const ReturnDataProvider& return_data_provider,
32 const InternalCallStackProvider& internal_call_stack_provider) override;
33 void notify_tx_revert(const std::string& revert_message) override;
35
36 private:
37 // Collection limits configuration.
39
40 // It is incremented by 1 for each new call.
41 uint32_t timestamp = 0;
42 // Total number of call stack items collected.
44 // We start with a dummy call stack metadata. This is not a real call,
45 // we use it as a placeholder "root call" that corresponds to the whole TX.
46 // We store the enqueued calls in the nested vector of this root call.
49
50 // Returns true if we should skip collection due to limits being exceeded.
51 bool should_skip_collection() const;
52};
53
54// These factories return an object that is only valid for the lifetime of the context.
55// The returned provider should never fail or throw.
57ReturnDataProvider make_return_data_provider(const ContextInterface& context, uint32_t rd_offset, uint32_t rd_size);
59 const InternalCallStackManagerInterface& internal_call_stack_manager);
60
61// Metadata collector that does not collect.
63 public:
65 void notify_enter_call(const AztecAddress&, uint32_t, const CalldataProvider&, bool, const Gas&) override {}
67 uint32_t,
69 const ReturnDataProvider&,
70 const InternalCallStackProvider&) override
71 {}
72 void notify_tx_revert(const std::string&) override {}
74};
75
76} // namespace bb::avm2::simulation
void notify_exit_call(bool success, uint32_t pc, const std::optional< std::string > &halting_message, const ReturnDataProvider &return_data_provider, const InternalCallStackProvider &internal_call_stack_provider) override
CallStackMetadataCollector(const CollectionLimitsConfig &limits)
void set_phase(CoarseTransactionPhase phase) override
std::vector< CallStackMetadata > dump_call_stack_metadata() override
void notify_enter_call(const AztecAddress &contract_address, uint32_t caller_pc, const CalldataProvider &calldata_provider, bool is_static_call, const Gas &gas_limit) override
void notify_tx_revert(const std::string &revert_message) override
std::vector< CallStackMetadata > dump_call_stack_metadata() override
void notify_enter_call(const AztecAddress &, uint32_t, const CalldataProvider &, bool, const Gas &) override
void notify_exit_call(bool, uint32_t, const std::optional< std::string > &, const ReturnDataProvider &, const InternalCallStackProvider &) override
std::function< std::vector< PC >()> InternalCallStackProvider
InternalCallStackProvider make_internal_call_stack_provider(const InternalCallStackManagerInterface &internal_call_stack_manager)
ReturnDataProvider make_return_data_provider(const ContextInterface &context, uint32_t rd_offset, uint32_t rd_size)
std::function< std::vector< FF >(uint32_t max_size)> CalldataProvider
std::function< std::vector< FF >(uint32_t max_size)> ReturnDataProvider
CalldataProvider make_calldata_provider(const ContextInterface &context)
CoarseTransactionPhase
Definition avm_io.hpp:482
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13