proposals

package
v2.0.0-b2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: GPL-3.0 Imports: 32 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFromFile

func LoadFromFile[ContextType any, DataType IDataType](m *ChecksumManager[ContextType, DataType], context ContextType) (*DataType, string, error)

Load the snapshot for the provided block from disk if it exists, using the checksum table as an index

func SaveToFile

func SaveToFile[ContextType any, DataType IDataType](m *ChecksumManager[ContextType, DataType], data *DataType) error

Types

type ChecksumManager

type ChecksumManager[ContextType any, DataType IDataType] struct {
	// contains filtered or unexported fields
}

func NewChecksumManager

func NewChecksumManager[ContextType any, DataType IDataType](checksumFilename string, dataHandler IChecksumDataHandler[ContextType, DataType]) (*ChecksumManager[ContextType, DataType], error)

type IChecksumDataHandler

type IChecksumDataHandler[ContextType any, DataType IDataType] interface {
	Less(firstFilename string, secondFilename string) (bool, error)
	ShouldLoadEntry(filename string, context ContextType) (bool, error)
	IsDataValid(data *DataType, filename string, context ContextType) (bool, error)
}

type IDataType

type IDataType interface {
	GetFilename() string
}

type NetworkTreeManager

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

Struct for network voting trees

func NewNetworkTreeManager

func NewNetworkTreeManager(logger *slog.Logger, cfg *config.SmartNodeConfig) (*NetworkTreeManager, error)

Create a new NetworkTreeManager instance

func (*NetworkTreeManager) CreateNetworkVotingTree

func (m *NetworkTreeManager) CreateNetworkVotingTree(snapshot *VotingInfoSnapshot, depthPerRound uint64) *NetworkVotingTree

Create a network voting tree from a voting info snapshot

func (*NetworkTreeManager) IsDataValid

func (m *NetworkTreeManager) IsDataValid(data *NetworkVotingTree, filename string, context uint32) (bool, error)

Return true if the loaded network tree can be used for processing

func (*NetworkTreeManager) Less

func (m *NetworkTreeManager) Less(firstFilename string, secondFilename string) (bool, error)

Return true if the first filename represents a block number that's lower than the second filename's block number

func (*NetworkTreeManager) LoadFromDisk

func (m *NetworkTreeManager) LoadFromDisk(blockNumber uint32) (*NetworkVotingTree, error)

Load the network tree for the provided block from disk if it exists

func (*NetworkTreeManager) SaveToFile

func (m *NetworkTreeManager) SaveToFile(tree *NetworkVotingTree) error

Save a network voting tree to a file

func (*NetworkTreeManager) ShouldLoadEntry

func (m *NetworkTreeManager) ShouldLoadEntry(filename string, context uint32) (bool, error)

Return true if the filename matches the block number provided in the context

type NetworkVotingTree

type NetworkVotingTree struct {
	*VotingTree
}

A network voting tree

func (NetworkVotingTree) GetFilename

func (t NetworkVotingTree) GetFilename() string

Get the filename of the network voting tree, including the block number it's built against

type NodeTreeManager

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

Struct for node voting trees

func NewNodeTreeManager

func NewNodeTreeManager(logger *slog.Logger, cfg *config.SmartNodeConfig) (*NodeTreeManager, error)

Create a new NodeTreeManager instance

func (*NodeTreeManager) CreateNodeVotingTree

func (m *NodeTreeManager) CreateNodeVotingTree(snapshot *VotingInfoSnapshot, rpNodeIndex uint64, networkTreeNodeIndex uint64, depthPerRound uint64) *NodeVotingTree

Create a node voting tree from a voting info snapshot and the node's index

func (*NodeTreeManager) IsDataValid

func (m *NodeTreeManager) IsDataValid(data *NodeVotingTree, filename string, context NodeVotingTreeLoadingContext) (bool, error)

Return true if the loaded node tree can be used for processing

func (*NodeTreeManager) Less

func (m *NodeTreeManager) Less(firstFilename string, secondFilename string) (bool, error)

Sort the checksum file entries by their block number

func (*NodeTreeManager) LoadFromDisk

func (m *NodeTreeManager) LoadFromDisk(blockNumber uint32, rpIndex uint64) (*NodeVotingTree, error)

Load the node tree for the provided block from disk if it exists

func (*NodeTreeManager) SaveToFile

func (m *NodeTreeManager) SaveToFile(tree *NodeVotingTree) error

Save a node voting tree to a file

func (*NodeTreeManager) ShouldLoadEntry

func (m *NodeTreeManager) ShouldLoadEntry(filename string, context NodeVotingTreeLoadingContext) (bool, error)

Get the checksum, the filename, and the block number from a checksum entry.

type NodeVotingTree

type NodeVotingTree struct {
	Address   common.Address `json:"address"`
	NodeIndex uint64         `json:"nodeIndex"`
	*VotingTree
}

A node voting tree

func (NodeVotingTree) GetFilename

func (t NodeVotingTree) GetFilename() string

Get the filename of the node voting tree, including the block number it's built against, the node's address, and the node's index

type NodeVotingTreeLoadingContext

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

type ProposalManager

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

func (*ProposalManager) CheckForChallengeableArtifacts

func (m *ProposalManager) CheckForChallengeableArtifacts(event protocol.RootSubmitted) (uint64, types.VotingTreeNode, []types.VotingTreeNode, error)

Checks a RootSubmitted event against the local artifacts to see if there's a mismatch at an index; if so, returns the index, the node, and the proof

func (*ProposalManager) CreateLatestFinalizedTree

func (m *ProposalManager) CreateLatestFinalizedTree(context context.Context) (uint32, *NetworkVotingTree, error)

