Skip to main content

Module iota::transaction_deny_rules

This module holds the consensus-governed transaction deny rules: the stake-weighted aggregate of the validators' deny rule proposals, mirrored on-chain by TransactionDenyRulesUpdate system transactions carrying add/remove deltas.

use iota::address; use iota::dynamic_field; use iota::event; use iota::hex; use iota::linked_table; use iota::object; use iota::transfer; use iota::tx_context; use iota::versioned; use std::ascii; use std::bcs; use std::option; use std::string; use std::vector;

Module Functions

prv apply_delta

Remove removed from list, then add added. Both are tolerant — keys already absent or already present are skipped — so a system transaction can never abort here and re-applying a delta is a no-op.

fun apply_delta<Key: copy, drop, store>(list: &mut iota::linked_table::LinkedTable<Key, bool>, added: &vector, removed: &vector)

Implementation

fun apply_delta<Key: copy + drop + store>(     list: &mut LinkedTable<Key, bool>,     added: &vector,     removed: &vector, ) {     let mut i = 0;     while (i < removed.length()) {         let key = removed[i];         if (list.contains(key)) {             list.remove(key);         };         i = i + 1;     };     let mut i = 0;     while (i < added.length()) {         let key = added[i];         if (!list.contains(key)) {             list.push_back(key, true);         };         i = i + 1;     }; }

prv create

Create and share the TransactionDenyRules object with no rules active. This function is called exactly once, by the TransactionDenyRulesCreate end-of-epoch transaction that first creates the object.

fun create(ctx: &mut iota::tx_context::TxContext)

Implementation

fun create(ctx: &mut TxContext) {     assert!(ctx.sender() == @0x0, ENotSystemAddress);     let version = CURRENT_VERSION;     let inner = TransactionDenyRulesInnerV1 {         version,         denied_addresses: linked_table::new(ctx),         denied_objects: linked_table::new(ctx),         denied_packages: linked_table::new(ctx),         package_publish_disabled: false,         package_upgrade_disabled: false,         shared_object_disabled: false,         user_transaction_disabled: false,         receiving_objects_disabled: false,         move_authenticator_disabled: false,     };     let self = TransactionDenyRules {         id: object::transaction_deny_rules(),         inner: versioned::create(version, inner, ctx),     };     transfer::share_object(self); }

Structs

struct TransactionDenyRules

Singleton shared object which stores the active transaction deny rules. The actual state is stored in a versioned inner field.

public struct TransactionDenyRules has key

Fields

prv load_inner_mut

fun load_inner_mut(self: &mut iota::transaction_deny_rules::TransactionDenyRules): &mut iota::transaction_deny_rules::TransactionDenyRulesInnerV1

Implementation

