rustev_contract/
limits.rs1use crate::bounded::ParseLimits;
5
6const KIB: usize = 1024;
7const MIB: usize = 1024 * KIB;
8
9pub const DEFINITION_V1: ParseLimits = ParseLimits {
11 max_bytes: MIB,
12 max_depth: 32,
13 max_string_bytes: 64 * KIB,
14 max_collection_len: 4096,
15 max_total_values: 100_000,
16 max_number_bytes: 40,
17 allow_fractional_numbers: false,
18};
19
20pub const SNAPSHOT_V1: ParseLimits = ParseLimits {
22 max_bytes: 4 * MIB,
23 max_depth: 32,
24 max_string_bytes: 256 * KIB,
25 max_collection_len: 10_000,
26 max_total_values: 500_000,
27 max_number_bytes: 40,
28 allow_fractional_numbers: false,
29};
30
31pub const DESCRIPTOR_V1: ParseLimits = ParseLimits {
33 max_bytes: 256 * KIB,
34 max_depth: 16,
35 max_string_bytes: 4 * KIB,
36 max_collection_len: 1024,
37 max_total_values: 20_000,
38 max_number_bytes: 40,
39 allow_fractional_numbers: false,
40};
41
42pub const BACKEND_OUTPUT_V1: ParseLimits = ParseLimits {
44 max_bytes: MIB,
45 max_depth: 8,
46 max_string_bytes: 4 * KIB,
47 max_collection_len: 4096,
48 max_total_values: 50_000,
49 max_number_bytes: 40,
50 allow_fractional_numbers: true,
51};
52
53pub const PLAN_V1: ParseLimits = ParseLimits {
55 max_bytes: 2 * MIB,
56 max_depth: 32,
57 max_string_bytes: 64 * KIB,
58 max_collection_len: 4096,
59 max_total_values: 200_000,
60 max_number_bytes: 40,
61 allow_fractional_numbers: false,
62};
63
64pub const RECORD_V1: ParseLimits = ParseLimits {
66 max_bytes: 4 * MIB,
67 max_depth: 32,
68 max_string_bytes: 256 * KIB,
69 max_collection_len: 10_000,
70 max_total_values: 500_000,
71 max_number_bytes: 40,
72 allow_fractional_numbers: true,
73};
74
75pub const REPLAY_V1: ParseLimits = ParseLimits {
77 max_bytes: 16 * MIB,
78 max_depth: 48,
79 max_string_bytes: 8 * MIB,
80 max_collection_len: 10_000,
81 max_total_values: 1_000_000,
82 max_number_bytes: 40,
83 allow_fractional_numbers: true,
84};
85
86pub const REQUEST_V1: ParseLimits = ParseLimits {
89 max_bytes: 4 * MIB,
90 ..REPLAY_V1
91};
92
93pub const REMOTE_V1: ParseLimits = ParseLimits {
97 max_bytes: 4 * MIB,
98 max_depth: 16,
99 max_string_bytes: MIB,
100 max_collection_len: 4096,
101 max_total_values: 100_000,
102 max_number_bytes: 40,
103 allow_fractional_numbers: true,
104};
105
106pub const EXCHANGE_V1: ParseLimits = ParseLimits {
109 max_bytes: 512 * KIB,
110 max_depth: 8,
111 max_string_bytes: 2 * KIB,
112 max_collection_len: 64,
113 max_total_values: 4096,
114 max_number_bytes: 40,
115 allow_fractional_numbers: false,
116};
117
118pub const DYNAMIC_QUESTION_V1: ParseLimits = ParseLimits {
124 max_bytes: 256 * KIB,
125 max_depth: 8,
126 max_string_bytes: 128 * KIB,
127 max_collection_len: 64,
128 max_total_values: 4096,
129 max_number_bytes: 40,
130 allow_fractional_numbers: false,
131};
132
133pub const TRACE_V1: ParseLimits = ParseLimits {
137 max_bytes: 64 * KIB,
138 max_depth: 8,
139 max_string_bytes: 24 * KIB,
140 max_collection_len: 1024,
141 max_total_values: 20_000,
142 max_number_bytes: 40,
143 allow_fractional_numbers: true,
144};