transaction

package
v1.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrencyLaunchNoncePoolSize          = 100
	CurrencyLaunchNonceMemoryAccountName = "nonce-0"

	CurrencyLaunchTimelockAccounts          = 500
	CurrencyLaunchTimelockMemoryAccountName = "timelock-0"

	// MemoryResizeStepSize is the most a single VM::ResizeMemory instruction
	// grows a memory account by, which is the runtime's per-instruction
	// realloc limit
	MemoryResizeStepSize = 10 * 1024

	// MaxInstructionTraceLength is the runtime's limit on a transaction's
	// instruction trace: its top-level instructions plus every CPI they make
	MaxInstructionTraceLength = 64
)
View Source
const (
	// CoinbaseSwapLoadedAccountsDataSizeLimit is the loaded accounts data size
	// limit for v1 transactions against the Coinbase Stable Swapper program.
	// The worst case loads about 1.23 MiB, dominated by program data.
	CoinbaseSwapLoadedAccountsDataSizeLimit = 4 * 1024 * 1024 // 4 MiB

	// ReserveSwapLoadedAccountsDataSizeLimit is the loaded accounts data size
	// limit for v1 reserve swap transactions on existing currencies. Program
	// data loads about 7.4 MiB, dominated by the 7.0 MB currency creator. A VM
	// memory account adds up to 4.9 MiB at the 65,535 timelock accounts the
	// server can index, for a worst case of about 12.2 MiB.
	ReserveSwapLoadedAccountsDataSizeLimit = 16 * 1024 * 1024 // 16 MiB

	// NewCurrencyLaunchLoadedAccountsDataSizeLimit is the loaded accounts data
	// size limit for v1 transactions that launch a new currency within its
	// first purchase. Program data loads about 8.1 MiB, dominated by the
	// 7.0 MB currency creator and 0.8 MB Metaplex programs. Accounts created by
	// the transaction, including the VM memory accounts, don't count.
	NewCurrencyLaunchLoadedAccountsDataSizeLimit = 16 * 1024 * 1024 // 16 MiB

	// InitNonceLoadedAccountsDataSizeLimit is the loaded accounts data size
	// limit for v1 transactions initializing virtual durable nonces. The VM
	// program data loads 488,621 bytes, and a nonce memory account holding
	// MaxInitNonceMemoryAccounts nonces adds 66,080 bytes.
	InitNonceLoadedAccountsDataSizeLimit = 1024 * 1024 // 1 MiB

	// MaxInitNonceMemoryAccounts is the largest nonce memory account, in
	// virtual durable nonces, that InitNonceLoadedAccountsDataSizeLimit is
	// sized for. Raise both together.
	MaxInitNonceMemoryAccounts = 1_000
)

Variables

View Source
var (
	ErrNoncePoolNotFound = errors.New("nonce pool not found")
	ErrNoAvailableNonces = errors.New("no available nonces")
	ErrNoncePoolClosed   = errors.New("nonce pool is closed")
)
View Source
var (
	ErrTransactionFailed = errors.New("transaction failed")
)

Functions

func CloseVmDepositComputeUnitLimit added in v1.22.0

func CloseVmDepositComputeUnitLimit() uint32

CloseVmDepositComputeUnitLimit computes the compute unit limit for a close_deposit_account_if_empty transaction.

func ExternalDepositComputeUnitLimit added in v1.22.0

func ExternalDepositComputeUnitLimit() uint32

ExternalDepositComputeUnitLimit computes the compute unit limit for a deposit_from_pda transaction sweeping an external deposit into the VM.

func GetAltForCoreMint added in v1.6.0

func GetAltForCoreMint() solana.AddressLookupTable

GetAltForCoreMint gets an address lookup table to operate in a versioned transaction that operates with the core mint

func GetAltForMint

func GetAltForMint(ctx context.Context, data ocp_data.Provider, mint *common.Account) (solana.AddressLookupTable, error)

GetAltForMint gets an address lookup table to operate in a versioned transaction for the provided mint

func GetCoinbaseSwapDestinationLiquidity added in v1.12.0

func GetCoinbaseSwapDestinationLiquidity(ctx context.Context, data ocp_data.Provider, toMint ed25519.PublicKey) (uint64, error)

