runtime

package
v0.7.11 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Overview

Package runtime implements the analyzer for the accounts module.

Index

Constants

View Source
const (
	TxRevertErrPrefix     = "reverted: "
	DefaultTxRevertErrMsg = "reverted without a message"
)

Variables

This section is empty.

Functions

func DecodeAccountsEvent

func DecodeAccountsEvent(event *nodeapi.RuntimeEvent) ([]accounts.Event, error)

func DecodeConsensusAccountsEvent

func DecodeConsensusAccountsEvent(event *nodeapi.RuntimeEvent) ([]consensusaccounts.Event, error)

func DecodeCoreEvent

func DecodeCoreEvent(event *nodeapi.RuntimeEvent) ([]core.Event, error)

func DecodeEVMEvent

func DecodeEVMEvent(event *nodeapi.RuntimeEvent) ([]evm.Event, error)

func DecodeRoflEvent added in v0.5.0

func DecodeRoflEvent(event *nodeapi.RuntimeEvent) ([]rofl.Event, error)

func DecodeRoflMarketEvent added in v0.6.4

func DecodeRoflMarketEvent(event *nodeapi.RuntimeEvent) ([]roflmarket.Event, error)

func NewRuntimeAnalyzer

func NewRuntimeAnalyzer(
	chain common.ChainName,
	runtime common.Runtime,
	sdkPT *sdkConfig.ParaTime,
	blockRange config.BlockRange,
	cfg *config.RuntimeAnalyzerConfig,
	mode analyzer.BlockAnalysisMode,
	sourceClient nodeapi.RuntimeApiLite,
	target storage.TargetStorage,
	logger *log.Logger,
) (analyzer.Analyzer, error)

NewRuntimeAnalyzer returns a new runtime analyzer for a runtime.

func OasisMaybeUnmarshalEncryptedData added in v0.4.0

func OasisMaybeUnmarshalEncryptedData(call *sdkTypes.Call, callResult *sdkTypes.CallResult) (*encryption.EncryptedData, error)

OasisMaybeUnmarshalEncryptedData breaks down a possibly encrypted call + result into their encryption envelope fields. If the call is not encrypted, it returns nil with no error.

func VisitCall

func VisitCall(call *sdkTypes.Call, result *sdkTypes.CallResult, handler *CallHandler) error

func VisitEVMEvent

func VisitEVMEvent(event *evm.Event, handler *EVMEventHandler) error

func VisitSdkEvent

func VisitSdkEvent(event *nodeapi.RuntimeEvent, handler *SdkEventHandler, eventIdx int) (int, error)

func VisitSdkEvents

func VisitSdkEvents(events []nodeapi.RuntimeEvent, handler *SdkEventHandler) error

Types

type BlockData

type BlockData struct {
	Header              nodeapi.RuntimeBlockHeader
	MinGasPrice         common.BigInt
	NumTransactions     int // Might be different from len(TransactionData) if some transactions are malformed.
	GasUsed             uint64
	Size                int
	TransactionData     []*BlockTransactionData
	EventData           []*EventData
	AddressPreimages    map[apiTypes.Address]*addresses.PreimageData
	TokenBalanceChanges map[TokenChangeKey]*big.Int
	PossibleTokens      map[apiTypes.Address]*evm.EVMPossibleToken // key is oasis bech32 address
	PossibleNFTs        map[NFTKey]*PossibleNFT
	SwapCreations       map[SwapCreationKey]*PossibleSwapCreation
	SwapSyncs           map[apiTypes.Address]*PossibleSwapSync
}

func ExtractRound

func ExtractRound(blockHeader nodeapi.RuntimeBlockHeader, txrs []nodeapi.RuntimeTransactionWithResults, rawEvents []nodeapi.RuntimeEvent, minGasPrice common.BigInt, sdkPT *sdkConfig.ParaTime, logger *log.Logger) (*BlockData, error)

type BlockTransactionData

