sink

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Sink

Sink escrows native AKT for minting on Solana. A deposit creates an immutable proof record and an explicit settlement. Mint confirmation keeps the backing in escrow. A refund pays the original Akash owner after authorization, a challenge interval, and queue and amount checks.

Authority and bank accounting

handler.NewServer rejects nil messages, calls SDK ValidateBasic, and checks caller authorization for restricted commands before invoking a keeper command. Keeper commands accept validated messages and enforce state, account-kind, balance, and settlement rules within one cache. Their bank changes, records, counters, indexes, allocation, and events commit together.

The ante decorator records the exact sole top-level MsgSink request. Deposit matches the sender, destination type, destination, denomination, and amount against that private marker. It also requires an ordinary account with a public key. Nested authz and contract calls receive no matching request marker.

Sink remains in the bank's BlockedAddrs. Public bank send and multisend handlers reject that recipient, including bank messages dispatched through authz or contracts. Wasm attached-fund transfers also check blocked recipients. Sink registers no additional bank send restriction. Its deposit, refund, and pre-installation sweep use the bank's privileged module helpers after their own validation. Calling those helpers directly is trusted module code, not a public transaction route.

After a bank deposit, the keeper verifies exact escrow backing. After a refund, it verifies both escrow backing and the original owner's balance increase. A bank error or redirected deposit or refund cannot leave successful Sink state. Installation retains its cached sweep, empty-balance check, and cleanup of withdrawal addresses that pointed at Sink before it became blocked.

Totals contain one amount and count for each financial status:

  • TRANSFER_PENDING has no mint or refund authorization.
  • MINTED retains the backing in escrow.
  • VOIDED retains a governance order awaiting Solana confirmation.
  • REFUND_PENDING has authorization and a challenge deadline, but has not paid.
  • REFUNDED records a paid refund and sits outside escrow.

Holds do not change these populations. The module's complete bank balance must equal pending, minted, voided, and refund-pending amounts in uakt, with no other denominations. A new governance void order moves a pending attempt to VOIDED; it never authorizes payment. Totals contain only five Coin/uint64 count pairs. The flat totals event additionally includes normalized refund consumption for the current native epoch.

Reports and governance

Reporter policies are immutable history. A separate current-policy item selects the active version; reads load only referenced policies. The quorum is the ceiling of reporters_threshold * member_count, computed with exact decimals, and must exceed two thirds of the members. SDK ValidateBasic does not apply that rule, so SetParams rejects a failing set before storing anything: settlement writes revalidate the policy they embed, export revalidates every stored policy, and a stored policy can never be removed. A membership or ratio change increments the version. Reordering members does not. Members must be distinct accounts: duplicates are found by decoded address, because bech32 also accepts the upper-case spelling of an address. SetParams also rejects a module-account member in either spelling but allows an address with no account yet; genesis import does not apply this check, so a module account imported through genesis makes every later MsgUpdateParams that keeps it fail. Membership checks compare the listed spelling, so a member listed in upper case must name that spelling in its messages, and changing only a member's spelling increments the version. The shipped reporter accepts only a lowercase 20-byte akash address, so a member that runs it must be listed in that form.

Reports require current membership, current policy version, and exact settlement round. Votes retain their own policy version. An active attempt accepts one vote per reporter for its first outcome. At quorum the certificate freezes. At most one opposite witness is retained; conflict freezes further reports. Same-outcome reports cannot grow a completed certificate. Evidence validation checks signature and slot format; it does not establish Solana truth or finality.

A current report refreshes an unheld unpaid reporter attempt after rotation: replace the embedded policy, clear stale attempt votes and the deadline, and return to transfer-pending or voided according to its permanent order. Old-policy reports fail before clearing. Held, minted, refunded, and governance-authorized refund-pending settlements retain their authorization and evidence. New-policy reports can add an opposite witness without erasing the retained certificate.

RequestVoid requires a matching expected_round for a new order. An authenticated retry preserves the original receipt without changing the round. The receipt stores request height and round and survives every subsequent transition. RestartTransfer, ConfirmMint, and ConfirmVoid require expected_round, then advance the round. Restart applies only before payment or mint confirmation. Confirm-mint never reverses a paid refund. Confirm-void requires an immutable void order for unpaid transfers or conflict-held minted transfers. Those transfers must fit the refund cap. Accepting conflict-held minted transfers here, and in RequestVoid, is a known defect: AEP-95 treats Minted as final. Confirm-void on an already-refunded transfer resolves the dispute without another payment or a new order. Confirmations replace votes and holds with governance evidence.