GetCoinbaseSwapDestinationLiquidity returns the balance of the Coinbase Stable Swapper's token vault for the destination mint, which represents the available liquidity for swaps targeting that mint.

func GetDeltaQuarksFromTokenBalances

func GetDeltaQuarksFromTokenBalances(tokenAccount *common.Account, tokenBalances *solana.TransactionTokenBalances) (int64, error)

func GetInitialPurchaseTransactionVersion added in v1.30.0

func GetInitialPurchaseTransactionVersion(swapRecord *swap.Record) (solana.MessageVersion, error)

GetInitialPurchaseTransactionVersion returns the version of a currency's initial purchase transaction, which its swap record holds until the swap reaches a terminal state. The version decides how the currency is initialized and what its launch is charged.

func GetMetaplexMetadataAccount added in v1.30.0

func GetMetaplexMetadataAccount(mint *common.Account) (*common.Account, uint8, error)

GetMetaplexMetadataAccount returns the mint's Metaplex metadata account and its bump

func GetPostQuarksFromTokenBalances added in v1.2.0

func GetPostQuarksFromTokenBalances(tokenAccount *common.Account, tokenBalances *solana.TransactionTokenBalances) (uint64, bool, error)

GetPostQuarksFromTokenBalances returns the token account's balance after the transaction. It returns false when the account doesn't exist after the transaction.

func GetPreQuarksFromTokenBalances added in v1.30.0

func GetPreQuarksFromTokenBalances(tokenAccount *common.Account, tokenBalances *solana.TransactionTokenBalances) (uint64, bool, error)

GetPreQuarksFromTokenBalances returns the token account's balance before the transaction. It returns false when the account didn't exist before the transaction, such as when the transaction created it.

func InitNonceBatchComputeUnitLimit added in v1.30.0

func InitNonceBatchComputeUnitLimit(numNonces int) uint32

InitNonceBatchComputeUnitLimit computes the compute unit limit for a transaction initializing a batch of virtual durable nonces in a VM's nonce memory account.

func MakeCoinbaseSwapInstruction added in v1.11.0

func MakeCoinbaseSwapInstruction(
	version CoinbaseSwapVersion,
	accounts *CoinbaseSwapAccounts,
	user ed25519.PublicKey,
	fromMint, toMint ed25519.PublicKey,
	userFromTokenAccount, userToTokenAccount ed25519.PublicKey,
	amountIn, minAmountOut uint64,
) (solana.Instruction, error)

MakeCoinbaseSwapInstruction builds a CoinbaseStableSwapper swap instruction for the provided version.

func MakeCompressAccountTransaction

func MakeCompressAccountTransaction(
	nonce *Nonce,

	vmConfig *common.VmConfig,

	memory *common.Account,
	accountIndex uint16,

	storage *common.Account,

	virtualAccountState []byte,
) (solana.Transaction, error)

func MakeExternalTransferWithAuthorityTransaction

func MakeExternalTransferWithAuthorityTransaction(
	nonce *Nonce,

	vmConfig *common.VmConfig,

	virtualSignature solana.Signature,

	nonceMemory *common.Account,
	nonceIndex uint16,

	sourceMemory *common.Account,
	sourceIndex uint16,

	externalDestinationOwner *common.Account,
	externalDestination *common.Account,

	isCreateOnSend bool,
	mint *common.Account,
	quarks uint64,
) (solana.Transaction, error)

func MakeExternalWithdrawTransaction

func MakeExternalWithdrawTransaction(
	nonce *Nonce,

	vmConfig *common.VmConfig,

	virtualSignature solana.Signature,

	nonceMemory *common.Account,
	nonceIndex uint16,

	sourceMemory *common.Account,
	sourceIndex uint16,

	externalDestination *common.Account,
) (solana.Transaction, error)

func MakeInternalTransferWithAuthorityTransaction

func MakeInternalTransferWithAuthorityTransaction(
	nonce *Nonce,

	vmConfig *common.VmConfig,

	virtualSignature solana.Signature,

	nonceMemory *common.Account,
	nonceIndex uint16,

	sourceMemory *common.Account,
	sourceIndex uint16,

	destinationMemory *common.Account,
	destinationIndex uint16,

	quarks uint64,
) (solana.Transaction, error)