type BlockTransactionData struct {
	Index                   int
	Hash                    string
	EthHash                 *string
	GasUsed                 uint64
	Size                    int
	Raw                     []byte
	RawResult               []byte
	SignerData              []*BlockTransactionSignerData
	RelatedAccountAddresses map[apiTypes.Address]struct{}
	RelatedRoflAddresses    map[nodeapi.AppID]struct{}
	Fee                     common.BigInt
	FeeSymbol               string
	FeeProxyModule          *string
	FeeProxyID              *[]byte
	GasLimit                uint64
	OasisEncrypted          *encryption.EncryptedData
	Method                  string
	Body                    interface{}
	ContractCandidate       *apiTypes.Address // If non-nil, an address that was encountered in the tx and might be a contract.
	To                      *apiTypes.Address // Extracted from the body for convenience. Semantics vary by tx type.
	Amount                  *common.BigInt    // Extracted from the body for convenience. Semantics vary by tx type.
	AmountSymbol            *string           // Extracted from the body for convenience.
	EVMEncrypted            *encryption.EncryptedData
	EVMContract             *evm.EVMContractData
	Success                 *bool
	Error                   *TxError
	IsLikelyTokenTransfer   bool
}

type BlockTransactionSignerData

type BlockTransactionSignerData struct {
	Index   int
	Address apiTypes.Address
	Nonce   int
}

type CallHandler

type CallHandler struct {
	AccountsTransfer               func(body *accounts.Transfer) error
	ConsensusAccountsDeposit       func(body *consensusaccounts.Deposit) error
	ConsensusAccountsWithdraw      func(body *consensusaccounts.Withdraw) error
	ConsensusAccountsDelegate      func(body *consensusaccounts.Delegate) error
	ConsensusAccountsUndelegate    func(body *consensusaccounts.Undelegate) error
	EVMCreate                      func(body *evm.Create, ok *[]byte) error
	EVMCall                        func(body *evm.Call, ok *[]byte) error
	RoflCreate                     func(body *rofl.Create) error
	RoflUpdate                     func(body *rofl.Update) error
	RoflRemove                     func(body *rofl.Remove) error
	RoflRegister                   func(body *rofl.Register) error
	RoflMarketProviderCreate       func(body *roflmarket.ProviderCreate) error
	RoflMarketProviderUpdate       func(body *roflmarket.ProviderUpdate) error
	RoflMarketProviderUpdateOffers func(body *roflmarket.ProviderUpdateOffers) error
	RoflMarketProviderRemove       func(body *roflmarket.ProviderRemove) error
	RoflMarketInstanceCreate       func(body *roflmarket.InstanceCreate) error
	RoflMarketInstanceTopUp        func(body *roflmarket.InstanceTopUp) error
	RoflMarketInstanceCancel       func(body *roflmarket.InstanceCancel) error
	RoflMarketInstanceExecuteCmds  func(body *roflmarket.InstanceExecuteCmds) error
	RoflMarketInstanceChangeAdmin  func(body *roflmarket.InstanceChangeAdmin) error
	UnknownMethod                  func(methodName string) error // Invoked for a tx call that doesn't map to any of the above method names.
}

type EVMEventHandler

type EVMEventHandler struct {
	ERC20Transfer                func(from ethCommon.Address, to ethCommon.Address, value *big.Int) error
	ERC20Approval                func(owner ethCommon.Address, spender ethCommon.Address, value *big.Int) error
	ERC721Transfer               func(from ethCommon.Address, to ethCommon.Address, tokenID *big.Int) error
	ERC721Approval               func(owner ethCommon.Address, approved ethCommon.Address, tokenID *big.Int) error
	ERC721ApprovalForAll         func(owner ethCommon.Address, operator ethCommon.Address, approved bool) error
	IUniswapV2FactoryPairCreated func(token0 ethCommon.Address, token1 ethCommon.Address, pair ethCommon.Address, allPairsLength *big.Int) error
	IUniswapV2PairMint           func(sender ethCommon.Address, amount0 *big.Int, amount1 *big.Int) error
	IUniswapV2PairBurn           func(sender ethCommon.Address, amount0 *big.Int, amount1 *big.Int, to ethCommon.Address) error
	IUniswapV2PairSwap           func(sender ethCommon.Address, amount0In *big.Int, amount1In *big.Int, amount0Out *big.Int, amount1Out *big.Int, to ethCommon.Address) error
	IUniswapV2PairSync           func(reserve0 *big.Int, reserve1 *big.Int) error
	// `owner` wrapped/deposited runtime's native token (ROSE) into the wrapper contract (creating WROSE).
	// `value` ROSE is transferred from `owner` to the wrapper (= event-emitting contract). Caller's WROSE balance increases by `value`.
	WROSEDeposit func(owner ethCommon.Address, value *big.Int) error
	// `owner` unwrapped/withdrew runtime's native token (ROSE) into the wrapper contract (burning WROSE).
	// Caller's WROSE balance decreases by `value`. `value` ROSE is transferred from the wrapper (= event-emitting contract) to `owner`.
	WROSEWithdrawal func(owner ethCommon.Address, value *big.Int) error
}