A reporter can veto a refund before its deadline. Governance can veto before payment. Conflict takes precedence over veto. Changing policy preserves the veto signer, reason, and its membership version. A zero veto version means governance; import and writes authenticate the configured authority.

Limits and refund order

Send and refund usage read CurrentEpoch from the existing x/epochs record named day. Sink owns no timer or epoch hooks. The schedule's duration and start belong to epochs genesis and can differ from a UTC day. After counting starts, the native timer advances only strictly after the current endpoint, once per block. Downtime can therefore produce successive allowance resets across recovery blocks; unused allowances do not accumulate.

Deposits charge lifetime account usage, account epoch usage, and global send epoch usage. Refunds never restore sending capacity. Queries project stale usage to the native number at the queried height without writes; export preserves raw stamps. Missing or malformed native state fails. Valid unstarted schedules expose epoch zero, while deposits and refund payments reject it. Future stamps and positive epoch-zero consumption fail. Epochs initializes before Sink and already runs first in BeginBlock. Sink still resets its independent per-block sequence in BeginBlock.

The challenge Duration remains independent. Its integer Unix-second deadline is the checked ceiling of block time plus Duration, including fractional carry. Authorization receives the full interval even just before a quota boundary, and existing deadlines survive parameter changes. Immediate Solana mints and their separate amount caps remain unchanged.

The account epoch cap may be zero to disable that limit; account usage is still tracked. The other caps are positive uakt Coins; the uakt minimum must be positive while deposits are enabled. Only individual transfer amounts must fit uint64. There are no account count quotas. Changing a cap preserves consumption, including when an account cap is re-enabled. Lowering the refund cap scans unpaid transfers and rejects a cap that strands one. Existing challenge deadlines remain unchanged when the challenge parameter changes.

Refund queue keys contain authorization scope, challenge deadline, and ID. Scope zero is governance; a nonzero scope is a reporter policy version. Payment selects the oldest entry across governance and the current policy. Old reporter scopes cannot block current refunds. Queue membership alone does not imply maturity, remaining epoch capacity, or enabled refunds.

The destination vault allowlist exempts configured Solana recipients from the curve check. It does not bypass amount, authorization, or accounting rules.

Identity, storage, and queries

A transfer ID is owner/height/sequence, with any owner sdk.AccAddressFromBech32 accepts (1 to 255 bytes, all-zero bytes included) and positive height and sequence. A transient allocator issues 1 first and increments globally within each block. BeginBlocker resets it to zero. Failed deposits roll back allocation. Simulation uses the proposed next block height because committed state has already cleared its transient allocator; BaseApp discards the simulated writes.

Node owns the native codec fixtures and generates them with its production codecs. Transfer keys are 02 00 || u8(len(owner)) || owner || BE64(height) || BE64(sequence) (19 + len(owner) bytes); values are native protobuf RecordData, including the recipient and SDK Coin. Canonical settlement keys are 03 01 || status || u8(len(owner)) || owner || BE64(height) || BE64(sequence) (20 + len(owner) bytes); values are native protobuf SettlementData. Status exists only in the settlement key. Its permanent tag-9 void authorization is the sealing receipt. Both maps use codec.CollValue. Proof nonces are the full SHA-256 of the proven key; paths are [sink, key]. There is no separate void map or status index.

Transfer probes all five canonical status keys and requires exactly one settlement. Missing, duplicate, or malformed canonical state fails. Transfers with a status filter ranges that canonical status bucket, within the owner when one is given; owner-only pages walk the record map in height and sequence order. Without filters it walks the chronological index by height, sequence, then owner. Disputes includes held terminal transfers. Account and State expose normalized epoch usage; State also returns the eligible refund queue head. Params returns the parameters. Reporters returns the current policy for version 0 (none before the first policy), every retained policy for the maximum uint64, and otherwise that version or NotFound.

Both list queries use native PageRequest and PageResponse. Disputes uses standard collection pagination, including offsets and count_total. Transfers pagination keys are opaque server cursors that carry the filter and resume position; malformed cursors are rejected. A resumed page takes owner and status from the cursor and ignores the request's, while reverse is read from every request. Transfers offsets require a status filter, limit 0 selects the default of 100, and there is no maximum. count_total is ignored; total is the page size.

Clients must use the same x-cosmos-block-height on every page of a snapshot. A pruned height fails through BaseApp; the keeper does not fall back to current state. Durable discovery retains the last processed chronological identity and the key that fetched its page, even when next_key is empty. On reconnect, refetch that page at the new height, skip identities up to and including the retained one, and continue. A new owner cannot sort behind an old chronological identity. Filtered listings do not serve as global discovery cursors.

