mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-27 15:28:03 +00:00
Upstream rewrote the wasm VM and host-function system (Rust `crates/` bridged via cxx), collapsed `transactions.macro` onto `TxSettings`, and moved invariant running from `ApplyContext` to `Transactor`. This merge resolves those conflicts and the breaks that carried no conflict marker. Conflict resolutions of note: - transactions.macro: took upstream's 5-argument `TxSettings` form and re-expressed our `emitable` column as `TxSettings::emittance`, a new scoped `Emittance` enum in TxSettings.h. `Emitable.cpp` and the transaction code generator read the new member. - sfields.macro: upstream claimed UINT32 75-80, so `sfParameterFlag` moves from 80 to 86. The amendment is not live, so no wire break. - HostFunc.h: took upstream's version, which drops `floatRoot`, and re-added the 15 contract virtuals. `setDataNestedObjectField`'s parameters are renamed to `(account, key, nestedKey, value)` to match the implementation; the wire order is unchanged. - WasmCommon.h: `SubmitTxnFailure` (-21) and `InvalidState` (-22) join upstream's enum and the Rust `host_errors!` table. `Success` is gone; the helpers that compared against it now return `expected<void, ...>`. - Transactor.cpp: kept the emitted-transaction pass, now using `checkInvariants(result, fee, InvariantScope::ProtocolOnly)`. Breaks with no conflict marker: - `Emitable.cpp` used the 8-argument TRANSACTION macro. - `STTx::getSeqValue` is gone; use `getSeqProxy().value()`. - `NetworkOPsImp::subLock_` is now `streamLock_`, held with `scoped_lock`. - The `LedgerEntryHelpers` namespace is now `ledger_entry_helpers`. - `keylet::vault` takes a `SeqProxy`. The three contract `ledger_entry` parsers were copy-pasted from the vault one and returned vault keylets; they now build contract, contract source and contract data keylets from their own fields. `contract_hash` is added to jss. The 15 contract host functions still register through the deleted C++ wrapper layer, so contract bytecode does not run yet. Porting them to the Rust-declared ABI is the next commit.
107 lines
4.2 KiB
C++
107 lines
4.2 KiB
C++
#pragma once
|
|
|
|
#include <xrpl/basics/base_uint.h>
|
|
#include <xrpl/basics/safe_cast.h>
|
|
|
|
#include <cstdint>
|
|
#include <type_traits>
|
|
|
|
namespace xrpl {
|
|
|
|
enum class Delegation { Delegable, NotDelegable };
|
|
|
|
/**
|
|
* Whether a smart contract may emit this transaction type.
|
|
*/
|
|
enum class Emittance { Emitable, NotEmitable };
|
|
|
|
/**
|
|
* Operations a transaction is permitted to perform, as a bitfield.
|
|
*
|
|
* These are declared per-transaction in transactions.macro (via
|
|
* TxSettings::privileges) and enforced in InvariantCheck.cpp.
|
|
*/
|
|
enum class Privilege : std::uint16_t {
|
|
NoPriv = 0x0000, // The transaction can not do any of the enumerated operations
|
|
CreateAcct = 0x0001, // The transaction can create a new ACCOUNT_ROOT object.
|
|
CreatePseudoAcct = 0x0002, // The transaction can create a pseudo account,
|
|
// which implies createAcct
|
|
MustDeleteAcct = 0x0004, // The transaction must delete an ACCOUNT_ROOT object
|
|
MayDeleteAcct = 0x0008, // The transaction may delete an ACCOUNT_ROOT
|
|
// object, but does not have to
|
|
OverrideFreeze = 0x0010, // The transaction can override some freeze rules
|
|
ChangeNftCounts = 0x0020, // The transaction can mint or burn an NFT
|
|
CreateMptIssuance = 0x0040, // The transaction can create a new MPT issuance
|
|
DestroyMptIssuance = 0x0080, // The transaction can destroy an MPT issuance
|
|
MustAuthorizeMpt = 0x0100, // The transaction MUST create or delete an MPT
|
|
// object (except by issuer)
|
|
MayAuthorizeMpt = 0x0200, // The transaction MAY create or delete an MPT
|
|
// object (except by issuer)
|
|
MayDeleteMpt = 0x0400, // The transaction MAY delete an MPT object. May not create.
|
|
MustModifyVault = 0x0800, // The transaction must modify, delete or create, a vault
|
|
MayModifyVault = 0x1000, // The transaction MAY modify, delete or create, a vault
|
|
MayCreateMpt = 0x2000, // The transaction MAY create an MPT object, except for issuer.
|
|
};
|
|
|
|
// The inner static_cast is not redundant: the underlying type is narrower than
|
|
// `int`, so the operands integer-promote and the result has to be narrowed back.
|
|
// safeCast rejects that narrowing, but every input bit is a Privilege bit by
|
|
// construction, so the result is always representable.
|
|
constexpr Privilege
|
|
operator|(Privilege lhs, Privilege rhs)
|
|
{
|
|
using Underlying = std::underlying_type_t<Privilege>;
|
|
return static_cast<Privilege>(
|
|
static_cast<Underlying>(safeCast<Underlying>(lhs) | safeCast<Underlying>(rhs)));
|
|
}
|
|
|
|
constexpr Privilege
|
|
operator&(Privilege lhs, Privilege rhs)
|
|
{
|
|
using Underlying = std::underlying_type_t<Privilege>;
|
|
return static_cast<Privilege>(
|
|
static_cast<Underlying>(safeCast<Underlying>(lhs) & safeCast<Underlying>(rhs)));
|
|
}
|
|
|
|
/**
|
|
* Per-transaction metadata declared in transactions.macro.
|
|
*
|
|
* Every member has a default, so a transaction only needs to name the settings
|
|
* that differ from the common case. See the documentation at the top of
|
|
* transactions.macro for the authoring syntax.
|
|
*
|
|
* This is deliberately not a constexpr-friendly type: amendment identifiers are
|
|
* runtime-initialized `extern uint256 const` globals (see Feature.h), so a
|
|
* TxSettings can only be built at runtime.
|
|
*/
|
|
struct TxSettings
|
|
{
|
|
/**
|
|
* Whether an account may delegate this transaction to another account.
|
|
*/
|
|
Delegation delegable{Delegation::NotDelegable};
|
|
|
|
/**
|
|
* The amendment gating this transaction, or uint256{} if always available.
|
|
*/
|
|
// The `{}` looks redundant, because BaseUInt's default constructor already
|
|
// zeroes the value. It is not: without a default member initializer here,
|
|
// every partial designated initializer in transactions.macro trips the
|
|
// missing-designated-field-initializers warning, which the build treats as
|
|
// an error.
|
|
// NOLINTNEXTLINE(readability-redundant-member-init)
|
|
uint256 amendment{};
|
|
|
|
/**
|
|
* Operations this transaction is permitted to perform.
|
|
*/
|
|
Privilege privileges{Privilege::NoPriv};
|
|
|
|
/**
|
|
* Whether a smart contract may emit this transaction type.
|
|
*/
|
|
Emittance emittance{Emittance::Emitable};
|
|
};
|
|
|
|
} // namespace xrpl
|