type EventBody

type EventBody interface{}

type EventData

type EventData struct {
	TxIndex              *int    // nil for non-tx events
	TxHash               *string // nil for non-tx events
	TxEthHash            *string // nil for non-evm-tx events
	EventIdx             int     // Unique event index within the block.
	Type                 apiTypes.RuntimeEventType
	Body                 EventBody
	WithScope            ScopedSdkEvent
	EvmLogName           *string
	EvmLogSignature      *ethCommon.Hash
	EvmLogParams         []*apiTypes.EvmAbiParam
	RelatedAddresses     map[apiTypes.Address]struct{}
	RelatedRoflAddresses map[nodeapi.AppID]struct{}
	// EVM logs are emitted by contracts. We usually detect contracts via transactions,
	// but in some edge cases, we can only detect them via emitted events.
	// This happens when a contract is created via an internal call and only interacted with
	// through internal calls — meaning we never see a top-level transaction involving the contract,
	// and thus don't mark the address as a contract candidate. In such cases,
	// observing the address in events helps us detect the contract.
	ContractCandidate *apiTypes.Address
}

type NFTKey added in v0.1.16

type NFTKey struct {
	TokenAddress apiTypes.Address
	TokenID      *big.Int
}

type PossibleNFT added in v0.1.17

type PossibleNFT struct {
	// NumTransfers is how many times we saw it transferred. If it's more than
	// zero, Burned or NewOwner will be set.
	NumTransfers int
	// Burned is true if NumTransfers is more than zero and the NFT instance
	// was burned.
	Burned bool
	// NewOwner has the latest owner if NumTransfers is more than zero.
	NewOwner apiTypes.Address
}

type PossibleSwapCreation added in v0.4.0

type PossibleSwapCreation struct {
	Pair apiTypes.Address
}

type PossibleSwapSync added in v0.4.0

type PossibleSwapSync struct {
	Reserve0 *big.Int
	Reserve1 *big.Int
}

type ScopedSdkEvent

type ScopedSdkEvent struct {
	Core              *core.Event
	Accounts          *accounts.Event
	ConsensusAccounts *consensusaccounts.Event
	EVM               *sdkEVM.Event
	Rofl              *rofl.Event
	RoflMarket        *roflmarket.Event
}

ScopedSdkEvent is a one-of container for SDK events.

type SdkEventHandler

type SdkEventHandler struct {
	Core              func(event *core.Event, eventTxHash *string, eventIdx int) error
	Accounts          func(event *accounts.Event, eventTxHash *string, eventIdx int) error
	ConsensusAccounts func(event *consensusaccounts.Event, eventTxHash *string, eventIdx int) error
	EVM               func(event *evm.Event, eventTxHash *string, eventIdx int) error
	Rofl              func(event *rofl.Event, eventTxHash *string, eventIdx int) error
	RoflMarket        func(event *roflmarket.Event, eventTxHash *string, eventIdx int) error
}

type SwapCreationKey added in v0.4.0

type SwapCreationKey struct {
	Factory apiTypes.Address
	Token0  apiTypes.Address
	Token1  apiTypes.Address
}

type TokenChangeKey

type TokenChangeKey struct {
	// TokenAddress is the Oasis address of the smart contract of the
	// compatible (e.g. ERC-20) token.
	TokenAddress apiTypes.Address
	// AccountAddress is the Oasis address of the owner of some amount of the
	// compatible (e.g. ERC-20) token.
	AccountAddress apiTypes.Address
}

type TxError

type TxError struct {
	Code   uint32
	Module string
	// The raw error message returned by the node. Note that this may be null.
	// https://github.com/oasisprotocol/oasis-sdk/blob/fb741678585c04fdb413441f2bfba18aafbf98f3/client-sdk/go/types/transaction.go#L488-L492
	RawMessage *string
	// The human-readable error message parsed from RawMessage.
	Message *string
}

Directories

Path Synopsis
Package abiparse implements a parser for Ethereum ABI.
Package abiparse implements a parser for Ethereum ABI.
Package encryption defines the types for encryption envelopes.
Package encryption defines the types for encryption envelopes.
Package evm implements the EVM client.
Package evm implements the EVM client.
Package static contains static data for the analyzer.
Package static contains static data for the analyzer.

Jump to

Keyboard shortcuts

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