Documentation ¶
Index ¶
- Constants
- Variables
- func GetPredicateResultBytes(extraData []byte) ([]byte, bool)
- func NewPredicateTx(chainID *big.Int, nonce uint64, to *common.Address, gas uint64, ...) *types.Transaction
- func PackPredicate(predicateBytes []byte) []byte
- func PreparePredicateStorageSlots(rules params.Rules, list types.AccessList) map[common.Address][][]byte
- func UnpackPredicate(paddedPredicate []byte) ([]byte, error)
- type Results
- type TxResults
Constants ¶
const ( Version = uint16(0) MaxResultsSize = units.MiB )
Variables ¶
var ( ErrInvalidAllZeroBytes = fmt.Errorf("predicate specified invalid all zero bytes") ErrInvalidPadding = fmt.Errorf("predicate specified invalid padding") ErrInvalidEndDelimiter = fmt.Errorf("invalid end delimiter") ErrorInvalidExtraData = fmt.Errorf("header extra data too short for predicate verification") )
var Codec codec.Manager
var EndByte = byte(0xff)
EndByte is used as a delimiter for the bytes packed into a precompile predicate. Precompile predicates are encoded in the Access List of transactions in the access tuples which means that its length must be a multiple of 32 (common.HashLength). For messages with a length that does not comply to that, this delimiter is used to append/remove padding.
Functions ¶
func GetPredicateResultBytes ¶
GetPredicateResultBytes returns the predicate result bytes from the extra data and true iff the predicate results bytes have non-zero length.
func NewPredicateTx ¶
func NewPredicateTx( chainID *big.Int, nonce uint64, to *common.Address, gas uint64, gasFeeCap *big.Int, gasTipCap *big.Int, value *big.Int, data []byte, accessList types.AccessList, predicateAddress common.Address, predicateBytes []byte, ) *types.Transaction
NewPredicateTx returns a transaction with the predicateAddress/predicateBytes tuple packed and added to the access list of the transaction.
func PackPredicate ¶
PackPredicate packs predicate by delimiting the actual message with [PredicateEndByte] and zero padding to reach a length that is a multiple of 32.
func PreparePredicateStorageSlots ¶
func PreparePredicateStorageSlots(rules params.Rules, list types.AccessList) map[common.Address][][]byte
PreparePredicateStorageSlots populates the the predicate storage slots of a transaction's access list Note: if an address is specified multiple times in the access list, each storage slot for that address is appended to a slice of byte slices. Each byte slice represents a predicate, making it a slice of predicates for each access list address, and every predicate in the slice goes through verification.
func UnpackPredicate ¶
UnpackPredicate unpacks a predicate by stripping right padded zeroes, checking for the delimter, ensuring there is not excess padding, and returning the original message. Returns an error if it finds an incorrect encoding.
Types ¶
type Results ¶
Results encodes the precompile predicate results included in a block on a per transaction basis. Results is not thread-safe.
func ParseResults ¶
ParseResults parses [b] into predicate results.
func (*Results) DeleteTxResults ¶
DeleteTxResults deletes the predicate results for the given [txHash].
func (*Results) GetResults ¶
GetResults returns the byte array results for [txHash] from precompile [address] if available.
func (*Results) SetTxResults ¶
SetTxResults sets the predicate results for the given [txHash]. Overrides results if present.