func (*ProposalManager) CreatePollardForProposal

func (m *ProposalManager) CreatePollardForProposal(context context.Context) (uint32, []*types.VotingTreeNode, error)

func (*ProposalManager) GetArtifactsForChallengeResponse

func (m *ProposalManager) GetArtifactsForChallengeResponse(blockNumber uint32, challengedIndex uint64) (types.VotingTreeNode, []types.VotingTreeNode, error)

Gets the root node and pollard for a proposer's response to a challenge against a tree node

func (*ProposalManager) GetArtifactsForVoting

func (m *ProposalManager) GetArtifactsForVoting(blockNumber uint32, nodeAddress common.Address) (*big.Int, uint64, []types.VotingTreeNode, error)

Get the artifacts required for voting on a proposal: the node's total delegated voting power, the node index, and a Merkle proof for the node's corresponding leaf index in the network tree

func (*ProposalManager) GetNetworkTree

func (m *ProposalManager) GetNetworkTree(blockNumber uint32, snapshot *VotingInfoSnapshot) (*NetworkVotingTree, error)

func (*ProposalManager) GetNodeTree

func (m *ProposalManager) GetNodeTree(blockNumber uint32, nodeIndex uint64, snapshot *VotingInfoSnapshot) (*NodeVotingTree, error)

func (*ProposalManager) GetPollardForProposal

func (m *ProposalManager) GetPollardForProposal(blockNumber uint32) ([]*types.VotingTreeNode, error)

func (*ProposalManager) GetVotingInfoSnapshot

func (m *ProposalManager) GetVotingInfoSnapshot(blockNumber uint32) (*VotingInfoSnapshot, error)

type VotingInfoSnapshot

type VotingInfoSnapshot struct {
	SmartnodeVersion string                 `json:"smartnodeVersion"`
	Network          nmc_config.Network     `json:"network"`
	BlockNumber      uint32                 `json:"blockNumber"`
	Info             []types.NodeVotingInfo `json:"info"`
}

A network voting tree

func (VotingInfoSnapshot) GetFilename

func (t VotingInfoSnapshot) GetFilename() string

Get the filename of the network voting tree, including the block number it's built against

type VotingInfoSnapshotManager

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

Struct for voting info snapshots

func NewVotingInfoSnapshotManager

func NewVotingInfoSnapshotManager(logger *slog.Logger, cfg *config.SmartNodeConfig, rp *rocketpool.RocketPool) (*VotingInfoSnapshotManager, error)

Create a new VotingInfoSnapshotManager instance

func (*VotingInfoSnapshotManager) CreateVotingInfoSnapshot

func (m *VotingInfoSnapshotManager) CreateVotingInfoSnapshot(blockNumber uint32) (*VotingInfoSnapshot, error)

Create a voting info snapshot from the given block

func (*VotingInfoSnapshotManager) IsDataValid

func (m *VotingInfoSnapshotManager) IsDataValid(data *VotingInfoSnapshot, filename string, context uint32) (bool, error)

Return true if the loaded snapshot can be used for processing

func (*VotingInfoSnapshotManager) Less

func (m *VotingInfoSnapshotManager) Less(firstFilename string, secondFilename string) (bool, error)

Return true if the first filename represents a block number that's lower than the second filename's block number

func (*VotingInfoSnapshotManager) LoadFromDisk

func (m *VotingInfoSnapshotManager) LoadFromDisk(blockNumber uint32) (*VotingInfoSnapshot, error)

Load the snapshot for the provided block from disk if it exists

func (*VotingInfoSnapshotManager) SaveToFile

func (m *VotingInfoSnapshotManager) SaveToFile(snapshot *VotingInfoSnapshot) error

Save a snapshot to a file

func (*VotingInfoSnapshotManager) ShouldLoadEntry

func (m *VotingInfoSnapshotManager) ShouldLoadEntry(filename string, context uint32) (bool, error)

Return true if the filename matches the block number provided in the context

type VotingTree

type VotingTree struct {
	SmartnodeVersion string                  `json:"smartnodeVersion"`
	Network          config.Network          `json:"network"`
	BlockNumber      uint32                  `json:"blockNumber"`
	Depth            uint64                  `json:"depth"`
	VirtualRootIndex uint64                  `json:"virtualRootIndex"`
	DepthPerRound    uint64                  `json:"depthPerRound"`
	Nodes            []*types.VotingTreeNode `json:"nodes"`
}

func CreateTreeFromLeaves

func CreateTreeFromLeaves(blockNumber uint32, network config.Network, leaves []*types.VotingTreeNode, virtualRootIndex uint64, depthPerRound uint64) *VotingTree

Creates a new NetworkVotingPowerTree instance from leaf nodes.

func (*VotingTree) CheckForChallengeableArtifacts

func (t *VotingTree) CheckForChallengeableArtifacts(virtualRootIndex uint64, proposedPollard []types.VotingTreeNode) (uint64, *types.VotingTreeNode, []*types.VotingTreeNode, error)

Compare a pollard used in a proposal / root submission with the corresponding pollard in this tree, getting the challenge artifacts for the first mismatch

func (*VotingTree) GetArtifactsForChallengeResponse

func (t *VotingTree) GetArtifactsForChallengeResponse(challengedIndex uint64) (*types.VotingTreeNode, []*types.VotingTreeNode)

Create a pollard for a challenged tree node, to be used as a challenge response

func (*VotingTree) GetPollardForProposal

func (t *VotingTree) GetPollardForProposal() (*types.VotingTreeNode, []*types.VotingTreeNode)

Create a pollard from the tree's root node, to be used for new proposals

Jump to

Keyboard shortcuts

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