Recovery and compatibility

Consensus version remains 2. GenesisRecord contains ID, immutable data, complete settlement and its separate status; account usage appears once per owner. policy_sequence names the current policy. Imports require the current policy and all referenced policies, with uniqueness and consistency but no contiguity requirement. The current policy must match params.reporters, in any order, and params.reporters_threshold; with policy_sequence 0 the reporter list must be empty. SDK genesis validation does not check this; the module's genesis validation, import and export do. There is no in-place conversion or silent evidence truncation. The v2.2.0 upgrade installs Sink only when the input module version map does not contain Sink. It preserves its shared cache around installation, module migration, escrow repair, real Wasm migration, and final checks.

The upgrade moves any preexisting balance at the deterministic Sink address to the community pool. Its governance proposal must disclose that disposition. Installation preserves the existing account number and clears withdrawal addresses pointing to Sink so rewards return to their delegators.

Genesis runs after auth and bank. Import validates the complete snapshot, requires an empty Sink store, creates the Sink module account or keeps the one at its address, writes canonical state in one cache, rebuilds indexes through the settlement writer without replaying accounting, checks totals against a recomputation, and checks exact bank restoration. Import does not sweep, mint, refund, rotate policy, or normalize epochs. Policies, votes, governance evidence, vetoes, void orders, paid states, and empty account usage entries survive export and import.

Every imported transfer and void-request height must precede max(1, InitChain height). Duplicate block-height/sequence pairs are rejected across owners as well. Operators must retain an initial height above the exported chain height. A zero-height export (--for-zero-height) restarts heights at 1, so export rejects it once Sink has recorded a transfer (records are never removed); export without the flag instead. akash export keeps the original genesis_time. Operators must also set it at or after the export's last block time, and preserve the native epoch record; import rejects usage beyond its current number. A database restart resumes after the committed height with a fresh transient sequence. Prior Sink schemas require a fresh deployment domain; their keys and history are not rewritten in place.

Defaults are development policy. Deposits and refunds are disabled. Reporter membership is empty, the ratio is 0.66, and the challenge is 72 hours. Because 0.66 is below two thirds, it is rejected for every set size divisible by 3 and for some larger sizes such as 50 or 100. Any ratio above two thirds, such as 0.67, works for every size. Release and sinkdev challenge floors remain in SDK validation. Solana's independent mint amount caps do not couple submission timing to Akash send epochs.

Recovery must preserve the native day schedule and current number before Sink initialization. A new installation accepts empty zero-stamped usage at an existing nonzero epoch. Populated import preserves raw current and stale consumption and requires the first executable height to exceed every stored transfer height. Restart preserves both modules. Sink does not tick the native timer during import, export, or queries.

Documentation

Index

Constants

View Source
const ModuleName = types.ModuleName

Variables

This section is empty.

Functions

This section is empty.

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

func (AppModule) BeginBlock

func (am AppModule) BeginBlock(ctx context.Context) error

func (AppModule) ConsensusVersion

func (AppModule) ConsensusVersion() uint64

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage

func (AppModule) GenerateGenesisState

func (AppModule) GenerateGenesisState(simState *module.SimulationState)

GenerateGenesisState creates randomized Sink parameters and reporter policy.

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage)

func (AppModule) IsAppModule

func (AppModule) IsAppModule()

func (AppModule) IsOnePerModuleType

func (AppModule) IsOnePerModuleType()

func (AppModule) ProposalMsgs

ProposalMsgs returns Sink governance messages for simulations.

func (AppModule) RegisterServices

func (am AppModule) RegisterServices(cfg module.Configurator)

func (AppModule) RegisterStoreDecoder

func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry)

RegisterStoreDecoder registers the Sink collections schema for state comparisons.

func (AppModule) WeightedOperations

func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation

WeightedOperations returns signed Sink deposit, report and refund operations.

type AppModuleBasic

type AppModuleBasic struct{}

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

func (AppModuleBasic) RegisterGRPCGatewayRoutes

func (AppModuleBasic) RegisterGRPCGatewayRoutes(cctx client.Context, mux *gwruntime.ServeMux)

func (AppModuleBasic) RegisterInterfaces

func (AppModuleBasic) RegisterInterfaces(reg codectypes.InterfaceRegistry)

func (AppModuleBasic) RegisterLegacyAminoCodec

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

func (AppModuleBasic) ValidateGenesis

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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