func MakeInternalWithdrawTransaction

func MakeInternalWithdrawTransaction(
	nonce *Nonce,

	vmConfig *common.VmConfig,

	virtualSignature solana.Signature,

	nonceMemory *common.Account,
	nonceIndex uint16,

	sourceMemory *common.Account,
	sourceIndex uint16,

	destinationMemory *common.Account,
	destinationIndex uint16,
) (solana.Transaction, error)

func MakeNoncedTransaction

func MakeNoncedTransaction(nonce *Nonce, instructions ...solana.Instruction) (solana.Transaction, error)

MakeNoncedTransaction makes a transaction that's backed by a nonce. The returned transaction is not signed.

func MakeOpenAccountTransaction

func MakeOpenAccountTransaction(
	nonce *Nonce,

	vmConfig *common.VmConfig,

	memory *common.Account,
	accountIndex uint16,

	timelockAccounts *common.TimelockAccounts,
) (solana.Transaction, error)

func MakeSolanaTransferTransaction added in v1.0.0

func MakeSolanaTransferTransaction(
	payer, source, destination *common.Account,
	lamports uint64,
	bh solana.Blockhash,
) (solana.Transaction, error)

func MemoryCapacity added in v1.30.0

func MemoryCapacity(numAccounts uint32, accountSize uint16) uint32

MemoryCapacity returns the size of a memory account holding numAccounts virtual accounts of accountSize bytes at full capacity

func MemoryResizeSizes added in v1.30.0

func MemoryResizeSizes(numAccounts uint32, accountSize uint16) []uint32

MemoryResizeSizes returns the account sizes passed to successive VM::ResizeMemory instructions to grow a memory account holding numAccounts virtual accounts of accountSize bytes to its full capacity

func NewCurrencyLaunchComputeUnitLimit added in v1.30.0

func NewCurrencyLaunchComputeUnitLimit(args *NewCurrencyLaunchComputeUnitArgs) uint32

NewCurrencyLaunchComputeUnitLimit computes the compute unit limit for a v1 create-and-buy transaction, which initializes the currency, pool, VM, metadata and memory accounts alongside the first purchase, and resizes the memory accounts to full capacity

func NewInitializeMetadataInstruction added in v1.30.0

func NewInitializeMetadataInstruction(authority, mint, currencyConfig, metaplexMetadata *common.Account) solana.Instruction

NewInitializeMetadataInstruction makes the Reserve::InitializeMetadata instruction, paid for by the currency authority

func NewResizeMemoryInstructions added in v1.30.0

func NewResizeMemoryInstructions(vmAuthority, vmAccount, memoryAccount *common.Account, sizes []uint32) []solana.Instruction

NewResizeMemoryInstructions makes a VM::ResizeMemory instruction for each size, paid for by the VM authority

func NewV1TransactionConfig added in v1.30.0

func NewV1TransactionConfig(computeUnitLimit uint32, computeUnitPrice uint64, loadedAccountsDataSizeLimit uint32) solana.TransactionConfig

NewV1TransactionConfig converts a legacy compute budget into a v1 transaction config. The priority fee is what ComputeBudget::SetComputeUnitPrice charges a legacy or v0 transaction with the same limit and price, so a swap costs the same in either version. The heap size is left at the runtime default.

func PriorityFeeLamports added in v1.30.0

func PriorityFeeLamports(computeUnitLimit uint32, computeUnitPrice uint64) uint64

PriorityFeeLamports returns the total priority fee for a compute unit limit and price in micro-lamports per compute unit, rounded up and saturating like the runtime's legacy prioritization fee.

func ReserveBuySellSwapComputeUnitLimit added in v1.22.0

func ReserveBuySellSwapComputeUnitLimit(temporaryCoreAtaBump, temporarySourceAtaBump uint8) uint32

ReserveBuySellSwapComputeUnitLimit computes the compute unit limit for a reserve buy/sell swap transaction, which creates temporary ATAs for both the core mint and the source currency.

func ReserveBuySwapComputeUnitLimit added in v1.22.0

func ReserveBuySwapComputeUnitLimit(temporaryAtaBump uint8) uint32