fun load_inner_mut(self: &mut TransactionDenyRules): &mut TransactionDenyRulesInnerV1 {     let version = self.inner.version();     // Replace this with a lazy update function when we add a new version of the inner object.     assert!(version == CURRENT_VERSION, EWrongInnerVersion);     let inner: &mut TransactionDenyRulesInnerV1 = self.inner.load_value_mut();     assert!(inner.version == version, EWrongInnerVersion);     inner }

prv update

Apply an add/remove delta to the deny lists and set the switch states. Called when executing a TransactionDenyRulesUpdate system transaction; a large delta arrives split across several such transactions.

fun update(self: &mut iota::transaction_deny_rules::TransactionDenyRules, added_addresses: vector<address>, removed_addresses: vector<address>, added_objects: vector<iota::object::ID>, removed_objects: vector<iota::object::ID>, added_packages: vector<iota::object::ID>, removed_packages: vector<iota::object::ID>, package_publish_disabled: bool, package_upgrade_disabled: bool, shared_object_disabled: bool, user_transaction_disabled: bool, receiving_objects_disabled: bool, move_authenticator_disabled: bool, ctx: &iota::tx_context::TxContext)

Implementation

fun update(     self: &mut TransactionDenyRules,     added_addresses: vector<address>,     removed_addresses: vector<address>,     added_objects: vector<ID>,     removed_objects: vector<ID>,     added_packages: vector<ID>,     removed_packages: vector<ID>,     package_publish_disabled: bool,     package_upgrade_disabled: bool,     shared_object_disabled: bool,     user_transaction_disabled: bool,     receiving_objects_disabled: bool,     move_authenticator_disabled: bool,     ctx: &TxContext, ) {     // Validator will make a special system call with sender set as 0x0.     assert!(ctx.sender() == @0x0, ENotSystemAddress);     let inner = self.load_inner_mut();     apply_delta(&mut inner.denied_addresses, &added_addresses, &removed_addresses);     apply_delta(&mut inner.denied_objects, &added_objects, &removed_objects);     apply_delta(&mut inner.denied_packages, &added_packages, &removed_packages);     inner.package_publish_disabled = package_publish_disabled;     inner.package_upgrade_disabled = package_upgrade_disabled;     inner.shared_object_disabled = shared_object_disabled;     inner.user_transaction_disabled = user_transaction_disabled;     inner.receiving_objects_disabled = receiving_objects_disabled;     inner.move_authenticator_disabled = move_authenticator_disabled;     event::emit(TransactionDenyRulesUpdated {         epoch: ctx.epoch(),         added_addresses,         removed_addresses,         added_objects,         removed_objects,         added_packages,         removed_packages,         package_publish_disabled,         package_upgrade_disabled,         shared_object_disabled,         user_transaction_disabled,         receiving_objects_disabled,         move_authenticator_disabled,         denied_addresses_len: inner.denied_addresses.length(),         denied_objects_len: inner.denied_objects.length(),         denied_packages_len: inner.denied_packages.length(),     }); }

struct TransactionDenyRulesInnerV1

The deny lists are LinkedTable membership sets (the bool value is always true and never read): each entry is its own child object, so capacity is not bounded by the size of a single Move object, and updates add and remove entries without touching the rest. The linked keys let any reader enumerate the full set by walking frontnext with plain child-object reads, without a dynamic-field index — a plain Table cannot be read back whole by a party that does not already know the keys.

public struct TransactionDenyRulesInnerV1 has store

Fields
version: u64
denied_addresses: iota::linked_table::LinkedTable<address, bool>

Addresses denied as transaction sender or gas sponsor.

denied_objects: iota::linked_table::LinkedTable<iota::object::ID, bool>

Objects denied as transaction inputs or receiving objects.

denied_packages: iota::linked_table::LinkedTable<iota::object::ID, bool>

Packages denied as a (transitive) dependency of any command.

package_publish_disabled: bool

Denies all package publishing.

package_upgrade_disabled: bool

Denies all package upgrades.

shared_object_disabled: bool

Denies transactions that use shared objects as inputs.

user_transaction_disabled: bool

Denies all user transactions (kill switch).

receiving_objects_disabled: bool

Denies transactions that contain receiving objects.

move_authenticator_disabled: bool

Denies transactions signed with a Move authenticator.

struct TransactionDenyRulesUpdated

Emitted on every update; the event stream is the audit history of the network's deny rules. Carries the delta the update transaction requested (tolerated no-ops included), the resulting switch states, and the post-update size of each deny list.

public struct TransactionDenyRulesUpdated has copy, drop

Fields
epoch: u64

The epoch in which the update was executed.

added_addresses: vector<address>

Addresses added to / removed from the sender-or-sponsor deny list.

removed_addresses: vector<address>
added_objects: vector<iota::object::ID>

Objects added to / removed from the input-or-receiving deny list.

removed_objects: vector<iota::object::ID>
added_packages: vector<iota::object::ID>

Packages added to / removed from the dependency deny list.

removed_packages: vector<iota::object::ID>
package_publish_disabled: bool

Denies all package publishing.

package_upgrade_disabled: bool

Denies all package upgrades.

shared_object_disabled: bool

Denies transactions that use shared objects as inputs.

user_transaction_disabled: bool

Denies all user transactions (kill switch).

receiving_objects_disabled: bool

Denies transactions that contain receiving objects.

move_authenticator_disabled: bool

Denies transactions signed with a Move authenticator.

denied_addresses_len: u64

Deny list sizes after applying the delta.

denied_objects_len: u64
denied_packages_len: u64

Constants

err ENotSystemAddress

Sender is not @0x0 the system address.

const ENotSystemAddress: u64 = 0;

err EWrongInnerVersion

const EWrongInnerVersion: u64 = 1;

const CURRENT_VERSION

const CURRENT_VERSION: u64 = 1;