pallet_evm_polkavm_uapi/flags.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18use bitflags::bitflags;
19
20bitflags! {
21 /// Flags used by a contract to customize exit behaviour.
22 #[cfg_attr(feature = "scale", derive(scale_codec::Encode, scale_codec::Decode, scale_info::TypeInfo))]
23 #[derive(Default)]
24 pub struct ReturnFlags: u32 {
25 /// If this bit is set all changes made by the contract execution are rolled back.
26 const REVERT = 0x0000_0001;
27 }
28}
29
30bitflags! {
31 /// Flags used to change the behaviour of `seal_call` and `seal_delegate_call`.
32 pub struct CallFlags: u32 {
33 /// Forward the input of current function to the callee.
34 ///
35 /// Supplied input pointers are ignored when set.
36 ///
37 /// # Note
38 ///
39 /// A forwarding call will consume the current contracts input. Any attempt to
40 /// access the input after this call returns will lead to [`Error::InputForwarded`].
41 /// It does not matter if this is due to calling `call_data_copy` or trying another
42 /// forwarding call. Consider using [`Self::CLONE_INPUT`] in order to preserve
43 /// the input.
44 const FORWARD_INPUT = 0b0000_0001;
45 /// Identical to [`Self::FORWARD_INPUT`] but without consuming the input.
46 ///
47 /// This adds some additional weight costs to the call.
48 ///
49 /// # Note
50 ///
51 /// This implies [`Self::FORWARD_INPUT`] and takes precedence when both are set.
52 const CLONE_INPUT = 0b0000_0010;
53 /// Do not return from the call but rather return the result of the callee to the
54 /// callers caller.
55 ///
56 /// # Note
57 ///
58 /// This makes the current contract completely transparent to its caller by replacing
59 /// this contracts potential output by the callee ones. Any code after `seal_call`
60 /// can be safely considered unreachable.
61 const TAIL_CALL = 0b0000_0100;
62 /// Allow the callee to reenter into the current contract.
63 ///
64 /// Without this flag any reentrancy into the current contract that originates from
65 /// the callee (or any of its callees) is denied. This includes the first callee:
66 /// You cannot call into yourself with this flag set.
67 ///
68 /// # Note
69 ///
70 /// For `seal_delegate_call` should be always unset, otherwise
71 /// [`Error::InvalidCallFlags`] is returned.
72 const ALLOW_REENTRY = 0b0000_1000;
73 /// Indicates that the callee is restricted from modifying the state during call execution,
74 /// equivalent to Ethereum's STATICCALL.
75 ///
76 /// # Note
77 ///
78 /// For `seal_delegate_call` should be always unset, otherwise
79 /// [`Error::InvalidCallFlags`] is returned.
80 const READ_ONLY = 0b0001_0000;
81 }
82}
83
84bitflags! {
85 /// Flags used by a contract to customize storage behaviour.
86 pub struct StorageFlags: u32 {
87 /// Access the transient storage instead of the persistent one.
88 const TRANSIENT = 0x0000_0001;
89 }
90}