ReserveBuySwapComputeUnitLimit computes the compute unit limit for a reserve buy swap transaction, whose only bump-dependent cost is creating the temporary core mint ATA.

func ReserveBuyWithFeeSwapComputeUnitLimit added in v1.23.0

func ReserveBuyWithFeeSwapComputeUnitLimit(temporaryAtaBump uint8) uint32

ReserveBuyWithFeeSwapComputeUnitLimit computes the compute unit limit for a reserve buy swap transaction that also collects a buy fee, whose only bump-dependent cost is creating the temporary core mint ATA.

func ReserveSellSwapComputeUnitLimit added in v1.22.0

func ReserveSellSwapComputeUnitLimit(temporaryAtaBump uint8) uint32

ReserveSellSwapComputeUnitLimit computes the compute unit limit for a reserve sell swap transaction, whose only bump-dependent cost is creating the temporary source currency ATA.

func SubmitAndWaitForFinalization added in v1.0.0

func SubmitAndWaitForFinalization(ctx context.Context, data ocp_data.BlockchainData, txn *solana.Transaction) error

SubmitAndWaitForFinalization submits a signed transaction and polls until it reaches finalized commitment. An error is returned if the transaction fails on chain or the context is cancelled.

func ToProtoAlts added in v1.6.0

func ToProtoTransactionConfig added in v1.30.0

func ToProtoTransactionConfig(config solana.TransactionConfig) *commonpb.SolanaTransactionConfig

ToProtoTransactionConfig converts a v1 transaction config into its proto form. Unset fields are 0, which clients treat as omitted only for the heap size.

func UpdateNonceSignature

func UpdateNonceSignature(ctx context.Context, data ocp_data.Provider, address, prevSig, newSig string) error

UpdateNonceSignature safely transitions a nonce's signature to a new value

func ValidateInitNonceMemoryAccounts added in v1.30.0

func ValidateInitNonceMemoryAccounts(numAccounts uint32) error

ValidateInitNonceMemoryAccounts errors when a nonce memory account holds more nonces than InitNonceLoadedAccountsDataSizeLimit is sized for, so a larger nonce pool can't ship without revisiting the limit.

func WithComputeUnitMargin added in v1.22.0

func WithComputeUnitMargin(computeUnits uint32) uint32

WithComputeUnitMargin pads a measured or modeled compute unit count by the standard safety margin.

Types

type CoinbaseSwapAccounts added in v1.11.0

type CoinbaseSwapAccounts struct {
	Pool                     ed25519.PublicKey
	InVault                  ed25519.PublicKey
	OutVault                 ed25519.PublicKey
	InVaultTokenAccount      ed25519.PublicKey
	OutVaultTokenAccount     ed25519.PublicKey
	Whitelist                ed25519.PublicKey
	FeeRecipient             ed25519.PublicKey
	FeeRecipientTokenAccount ed25519.PublicKey
}

CoinbaseSwapAccounts captures all derived PDAs and on-chain values needed to build a CoinbaseStableSwapper swap instruction for a (fromMint, toMint) pair. FeeRecipient is sourced from the on-chain LiquidityPool account. Whitelist is only used by CoinbaseSwapV1.

func GetCoinbaseSwapAccounts added in v1.11.0

func GetCoinbaseSwapAccounts(ctx context.Context, data ocp_data.Provider, fromMint, toMint ed25519.PublicKey) (*CoinbaseSwapAccounts, error)

GetCoinbaseSwapAccounts derives all PDAs and reads the on-chain pool account to resolve the fee recipient and its from-mint ATA.

type CoinbaseSwapVersion added in v1.29.0

type CoinbaseSwapVersion uint8

CoinbaseSwapVersion selects the CoinbaseStableSwapper swap instruction. Clients build and sign swap transactions locally, so the server must build the same version as the client.

const (
	CoinbaseSwapV1 CoinbaseSwapVersion = iota + 1 // swap, with the deprecated whitelist account
	CoinbaseSwapV2                                // swap_v2
)

func (CoinbaseSwapVersion) String added in v1.29.0

func (v CoinbaseSwapVersion) String() string

type CurrencyLaunch added in v1.30.0

