migration

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: MIT Imports: 29 Imported by: ? modules, 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.

Documentation

Index

Constants

View Source
const (
	MigrationQueueName         = "migration-queue"
	MigrationQueueBurnedName   = "migration-queue-burned"
	MigrationQueueMultisigName = "migration-queue-multisig"
)

Variables

View Source
var (
	OnDemandSuccessCounterVec = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "agora",
		Name:      "on_demand_migration_success",
		Help:      "Number of successful on demand migrations",
	}, []string{"kin_version"})

	OnDemandFailureCounterVec = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "agora",
		Name:      "on_demand_migration_failure",
		Help:      "Number of failed on demand migrations",
	}, []string{"kin_version"})

	MigrationAllowedCounter = prometheus.NewCounter(prometheus.CounterOpts{
		Namespace: "agora",
		Name:      "migration_allowed",
		Help:      "Number of initiate migration calls allowed",
	})
	MigrationRateLimitedCounter = prometheus.NewCounter(prometheus.CounterOpts{
		Namespace: "agora",
		Name:      "migration_rate_limited",
		Help:      "Number of initiate migration calls rate limited",
	})
)
View Source
var (
	ErrMultisig    = errors.New("multisig wallet")
	ErrNotFound    = errors.New("account not found")
	ErrBurned      = errors.New("account was burned")
	ErrRateLimited = errors.New("rate limited")
)
View Source
var ErrStatusMismatch = errors.New("previous state does not match stored")

ErrStatusMismatch indicates the expected previous state was not what was stored.

Functions

func DeriveMigrationAccount added in v0.2.6

func DeriveMigrationAccount(source ed25519.PublicKey, secret []byte) (ed25519.PublicKey, ed25519.PrivateKey, error)

DeriveMigrationAccount derives a migration account address.

func HasMigrationHeader added in v0.2.6

func HasMigrationHeader(ctx context.Context) (bool, error)

HasMigrationHeader indicates whether or not the provided context contains a header indicating a migration should occur.

func MarkComplete added in v0.2.6

func MarkComplete(ctx context.Context, store Store, account ed25519.PublicKey, prev State) error

MarkComplete is a utility function to mark the state for an account as complete.

func MigrateBatch added in v0.2.6

func MigrateBatch(ctx context.Context, m Migrator, accounts ...ed25519.PublicKey) error

MigrateBatch migrates a set of accounts in parallel.

The function will deduplicate accounts, so callers need not be concerned.

func MigrateTransferAccounts added in v0.3.0

func MigrateTransferAccounts(ctx context.Context, hc horizon.ClientInterface, m Migrator, transferAccountPairs ...[]ed25519.PublicKey) error

Migrate the accounts involved in a transaction in parallel.

Ensures a migration for destinations occurs if a sender sending a transfer to it has a native balance.

Types

type Migrator added in v0.2.6

type Migrator interface {
	// InitiateMigration initiates a migration for a given account.
	//
	// The commitment provided indicates the commitment that should be used for
	// transactions and queries before returning. It should be noted that any
	// commitment less than MAX will not mark a migration as completed.
	InitiateMigration(ctx context.Context, account ed25519.PublicKey, ignoreBalance bool, commitment solana.Commitment) error

	// GetMigrationAccount returns the migration account for the public key, _only if_
	// a migration would occur for said account.
	//
	// That is, this only returns the dervied (migration) account if the provided public
	// key exists on an older change
	GetMigrationAccount(ctx context.Context, account ed25519.PublicKey) (ed25519.PublicKey, error)
}

func NewContextAwareMigrator added in v0.2.6

func NewContextAwareMigrator(base Migrator) Migrator

func NewNoopMigrator added in v0.2.6

func NewNoopMigrator() Migrator

type Processor added in v0.3.0

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

func NewProcessor added in v0.3.0

func NewProcessor(
	queueCtr taskqueue.ProcessorCtor,
	burnedQueueSubmitter taskqueue.Submitter,
	multisigQueueSubmitter taskqueue.Submitter,
	m Migrator,
	localLimiter *xrate.Limiter,
) (p *Processor, err error)

func (*Processor) Queue added in v0.3.0

func (*Processor) SetRateLimit added in v0.3.0

func (*Processor) SetState added in v0.3.0

func (*Processor) Shutdown added in v0.3.0

func (p *Processor) Shutdown()

func (*Processor) Write added in v0.3.0

func (p *Processor) Write(ctx context.Context, account ed25519.PublicKey, ignoreZeroBalance bool) error

type State

type State struct {
	Status       Status
	Signature    solana.Signature
	LastModified time.Time
}

State represents the recorded migration state about an account.

var ZeroState State

type Status

type Status int

Status is the 'marked' status of a migration.

The source of truth for an account's migration status is completely recoverable from the chain, and will be used as a fallback. If the status is marked as complete, the migrators will _not_ consult the chain.

const (
	// StatusNone indicates either no migration has occurred, or no
	// information about a migration is stored.
	StatusNone Status = iota

	// StatusInProgress indicates that a migration transaction was
	// likely submitted, but its result is unknown.
	StatusInProgress

	// StatusComplete indicates that a migration transaction reached
	// max lockout with certainty.
	StatusComplete
)

type Store

type Store interface {
	// Get returns the recorded state, if any, for an account.
	//
	// ZeroState is returned if there is no persisted state.
	Get(ctx context.Context, account ed25519.PublicKey) (state State, exists bool, err error)

	// Update updates the state for an account. The previous state must match
	// what was stored. Implementations must support atomic compare-and-swap.
	Update(ctx context.Context, account ed25519.PublicKey, prev, next State) error

	// IncrementCount increments the request count for an account
	IncrementCount(ctx context.Context, account ed25519.PublicKey) error

	// GetCount returns the request count for an account
	GetCount(ctx context.Context, account ed25519.PublicKey) (int, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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