internal

package
v0.0.0-...-ae8e89f Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenesisBlockIndex = int64(0)
)

Variables

View Source
var (
	ErrInvalidChain      = xerrors.New("invalid chain")
	ErrNotImplemented    = xerrors.New("not implemented")
	ErrNotFound          = xerrors.New("not found")
	ErrInvalidParameters = xerrors.New("invalid input parameters")
)

Functions

func BigInt

func BigInt(value string) (*big.Int, error)

bigInt returns a *big.Int representation of a value.

func ChecksumAddress

func ChecksumAddress(address string) (string, error)

func CleanAddress

func CleanAddress(address string) (string, error)

CleanAddress cleans up an address string by removing all characters leading up to the address

func CleanHexString

func CleanHexString(hex string) (string, error)

CleanHexString cleans up a hex string by removing all leading 0s

func DecodeBase58

func DecodeBase58(s string) []byte

func EncodeBase58

func EncodeBase58(b []byte) string

func Has0xPrefix

func Has0xPrefix(str string) bool

Has0xPrefix returns true if the string beings with `0x` or `0X`

func HexToBig

func HexToBig(hex string) (*big.Int, error)

HexToBig converts a hex string into big integer

func NewTruncatedError

func NewTruncatedError(err error) error

func ValidateChain

func ValidateChain(blocks []*api.BlockMetadata, lastBlock *api.BlockMetadata) error

ValidateChain checks if the chain is continuous.

Types

type Checker

type Checker interface {
	GetPreProcessor() PreProcessor
	CompareNativeBlocks(ctx context.Context, height uint64, expectedBlock *api.NativeBlock, actualBlock *api.NativeBlock) error
	ValidateRosettaBlock(ctx context.Context, request *api.ValidateRosettaBlockRequest, actualRosettaBlock *api.RosettaBlock) error
}

Checker defines the interface to compare blocks (in different format) for parity check purposes. For example, CompareRosettaBlocks can be added to the interface when we support Rosetta format.

func NewChecker

func NewChecker(params ParserParams, preProcessor PreProcessor, rosettaChecker RosettaChecker) (Checker, error)

func NewDefaultChecker

func NewDefaultChecker(params ParserParams) (Checker, error)

type CheckerFactory

type CheckerFactory func(params ParserParams) (Checker, error)

type NativeParser

type NativeParser interface {
	ParseBlock(ctx context.Context, rawBlock *api.Block) (*api.NativeBlock, error)
	GetTransaction(ctx context.Context, nativeBlock *api.NativeBlock, transactionHash string) (*api.NativeTransaction, error)
}

type NativeParserFactory

type NativeParserFactory func(params ParserParams, opts ...ParserFactoryOption) (NativeParser, error)

type Params

type Params struct {
	fx.In
	fxparams.Params
	Aleo           ParserFactory `name:"aleo" optional:"true"`
	Bitcoin        ParserFactory `name:"bitcoin" optional:"true"`
	Bsc            ParserFactory `name:"bsc" optional:"true"`
	Ethereum       ParserFactory `name:"ethereum" optional:"true"`
	Rosetta        ParserFactory `name:"rosetta" optional:"true"`
	Solana         ParserFactory `name:"solana" optional:"true"`
	Polygon        ParserFactory `name:"polygon" optional:"true"`
	Avacchain      ParserFactory `name:"avacchain" optional:"true"`
	Arbitrum       ParserFactory `name:"arbitrum" optional:"true"`
	Optimism       ParserFactory `name:"optimism" optional:"true"`
	Fantom         ParserFactory `name:"fantom" optional:"true"`
	Base           ParserFactory `name:"base" optional:"true"`
	Aptos          ParserFactory `name:"aptos" optional:"true"`
	EthereumBeacon ParserFactory `name:"ethereum/beacon" optional:"true"`
	CosmosStaking  ParserFactory `name:"cosmos/staking" optional:"true"`
	CardanoStaking ParserFactory `name:"cardano/staking" optional:"true"`
}

type ParityCheckFailedError

type ParityCheckFailedError struct {
	Err  error
	Diff string
}