type CurrencyLaunch struct {
	Name     string
	Symbol   string
	Accounts *common.LaunchpadCurrencyAccounts

	VmConfig    *common.VmConfig
	VmBump      uint8
	OmnibusBump uint8

	MetaplexMetadata     *common.Account
	MetaplexMetadataBump uint8

	MemoryAccounts  []*CurrencyLaunchMemoryAccount
	FeeAccountOwner *common.Account
}

CurrencyLaunch builds the instructions that launch a new currency within its first purchase transaction. The currency authority pays for, and signs, every account it initializes.

func NewCurrencyLaunch added in v1.30.0

func NewCurrencyLaunch(metadataRecord *currency.MetadataRecord, vmMetadataRecord *vm_metadata.Record) (*CurrencyLaunch, error)

NewCurrencyLaunch derives the accounts a launch initializes for the currency

func (*CurrencyLaunch) ComputeUnitLimit added in v1.30.0

func (l *CurrencyLaunch) ComputeUnitLimit(ataBumps []uint8, isTreasuryFunded bool) uint32

ComputeUnitLimit computes the compute unit limit for a launch transaction that creates ATAs with the given bumps

func (*CurrencyLaunch) InstructionTraceLength added in v1.30.0

func (l *CurrencyLaunch) InstructionTraceLength(isTreasuryFunded bool) int

InstructionTraceLength returns the worst-case instruction trace length of a launch transaction, where every account the transaction opens is new

func (*CurrencyLaunch) MakeCreateAtaInstruction added in v1.30.0

func (l *CurrencyLaunch) MakeCreateAtaInstruction(owner, mint *common.Account) (solana.Instruction, ed25519.PublicKey, uint8, error)

MakeCreateAtaInstruction makes an AssociatedTokenAccount::CreateIdempotent instruction paid for by the currency authority, and returns the ATA and its bump

func (*CurrencyLaunch) MakeInitInstructions added in v1.30.0

func (l *CurrencyLaunch) MakeInitInstructions() []solana.Instruction

MakeInitInstructions makes the Reserve::InitializeCurrency, Reserve::InitializePool and VM::InitializeVm instructions

func (*CurrencyLaunch) MakePostPurchaseInstructions added in v1.30.0

func (l *CurrencyLaunch) MakePostPurchaseInstructions() ([]solana.Instruction, uint8, error)

MakePostPurchaseInstructions makes the instructions that follow the purchase: Reserve::InitializeMetadata, VM::InitMemory for each memory account, the fee account's creation, a System::Transfer of each memory account's rent top-up, then the VM::ResizeMemory instructions growing each memory account to full capacity. It returns the fee account's bump.

The rent top-ups pre-fund the resizes, so VM::ResizeMemory doesn't transfer rent with a CPI. That keeps the transaction's instruction trace within MaxInstructionTraceLength.

func (*CurrencyLaunch) SetMemoryAccountRentTopUps added in v1.30.0

func (l *CurrencyLaunch) SetMemoryAccountRentTopUps(ctx context.Context, getMinimumBalanceForRentExemption func(ctx context.Context, size uint64) (uint64, error)) error

SetMemoryAccountRentTopUps sets each memory account's rent top-up to the rent for its full capacity beyond what VM::InitMemory pays. Rent is read rather than computed because the network's rent rate can change.

func (*CurrencyLaunch) TransactionConfig added in v1.30.0

func (l *CurrencyLaunch) TransactionConfig(computeUnitLimit uint32, computeUnitPrice uint64) solana.TransactionConfig

TransactionConfig returns the v1 transaction config for a launch transaction

func (*CurrencyLaunch) ValidateInstructionTraceLength added in v1.30.0

func (l *CurrencyLaunch) ValidateInstructionTraceLength(isTreasuryFunded bool) error

ValidateInstructionTraceLength errors when a launch transaction's worst-case instruction trace exceeds MaxInstructionTraceLength

type CurrencyLaunchMemoryAccount added in v1.30.0

type CurrencyLaunchMemoryAccount struct {
	Address     *common.Account
	Bump        uint8
	Name        string
	NumAccounts uint32
	AccountSize uint16

	RentTopUpLamports uint64
}

