11namespace sysio {
namespace chain {
namespace webassembly {
16 SYS_ASSERT(
false, unsupported_feature,
"Unsupported Hardfork Detected" );
20 context.control.preactivate_feature( *feature_digest );
24 SYS_ASSERT(ram_bytes >= -1, wasm_execution_error,
"invalid value for ram resource limit expected [-1,INT64_MAX]");
25 SYS_ASSERT(net_weight >= -1, wasm_execution_error,
"invalid value for net resource weight expected [-1,INT64_MAX]");
26 SYS_ASSERT(cpu_weight >= -1, wasm_execution_error,
"invalid value for cpu resource weight expected [-1,INT64_MAX]");
27 if(
context.control.get_mutable_resource_limits_manager().set_account_limits(account, ram_bytes, net_weight, cpu_weight) ) {
28 context.trx_context.validate_ram_usage.insert( account );
33 context.control.get_resource_limits_manager().get_account_limits( account, *ram_bytes, *net_weight, *cpu_weight);
40 SYS_ASSERT(
producers.size() <= config::max_producers, wasm_execution_error,
"Producer schedule exceeds the maximum producer count for this chain");
44 "Producer schedule cannot be empty"
50 std::set<account_name> unique_producers;
52 SYS_ASSERT(
context.is_account(
p.producer_name), wasm_execution_error,
"producer schedule includes a nonexisting account" );
53 std::visit([&
p, num_supported_key_types, validate_keys](
const auto&
a) {
55 std::set<public_key_type> unique_keys;
56 for (
const auto& kw:
a.keys ) {
57 SYS_ASSERT( kw.key.which() < num_supported_key_types, unactivated_key_type,
58 "Unactivated key type used in proposed producer schedule");
61 SYS_ASSERT( kw.key.valid(), wasm_execution_error,
"producer schedule includes an invalid key" );
64 if (std::numeric_limits<uint32_t>::max() - sum_weights <= kw.weight) {
65 sum_weights = std::numeric_limits<uint32_t>::max();
67 sum_weights += kw.weight;
70 unique_keys.insert(kw.key);
73 SYS_ASSERT(
a.keys.size() == unique_keys.size(), wasm_execution_error,
"producer schedule includes a duplicated key for ${account}", (
"account",
p.producer_name));
74 SYS_ASSERT(
a.threshold > 0, wasm_execution_error,
"producer schedule includes an authority with a threshold of 0 for ${account}", (
"account",
p.producer_name));
75 SYS_ASSERT( sum_weights >=
a.threshold, wasm_execution_error,
"producer schedule includes an unsatisfiable authority for ${account}", (
"account",
p.producer_name));
78 unique_producers.insert(
p.producer_name);
80 SYS_ASSERT(
producers.size() == unique_producers.size(), wasm_execution_error,
"duplicate producer name in producer schedule" );
86 auto& gpo =
context.control.get_global_properties();
87 auto&
params = gpo.wasm_configuration;
91 if ( packed_parameters.
size() == 0 )
94 if (
s <= packed_parameters.
size() ) {
106 SYS_ASSERT(version == 0, wasm_config_unknown_version,
"set_wasm_parameters_packed: Unknown version: ${version}", (
"version", version));
110 [&](
auto& gprops ) {
111 gprops.wasm_configuration = cfg;
117 std::vector<producer_authority>
producers;
118 std::vector<legacy::producer_key> old_version;
124 for (
const auto&
p : old_version ) {
132 if (packed_producer_format == 0) {
134 }
else if (packed_producer_format == 1) {
141 SYS_THROW(wasm_execution_error,
"Producer schedule is in an unknown format!");
146 auto& gpo =
context.control.get_global_properties();
149 if( packed_blockchain_parameters.size() == 0 )
return s;
151 if (
s <= packed_blockchain_parameters.size() ) {
165 [&](
auto& gprops ) {
166 gprops.configuration = cfg;
174 std::vector<fc::unsigned_int> ids;
179 if( packed_parameters.
size() == 0 )
return size;
182 chain::config_parse_error,
183 "get_parameters_packed: buffer size is smaller than ${size}", (
"size", size));
200 [&](
auto& gprops ) {
201 gprops.configuration = config_range.config;
211 context.db.modify(
a, [&](
auto& ma ){
212 ma.set_privileged( is_priv );
#define SYS_THROW(exc_type, FORMAT,...)
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Maintains global state information about consensus protocol rules.
uint32_t get_blockchain_parameters_packed(legacy_span< char > packed_blockchain_parameters) const
int32_t is_feature_active(int64_t feature_name) const
void set_privileged(account_name account, bool is_priv)
int64_t set_proposed_producers_ex(uint64_t packed_producer_format, legacy_span< const char > packed_producer_schedule)
void activate_feature(int64_t feature_name) const
void set_parameters_packed(span< const char > packed_parameters)
Set the blockchain parameters in a flexible manner.
void set_wasm_parameters_packed(span< const char > packed_parameters)
void set_blockchain_parameters_packed(legacy_span< const char > packed_blockchain_parameters)
uint32_t get_wasm_parameters_packed(span< char > packed_parameters, uint32_t max_version) const
void get_resource_limits(account_name account, legacy_ptr< int64_t, 8 > ram_bytes, legacy_ptr< int64_t, 8 > net_weight, legacy_ptr< int64_t, 8 > cpu_weight) const
uint32_t get_parameters_packed(span< const char > packed_parameter_ids, span< char > packed_parameters) const
Retrieve the blockchain config parameters.
void set_resource_limits(account_name account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight)
bool is_privileged(account_name account) const
void preactivate_feature(legacy_ptr< const digest_type > feature_digest)
int64_t set_proposed_producers(legacy_span< const char > packed_producer_schedule)
constexpr std::size_t size() const noexcept
constexpr T * data() const noexcept
void unpack(Stream &s, std::deque< T > &value)
void pack(Stream &s, const std::deque< T > &value)
size_t pack_size(const T &v)
int64_t set_proposed_producers_common(apply_context &context, vector< producer_authority > &&producers, bool validate_keys)
data_range< chain_config, config_entry_validator > config_range
@ disallow_empty_producer_schedule
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
schedule config_dir_name data_dir_name p2p_port http_port file_size name name keys peers producers(dont_start)) FC_REFLECT(testnet_def
unsigned __int64 uint64_t
Producer-voted blockchain configuration parameters.
v1 Producer-voted blockchain configuration parameters
Immutable except for fc::from_variant.