Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
context_provider.cpp
Go to the documentation of this file.
2
3#include <cassert>
4#include <limits>
5
8
9namespace bb::avm2::simulation {
10
27 const AztecAddress& msg_sender,
28 const FF& transaction_fee,
29 ContextInterface& parent_context,
31 uint32_t cd_size,
32 bool is_static,
33 const Gas& gas_limit,
34 TransactionPhase phase)
35{
36 merkle_db.create_checkpoint(); // Fork DB just like in TS.
37 uint32_t context_id = next_context_id++;
38 // Memory assumes that the space id is <= 16 bits.
39 BB_ASSERT_LTE(context_id, std::numeric_limits<uint16_t>::max(), "Context ID out of bounds");
40 uint16_t space_id = static_cast<uint16_t>(context_id);
41
42 // Create the new nested context.
45 address,
46 msg_sender,
47 transaction_fee,
48 is_static,
49 gas_limit,
50 parent_context.get_globals(),
58 phase,
59 parent_context,
61 cd_size);
62}
63
79 const AztecAddress& msg_sender,
80 const FF& transaction_fee,
82 const FF& calldata_hash,
83 bool is_static,
84 const Gas& gas_limit,
85 const Gas& gas_used,
86 TransactionPhase phase)
87{
88
89 uint32_t context_id = next_context_id++;
90 // Memory assumes that the space id is <= 16 bits.
91 BB_ASSERT_LTE(context_id, std::numeric_limits<uint16_t>::max(), "Context ID out of bounds");
92 uint16_t space_id = static_cast<uint16_t>(context_id);
93
94 cd_hash_provider.make_calldata_hasher(context_id)->assert_calldata_hash(calldata_hash, calldata);
95
98 address,
99 msg_sender,
100 transaction_fee,
101 is_static,
102 gas_limit,
103 gas_used,
108 merkle_db,
112 phase,
113 calldata);
114}
115
117{
118 return next_context_id;
119}
120
121} // namespace bb::avm2::simulation
#define BB_ASSERT_LTE(left, right,...)
Definition assert.hpp:158
virtual std::unique_ptr< CalldataHashingInterface > make_calldata_hasher(uint32_t context_id)=0
virtual const GlobalVariables & get_globals() const =0
CalldataHashingProviderInterface & cd_hash_provider
WrittenPublicDataSlotsTreeCheckInterface & written_public_data_slots_tree
std::unique_ptr< ContextInterface > make_enqueued_context(const AztecAddress &address, const AztecAddress &msg_sender, const FF &transaction_fee, std::span< const FF > calldata, const FF &calldata_hash, bool is_static, const Gas &gas_limit, const Gas &gas_used, TransactionPhase phase) override
Make a new enqueued call context.
RetrievedBytecodesTreeCheckInterface & retrieved_bytecodes_tree
SideEffectTrackerInterface & side_effect_tracker
InternalCallStackManagerProviderInterface & internal_call_stack_manager_provider
std::unique_ptr< ContextInterface > make_nested_context(const AztecAddress &address, const AztecAddress &msg_sender, const FF &transaction_fee, ContextInterface &parent_context, MemoryAddress cd_offset_address, uint32_t cd_size, bool is_static, const Gas &gas_limit, TransactionPhase phase) override
Make a new nested context.
MemoryProviderInterface & memory_provider
uint32_t get_next_context_id() const override
TxBytecodeManagerInterface & tx_bytecode_manager
HighLevelMerkleDBInterface & merkle_db
virtual std::unique_ptr< InternalCallStackManagerInterface > make_internal_call_stack_manager(uint32_t context_id)=0
virtual std::unique_ptr< MemoryInterface > make_memory(uint16_t space_id)=0
uint32_t MemoryAddress
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
uint32_t context_id