CurrencyLaunchMemoryAccount is a VM memory account and the arguments it's initialized with

func GetCurrencyLaunchMemoryAccounts added in v1.30.0

func GetCurrencyLaunchMemoryAccounts(vmAccount *common.Account) ([]*CurrencyLaunchMemoryAccount, error)

GetCurrencyLaunchMemoryAccounts returns the memory accounts a new currency's VM is launched with, in initialization order: durable nonces, then timelocks

func (*CurrencyLaunchMemoryAccount) Capacity added in v1.30.0

func (m *CurrencyLaunchMemoryAccount) Capacity() uint32

Capacity returns the memory account's size at full capacity

func (*CurrencyLaunchMemoryAccount) NewInitMemoryInstruction added in v1.30.0

func (m *CurrencyLaunchMemoryAccount) NewInitMemoryInstruction(vmAuthority, vmAccount *common.Account) solana.Instruction

NewInitMemoryInstruction makes the VM::InitMemory instruction for the memory account, paid for by the VM authority

func (*CurrencyLaunchMemoryAccount) NewRentTopUpInstruction added in v1.30.0

func (m *CurrencyLaunchMemoryAccount) NewRentTopUpInstruction(vmAuthority *common.Account) solana.Instruction

NewRentTopUpInstruction makes the System::Transfer of the memory account's rent top-up from the VM authority

func (*CurrencyLaunchMemoryAccount) NewResizeMemoryInstructions added in v1.30.0

func (m *CurrencyLaunchMemoryAccount) NewResizeMemoryInstructions(vmAuthority, vmAccount *common.Account) []solana.Instruction

NewResizeMemoryInstructions makes the VM::ResizeMemory instructions that grow the memory account to its full capacity, paid for by the VM authority

func (*CurrencyLaunchMemoryAccount) ResizeSizes added in v1.30.0

func (m *CurrencyLaunchMemoryAccount) ResizeSizes() []uint32

ResizeSizes returns the account sizes passed to successive VM::ResizeMemory instructions to grow the memory account to its full capacity

type LocalNoncePool

type LocalNoncePool struct {
	// contains filtered or unexported fields
}

LocalNoncePool is a pool of nonces that are cached in memory for quick access. The LocalNoncePool will continually monitor the pool to ensure sufficient size, as well refresh nonce expiration times.

If the pool empties before it can be refilled, ErrNoAvailableNonces will be returned. Therefore, the pool should be sufficiently large such that the consumption of poolSize/2 nonces is _slower_ than the operation to top up the pool.

func NewLocalNoncePool

func NewLocalNoncePool(
	log *zap.Logger,
	data ocp_data.Provider,
	metricsProvider metrics.Provider,
	env nonce.Environment,
	envInstance string,
	poolType nonce.Purpose,
	opts ...NoncePoolOption,
) (*LocalNoncePool, error)

func SelectNoncePool

func SelectNoncePool(env nonce.Environment, envInstance string, poolType nonce.Purpose, pools ...*LocalNoncePool) (*LocalNoncePool, error)

SelectNoncePool selects a nonce pool from the provided set that matches the desired environment and pool type.

ErrNoncePoolNotFound is returned if no nonce pool matches the desired config.

func (*LocalNoncePool) Close

func (np *LocalNoncePool) Close() error

func (*LocalNoncePool) GetNonce

func (np *LocalNoncePool) GetNonce(ctx context.Context) (*Nonce, error)

func (*LocalNoncePool) Validate

func (np *LocalNoncePool) Validate(
	env nonce.Environment,
	envInstance string,
	poolType nonce.Purpose,
) error

type MergedMemoryBankResult

type MergedMemoryBankResult struct {
	A       *ed25519.PublicKey
	B       *ed25519.PublicKey
	C       *ed25519.PublicKey
	D       *ed25519.PublicKey
	Indices []uint8
}

func MergeMemoryBanks

func MergeMemoryBanks(accounts ...*common.Account) (*MergedMemoryBankResult, error)

func (*MergedMemoryBankResult) NumBanks added in v1.22.0

func (r *MergedMemoryBankResult) NumBanks() int

type NewCurrencyLaunchComputeUnitArgs added in v1.30.0

