distributedlog

package
v2.5.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package distributedlog encodes the IIP-59 §3.2 DelegateVoterRewardsDistributed receipt event. distributeToVoters (PR 3') calls Pack once per delegate at epoch close and wraps the returned Topics+data into an *action.Log; this package deliberately does NOT construct action.Log itself so it can be unit-tested without block context (mirrors the seam chosen by action/protocol/rewarding/delegateprofile and .../autodeposit).

Index

Constants

View Source
const ABIJSON = `` /* 671-byte string literal not displayed */

ABIJSON declares the single event this package encodes. Field ordering and indexed flags mirror IIP-59 §3.2 exactly; off-chain verifiers pin the selector derived from this signature.

It is exported so off-chain consumers decode against the protocol's exact definition instead of maintaining copies that can drift.

View Source
const EventName = "DelegateVoterRewardsDistributed"

EventName is the event's ABI name.

View Source
const EventSignature = "DelegateVoterRewardsDistributed(uint64,address,uint256,address[],address[],uint256[],uint64[],bool[])"

EventSignature is the canonical Solidity signature. Its keccak256 is Topics[0].

The trailing `bool[] compounded` is not redundant with `uint64[] compoundBucketIds`. Native bucket index 0 is a real, ordinary bucket, so `compoundBucketIds[i] == 0` cannot be read as "voter i was not compounded" -- it is indistinguishable from "voter i was compounded into bucket 0". The parallel bool is the authoritative discriminator; consumers must read compoundBucketIds[i] only when compounded[i] is true.

Variables

View Source
var (
	// ErrParallelArrayLengthMismatch is returned when the voters, recipients,
	// amounts, compound bucket ID, and compounded slices in EventArgs do not have
	// identical lengths. The rewarding protocol constructs these arrays in
	// lock-step, so a mismatch is a serialisation bug.
	ErrParallelArrayLengthMismatch = errors.New(
		"distributedlog: voters, recipients, amounts, compound bucket IDs, and compounded flags must have equal length")

	// ErrNilAddress is returned when Delegate, Voters[i], or Recipients[i]
	// is nil. Passing nil is a caller-side mistake and would
	// otherwise packet as the zero address, silently masking a lost voter.
	ErrNilAddress = errors.New("distributedlog: nil address")

	// ErrNilBigInt is returned when VoterAmount or
	// any Amounts[i] is nil.
	ErrNilBigInt = errors.New("distributedlog: nil *big.Int")

	// ErrNotDelegateVoterRewardsDistributed identifies logs for another event.
	ErrNotDelegateVoterRewardsDistributed = errors.New(
		"distributedlog: not a DelegateVoterRewardsDistributed log")

	// ErrMalformedLog identifies logs carrying this event's selector whose
	// topics or data do not match its ABI.
	ErrMalformedLog = errors.New(
		"distributedlog: malformed DelegateVoterRewardsDistributed log")
)

Errors returned by Pack. Both indicate a wiring bug in the caller (PR 3'), not on-chain data, so they hard-fail rather than degrade — there is no per-item fallback available at the log-encode layer.

Functions

func ABI

func ABI() (abi.ABI, error)

ABI parses and returns an independent copy of the event ABI. Returning a fresh value prevents callers from mutating the maps used by Pack and Unpack.

func Pack

func Pack(args EventArgs) (action.Topics, []byte, error)

Pack encodes args as an EVM-shaped receipt log. The returned Topics and data satisfy the same layout an EVM-emitted DelegateVoterRewardsDistributed event would produce, so off-chain verifiers (PR #45) can decode with stock ethers.js / web3.py against this event ABI.

Topics layout:

[0] keccak256(EventSignature)
[1] uint64 epoch, left-padded to 32 bytes
[2] address delegate, left-padded to 32 bytes

Data layout: ABI-standard tuple of the remaining (non-indexed) inputs in declaration order — voterAmount, voters[], recipients[], amounts[], compoundBucketIds[], compounded[].

compounded[i] is the only valid test for "was voter i's share compounded". compoundBucketIds[i] == 0 is NOT that test: native bucket index 0 is a real bucket and a voter can legitimately be compounded into it.

func Topic0

func Topic0() (hash.Hash256, error)

Topic0 returns the selector carried in Topics[0].

Types

type EventArgs

type EventArgs struct {
	Epoch             uint64            // indexed → Topics[1]
	Delegate          address.Address   // indexed → Topics[2]
	VoterAmount       *big.Int          // voter rewards paid in this chunk
	Voters            []address.Address // canonical sorted order per §3.4
	Recipients        []address.Address // actual direct recipient; voter for compound payout
	Amounts           []*big.Int        // parallel to Voters
	CompoundBucketIDs []uint64          // parallel to Voters; meaningful only where Compounded is true
	Compounded        []bool            // parallel to Voters; true → paid into CompoundBucketIDs[i]
}

EventArgs are the fields of one DelegateVoterRewardsDistributed log. Field order matches the Solidity signature so a struct literal reads left-to-right the same way as the on-chain event definition. Callers build one per delegate touched by a voter-major settlement chunk.

func Unpack

func Unpack(topics action.Topics, data []byte) (*EventArgs, error)

Unpack decodes a DelegateVoterRewardsDistributed log. Callers must check the emitting protocol address separately. A foreign selector returns ErrNotDelegateVoterRewardsDistributed; a matching selector with invalid topics or data returns ErrMalformedLog.

Jump to

Keyboard shortcuts

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