stateless

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const BRC20StartHeight uint = 779832

The first block height of the brc-20 protocol.

View Source
const ValueSize = 32

Variables

View Source
var NodeResolveFn verkle.NodeResolverFn = nil
View Source
var SelfMintEnableHeight uint = 837090

Start Height of the Self-Mint

Functions

func Exec

func Exec(state KVStorage, ots []getter.OrdTransfer, blockHeight uint)

TODO: High. Include burn logic. Input previous verkle tree and all ord records in a block, then get the K-V array that the verkle tree should update

func GetBalances

func GetBalances(state KVStorage, tick string, Pkscript ord.Pkscript) ([]byte, []byte, *uint256.Int, *uint256.Int)

Available, OverallBalances

func GetEventHash

func GetEventHash(inscriptionID string, locationID LocationID) []byte

func GetLatestPkscript

func GetLatestPkscript(state KVStorage, wallet string) ([]byte, string)

func GetTickHash

func GetTickHash(tick string, locationID LocationID) []byte

func GetTickPkscriptHash

func GetTickPkscriptHash(tick string, Pkscript ord.Pkscript, stateID LocationID) []byte

func GetWalletHash

func GetWalletHash(wallet string, locationID LocationID) []byte

func Rollingback

func Rollingback(header *Header, stateDiff *DiffState) (verkle.VerkleNode, [][]byte)

func StoreDiff

func StoreDiff(diff *AccessList, height uint) error

func StoreHeader

func StoreHeader(header *Header, evictHeight uint) error

func StoreKV

func StoreKV(header *Header) error

Types

type AccessList

type AccessList struct {
	Elements []TripleElement
}

type DiffState

type DiffState struct {
	Height uint
	Hash   string
	// ipa.CompressedSize
	VerkleCommit [32]byte

	Access AccessList
}

DiffState stores the difference from next state

func (DiffState) Copy

func (state DiffState) Copy() DiffState

type Dynamic

type Dynamic = string
type Header struct {
	// Verkle Tree Root
	Root verkle.VerkleNode

	// All Key Values on the Verkle Tree. It shall be consistent with the Root.
	KV KeyValueMap

	// The state is after the execution of Block Height.
	Height uint
	// Block Hash.
	Hash string
	// Ord Transfers at Height and Hash.
	OrdTrans []getter.OrdTransfer

	// All values being accessed at this height.
	Access AccessList
	// The key-value map during the execution of the block.
	IntermediateKV KeyValueMap

	sync.RWMutex
}

func Deserialize

func Deserialize(buffer *bytes.Buffer, height uint, nodeResolverFn verkle.NodeResolverFn) (*Header, error)

func LoadHeader

func LoadHeader(enableStateRootCache bool, initHeight uint) *Header

func NewHeader

func NewHeader(getter *getter.OrdGetter, initState *DiffState) *Header

func (*Header) GetBytes

func (h *Header) GetBytes(key []byte) []byte

func (*Header) GetHeight

func (h *Header) GetHeight() uint

func (*Header) GetInscriptionID

func (h *Header) GetInscriptionID(key []byte) string

func (*Header) GetUInt256

func (h *Header) GetUInt256(key []byte) *uint256.Int

func (*Header) InsertBytes

func (h *Header) InsertBytes(key []byte, value []byte)

func (*Header) InsertInscriptionID

func (h *Header) InsertInscriptionID(key []byte, value string)

func (*Header) InsertUInt256

func (h *Header) InsertUInt256(key []byte, value *uint256.Int)

func (*Header) OrderedKeys

func (h *Header) OrderedKeys() [][verkle.KeySize]byte

func (*Header) Paging

func (h *Header) Paging(ordGetter getter.OrdGetter, queryHash bool, nodeResolverFn verkle.NodeResolverFn) error

func (*Header) Serialize

func (h *Header) Serialize() (*bytes.Buffer, error)

func (*Header) VerifyState

func (h *Header) VerifyState(records *OPIRecords)

type KVStorage

type KVStorage interface {
	InsertInscriptionID(key []byte, value string)

	GetInscriptionID(key []byte) string

	InsertUInt256(key []byte, value *uint256.Int)

	GetUInt256(key []byte) *uint256.Int

	InsertBytes(key []byte, value []byte)

	GetBytes(key []byte) []byte

	GetHeight() uint
	// contains filtered or unexported methods
}