type NewCurrencyLaunchComputeUnitArgs struct {
	MintBump             uint8
	CurrencyConfigBump   uint8
	LiquidityPoolBump    uint8
	VaultMintBump        uint8
	VaultBaseBump        uint8
	VmBump               uint8
	OmnibusBump          uint8
	MetaplexMetadataBump uint8

	// One per VM::InitMemory instruction
	MemoryAccountBumps []uint8

	// One per AssociatedTokenAccount::CreateIdempotent instruction
	AtaBumps []uint8

	// System::Transfer rent top-ups and the VM::ResizeMemory instructions
	// they pre-fund
	NumRentTopUps    int
	NumMemoryResizes int

	// Treasury-funded launches sell the source currency and buy with the
	// treasury's core mint. Core mint funded launches buy directly and close
	// the temporary core mint ATA.
	IsTreasuryFunded bool
}

NewCurrencyLaunchComputeUnitArgs are the bumps and counts that determine the compute units of a v1 transaction that launches a new currency within its first purchase

type Nonce

type Nonce struct {
	Account   *common.Account
	Blockhash solana.Blockhash
	// contains filtered or unexported fields
}

Nonce represents a handle to a nonce that is owned by a local nonce pool, or claimed directly from the database via GetNonce.

func GetNonce added in v0.34.0

func GetNonce(
	ctx context.Context,
	data ocp_data.Provider,
	env nonce.Environment,
	envInstance string,
	purpose nonce.Purpose,
	nodeID string,
	timeout time.Duration,
) (*Nonce, error)

GetNonce claims a single nonce directly from the database. This is intended for use when a LocalNoncePool doesn't exist for the desired environment and purpose.

func (*Nonce) MarkReservedWithSignature

func (n *Nonce) MarkReservedWithSignature(ctx context.Context, sig string) error

MarkReservedWithSignature marks the nonce as reserved with a signature

func (*Nonce) ReleaseIfNotReserved

func (n *Nonce) ReleaseIfNotReserved(ctx context.Context)

ReleaseIfNotReserved releases the nonce back to the pool if the nonce has not yet been reserved (or more specifically, is still owned by the pool).

type NoncePoolOption

type NoncePoolOption func(*noncePoolOpts)

NoncePoolOption configures a nonce pool.

func WithNoncePoolMaxExpiration

func WithNoncePoolMaxExpiration(d time.Duration) NoncePoolOption

WithNoncePoolMaxExpiration configures the upper bound for the expiration window of claimed nonces.

func WithNoncePoolMinExpiration

func WithNoncePoolMinExpiration(d time.Duration) NoncePoolOption

WithNoncePoolMinExpiration configures the lower bound for the expiration window of claimed nonces.

func WithNoncePoolNodeID

func WithNoncePoolNodeID(id string) NoncePoolOption

WithNoncePoolNodeID configures the node id to use when claiming nonces.

func WithNoncePoolRefreshInterval

func WithNoncePoolRefreshInterval(interval time.Duration) NoncePoolOption

WithNoncePoolRefreshInterval specifies how often the pool should be scanning it's free list for refresh candidates. Candidates are claimed nonces whose expiration is <= 2/3 of the min expiration.

func WithNoncePoolRefreshPoolInterval

func WithNoncePoolRefreshPoolInterval(interval time.Duration) NoncePoolOption

WithNoncePoolRefreshPoolInterval configures the pool to refresh the set of nonces at this duration. If the pool size is 1/2 the desired size, nonces will be fetched from DB. This condition is also checked (asynchronously) every time a nonce is pulled from the pool.

func WithNoncePoolShutdownGracePeriod

func WithNoncePoolShutdownGracePeriod(duration time.Duration) NoncePoolOption

WithNoncePoolShutdownGracePeriod configures the amount of time given for cleanup on call to Close().

func WithNoncePoolSize

func WithNoncePoolSize(size int) NoncePoolOption

WithNoncePoolSize configures the desired size of the pool.

The pool will use this size to determine how much to load when the pool starts up, or when the pool gets low. It can be viewed as 'target memory' in a GC, with the actual pool size behaving like a saw-tooth graph.

The pool does not have any mechanism to shrink the pool to this size beyond the natural consumption of nonces.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL