Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
memory_tag.cpp
Go to the documentation of this file.
1
2
3
#include "
barretenberg/avm_fuzzer/mutations/configuration.hpp
"
4
#include "
barretenberg/vm2/common/memory_types.hpp
"
5
6
using
MemoryTag
=
bb::avm2::MemoryTag
;
7
8
MemoryTag
generate_memory_tag
(
std::mt19937_64
& rng,
const
MemoryTagGenerationConfig
& config)
9
{
10
const
MemoryTagOptions
option = config.
select
(rng);
11
switch
(option) {
12
case
MemoryTagOptions::U1
:
13
return
MemoryTag::U1;
14
case
MemoryTagOptions::U8
:
15
return
MemoryTag::U8;
16
case
MemoryTagOptions::U16
:
17
return
MemoryTag::U16;
18
case
MemoryTagOptions::U32
:
19
return
MemoryTag::U32;
20
case
MemoryTagOptions::U64
:
21
return
MemoryTag::U64;
22
case
MemoryTagOptions::U128
:
23
return
MemoryTag::U128;
24
case
MemoryTagOptions::FF
:
25
return
MemoryTag::FF;
26
}
27
}
28
29
void
mutate_memory_tag
(
MemoryTag
&
value
,
std::mt19937_64
& rng,
const
MemoryTagMutationConfig
& config)
30
{
31
const
MemoryTagOptions
option = config.
select
(rng);
32
switch
(option) {
33
case
MemoryTagOptions::U1
:
34
value
= MemoryTag::U1;
35
break
;
36
case
MemoryTagOptions::U8
:
37
value
= MemoryTag::U8;
38
break
;
39
case
MemoryTagOptions::U16
:
40
value
= MemoryTag::U16;
41
break
;
42
case
MemoryTagOptions::U32
:
43
value
= MemoryTag::U32;
44
break
;
45
case
MemoryTagOptions::U64
:
46
value
= MemoryTag::U64;
47
break
;
48
case
MemoryTagOptions::U128
:
49
value
= MemoryTag::U128;
50
break
;
51
case
MemoryTagOptions::FF
:
52
value
= MemoryTag::FF;
53
break
;
54
}
55
}
56
57
void
mutate_or_default_tag
(
MemoryTag
&
value
,
std::mt19937_64
& rng,
MemoryTag
default_tag,
double
probability = 0.1)
58
{
59
if
(
std::uniform_real_distribution<double>
(0.0, 1.0)(rng) < probability) {
60
mutate_memory_tag
(
value
, rng,
BASIC_MEMORY_TAG_MUTATION_CONFIGURATION
);
61
}
else
{
62
value
= default_tag;
63
}
64
}
WeightedSelectionConfig
Definition
weighted_selection.hpp:8
WeightedSelectionConfig::select
T select(std::mt19937_64 &rng) const
Definition
weighted_selection.hpp:33
configuration.hpp
MemoryTagOptions
MemoryTagOptions
Definition
configuration.hpp:82
MemoryTagOptions::FF
@ FF
MemoryTagOptions::U64
@ U64
MemoryTagOptions::U8
@ U8
MemoryTagOptions::U128
@ U128
MemoryTagOptions::U32
@ U32
MemoryTagOptions::U16
@ U16
MemoryTagOptions::U1
@ U1
BASIC_MEMORY_TAG_MUTATION_CONFIGURATION
constexpr MemoryTagMutationConfig BASIC_MEMORY_TAG_MUTATION_CONFIGURATION
Definition
configuration.hpp:98
generate_memory_tag
MemoryTag generate_memory_tag(std::mt19937_64 &rng, const MemoryTagGenerationConfig &config)
Definition
memory_tag.cpp:8
mutate_or_default_tag
void mutate_or_default_tag(MemoryTag &value, std::mt19937_64 &rng, MemoryTag default_tag, double probability=0.1)
Mutate the memory tag or set to the chosen tag with a given probability.
Definition
memory_tag.cpp:57
mutate_memory_tag
void mutate_memory_tag(MemoryTag &value, std::mt19937_64 &rng, const MemoryTagMutationConfig &config)
Definition
memory_tag.cpp:29
memory_types.hpp
bb::avm2::ValueTag
ValueTag
Definition
tagged_value.hpp:36
bb::avm2::MemoryTag
ValueTag MemoryTag
Definition
memory_types.hpp:9
std::get
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition
tuple.hpp:13
value
FF value
Definition
public_data_tree.test.cpp:97
src
barretenberg
avm_fuzzer
mutations
basic_types
memory_tag.cpp
Generated by
1.9.8