type KeyValueMap

type KeyValueMap = map[[verkle.KeySize]byte][ValueSize]byte

type LightHeader

type LightHeader struct {
	// Verkle Tree Root
	Root verkle.VerkleNode
	// The state is after the execution of Block Height.
	Height uint
	// Block Hash.
	Hash string
}

func (*LightHeader) GetBytes

func (h *LightHeader) GetBytes(key []byte) []byte

func (*LightHeader) GetHeight

func (h *LightHeader) GetHeight() uint

func (*LightHeader) GetInscriptionID

func (h *LightHeader) GetInscriptionID(key []byte) string

func (*LightHeader) GetUInt256

func (h *LightHeader) GetUInt256(key []byte) *uint256.Int

func (*LightHeader) InsertBytes

func (h *LightHeader) InsertBytes(key []byte, value []byte)

func (*LightHeader) InsertInscriptionID

func (h *LightHeader) InsertInscriptionID(key []byte, value string)

func (*LightHeader) InsertUInt256

func (h *LightHeader) InsertUInt256(key []byte, value *uint256.Int)

type LocationID

type LocationID = byte

LocationID is used to indicate the last digit of the Key to fully utilize the characteristics of the Verkle Tree and save memory.

var AvailableBalancePkscript LocationID = 0x00

Tick+Pkscript State Key: Keccak256(tick + Pkscript + "GetTickPkscriptHash")[:StemSize] + LocationID Value: uint256

var Decimals LocationID = 0x04
var Exists LocationID = 0x00

Tick State Key: Keccak256(tick + "GetTickHash")[:StemSize] + LocationID Value: uint256

var InscriptionID LocationID = 0x06 // inscription should take 2 slots, next should start with 08
var IsSelfMint LocationID = 0x05
var LimitPerMint LocationID = 0x03
var MaxSupply LocationID = 0x02
var OverallBalancePkscript LocationID = 0x01
var RemainingSupply LocationID = 0x01
var TransferInscribeCount LocationID = 0x0

TODO: High. Flush to the disk. Inscription Event State Key: Keccak256(inscriptionID + "GetEventHash")[:StemSize] + LocationID Value: uint256

var TransferInscribeSourcePkscript LocationID = 0x5

Value: []byte (Less than 1534 bytes)

var TransferInscribeSourceWallet LocationID = 0x2

Value: []byte (Less than 34 bytes, Next slot is 0x2 + 1 + (34 / 32) + 1 = 0x5)

var TransferTransferCount LocationID = 0x1
var WalletLatestPkscript LocationID = 0x00

Wallet State Key: Keccak256(wallet + "GetWalletHash")[:StemSize] + LocationID Value: []byte (Less than 1534 bytes)

type OPIRecords

type OPIRecords = map[uint][]Record

func LoadOPIRecords

func LoadOPIRecords(filepath string) (OPIRecords, error)

type Queue

type Queue struct {
	Header         *Header
	History        [ord.BitcoinConfirmations]DiffState
	LastStateProof *verkle.Proof
	sync.RWMutex
}

func NewQueues

func NewQueues(getter getter.OrdGetter, header *Header, queryHash bool, startHeight uint) (*Queue, error)

func (*Queue) CheckForReorg

func (queue *Queue) CheckForReorg(getter getter.OrdGetter) (uint, error)

func (*Queue) LatestHeight

func (queue *Queue) LatestHeight() uint

func (*Queue) Println

func (queue *Queue) Println()

func (*Queue) Recovery

func (queue *Queue) Recovery(getter getter.OrdGetter, reorgHeight uint) error

func (*Queue) StartHeight

func (queue *Queue) StartHeight() uint

func (*Queue) Update

func (queue *Queue) Update(getter getter.OrdGetter, latestHeight uint) error

type Record

type Record struct {
	ID               int
	Pkscript         string
	Wallet           string
	Tick             string
	OverallBalance   string
	AvailableBalance string
	BlockHeight      uint
	EventID          uint
}

type TripleElement

type TripleElement struct {
	Key            [verkle.KeySize]byte
	OldValue       [ValueSize]byte
	NewValue       [ValueSize]byte
	OldValueExists bool
}

Jump to

Keyboard shortcuts

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