func (*ParityCheckFailedError) Error

func (e *ParityCheckFailedError) Error() string

type Parser

type Parser interface {
	ParseNativeBlock(ctx context.Context, rawBlock *api.Block) (*api.NativeBlock, error)
	GetNativeTransaction(ctx context.Context, nativeBlock *api.NativeBlock, transactionHash string) (*api.NativeTransaction, error)
	ParseRosettaBlock(ctx context.Context, rawBlock *api.Block) (*api.RosettaBlock, error)
	CompareNativeBlocks(ctx context.Context, height uint64, expectedBlock, actualBlock *api.NativeBlock) error
	// ValidateBlock Given a native block, validates whether the block data is cryptographically correct.
	ValidateBlock(ctx context.Context, nativeBlock *api.NativeBlock) error
	// ValidateAccountState Given an account's state verification request and the target block, verifies that the account state is valid. If successful, return the stored account state. Otherwise, return error.
	ValidateAccountState(ctx context.Context, req *api.ValidateAccountStateRequest) (*api.ValidateAccountStateResponse, error)
	// ValidateRosettaBlock Given other block source (native, etc), validates whether transaction operations show the correct balance transfer.
	ValidateRosettaBlock(ctx context.Context, req *api.ValidateRosettaBlockRequest, actualRosettaBlock *api.RosettaBlock) error
}

func NewNop

func NewNop() Parser

func NewParser

func NewParser(params Params) (Parser, error)

func WithInstrumentInterceptor

func WithInstrumentInterceptor(parser Parser, scope tally.Scope, logger *zap.Logger) Parser

type ParserBuilder

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

func NewParserBuilder

func NewParserBuilder(name string, nativeParserFactory NativeParserFactory) *ParserBuilder

func (*ParserBuilder) Build

func (b *ParserBuilder) Build() fx.Option

func (*ParserBuilder) SetCheckerFactory

func (b *ParserBuilder) SetCheckerFactory(checkerFactory CheckerFactory) *ParserBuilder

func (*ParserBuilder) SetRosettaParserFactory

func (b *ParserBuilder) SetRosettaParserFactory(rosettaParserFactory RosettaParserFactory) *ParserBuilder

func (*ParserBuilder) SetValidatorFactory

func (b *ParserBuilder) SetValidatorFactory(validatorFactory ValidatorFactory) *ParserBuilder

type ParserFactory

type ParserFactory interface {
	NewParser() (Parser, error)
}

type ParserFactoryOption

type ParserFactoryOption func(options any)

type ParserParams

type ParserParams struct {
	fx.In
	fxparams.Params
}

type PreProcessor

type PreProcessor interface {
	PreProcessNativeBlock(expected, actual *api.NativeBlock) error
}

type RosettaChecker

type RosettaChecker interface {
	ValidateRosettaBlock(ctx context.Context, request *api.ValidateRosettaBlockRequest, actualRosettaBlock *api.RosettaBlock) error
}

type RosettaParser

type RosettaParser interface {
	ParseBlock(ctx context.Context, rawBlock *api.Block) (*api.RosettaBlock, error)
}

func NewNotImplementedRosettaParser

func NewNotImplementedRosettaParser(params ParserParams, nativeParser NativeParser, opts ...ParserFactoryOption) (RosettaParser, error)

type RosettaParserFactory

type RosettaParserFactory func(params ParserParams, nativeParser NativeParser, opts ...ParserFactoryOption) (RosettaParser, error)

type TrustlessValidator

type TrustlessValidator interface {
	ValidateBlock(ctx context.Context, nativeBlock *api.NativeBlock) error
	ValidateAccountState(ctx context.Context, req *api.ValidateAccountStateRequest) (*api.ValidateAccountStateResponse, error)
}

TrustlessValidator validates the block payload and account state using cryptographic algorithms. The goal is to have the level of cryptographic security that is comparable to the native blockchain.

func NewNotImplementedValidator

func NewNotImplementedValidator(params ParserParams) TrustlessValidator

type ValidatorFactory

type ValidatorFactory func(params ParserParams) TrustlessValidator

Jump to

Keyboard shortcuts

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