genesis

package
v0.0.0-...-fb6e132 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: LGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyNetworkRulesPatch

func ApplyNetworkRulesPatch(rules *opera.Rules, patch NetworkRulesPatch) error

func DeriveValidatorKey

func DeriveValidatorKey(id int) (privKeyHex string, pubKey string, address string, err error)

DeriveValidatorKey derives a fake validator private key, pubkey and address from validator ID.

func GenerateJsonGenesis

func GenerateJsonGenesis(
	jsonFile string,
	validatorStakes []uint64,
	rules *opera.Rules,
	clientVersions []string,
) error

GenerateJsonGenesis generates a genesis json file with the given number of validators and network rules configurations. The file is written to the given path.

Every node of a network imports the same file, so the parts of it that depend on the client version - currently the subsidies registry - are chosen to suit the oldest client of the network. The versions are the ones the clients report for themselves; see docker.ClientVersions.

func ValidateNetworkRulesPatch

func ValidateNetworkRulesPatch(patch NetworkRulesPatch) error

func WriteValidatorKeystore

func WriteValidatorKeystore(privKeyHex, datastoreDir string) error

WriteValidatorKeystore writes a validator key to a sonic-compatible keystore in datastoreDir.

Types

type BigIntValue

type BigIntValue big.Int

BigIntValue accepts YAML scalar values for big integers.

func (BigIntValue) MarshalJSON

func (b BigIntValue) MarshalJSON() ([]byte, error)

func (BigIntValue) MarshalYAML

func (b BigIntValue) MarshalYAML() (any, error)

func (*BigIntValue) UnmarshalJSON

func (b *BigIntValue) UnmarshalJSON(data []byte) error

func (*BigIntValue) UnmarshalYAML

func (b *BigIntValue) UnmarshalYAML(node *yaml.Node) error

type BlocksPatch

type BlocksPatch struct {
	MaxBlockGas             *uint64   `yaml:"MaxBlockGas,omitempty" json:"MaxBlockGas,omitempty"`
	MaxEmptyBlockSkipPeriod *Duration `yaml:"MaxEmptyBlockSkipPeriod,omitempty" json:"MaxEmptyBlockSkipPeriod,omitempty"`
}

type DagPatch

type DagPatch struct {
	MaxParents     *uint64 `yaml:"MaxParents,omitempty" json:"MaxParents,omitempty"`
	MaxFreeParents *uint64 `yaml:"MaxFreeParents,omitempty" json:"MaxFreeParents,omitempty"`
	MaxExtraData   *uint32 `yaml:"MaxExtraData,omitempty" json:"MaxExtraData,omitempty"`
}

type Duration

type Duration inter.Timestamp

Duration is a YAML/JSON helper for inter.Timestamp fields. It accepts either duration strings (e.g. "15s") or integer nanoseconds.

func NewDuration

func NewDuration(d time.Duration) *Duration

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(node *yaml.Node) error

type EconomyPatch

type EconomyPatch struct {
	BlockMissedSlack *uint64        `yaml:"BlockMissedSlack,omitempty" json:"BlockMissedSlack,omitempty"`
	Gas              *GasPatch      `yaml:"Gas,omitempty" json:"Gas,omitempty"`
	MinGasPrice      *BigIntValue   `yaml:"MinGasPrice,omitempty" json:"MinGasPrice,omitempty"`
	MinBaseFee       *BigIntValue   `yaml:"MinBaseFee,omitempty" json:"MinBaseFee,omitempty"`
	ShortGasPower    *GasPowerPatch `yaml:"ShortGasPower,omitempty" json:"ShortGasPower,omitempty"`
	LongGasPower     *GasPowerPatch `yaml:"LongGasPower,omitempty" json:"LongGasPower,omitempty"`
}

type EmitterPatch

type EmitterPatch struct {
	Interval        *Duration `yaml:"Interval,omitempty" json:"Interval,omitempty"`
	StallThreshold  *Duration `yaml:"StallThreshold,omitempty" json:"StallThreshold,omitempty"`
	StalledInterval *Duration `yaml:"StalledInterval,omitempty" json:"StalledInterval,omitempty"`
}

type EpochsPatch

type EpochsPatch struct {
	MaxEpochGas      *uint64   `yaml:"MaxEpochGas,omitempty" json:"MaxEpochGas,omitempty"`
	MaxEpochDuration *Duration `yaml:"MaxEpochDuration,omitempty" json:"MaxEpochDuration,omitempty"`
}

type GasPatch

type GasPatch struct {
	MaxEventGas          *uint64 `yaml:"MaxEventGas,omitempty" json:"MaxEventGas,omitempty"`
	EventGas             *uint64 `yaml:"EventGas,omitempty" json:"EventGas,omitempty"`
	ParentGas            *uint64 `yaml:"ParentGas,omitempty" json:"ParentGas,omitempty"`
	ExtraDataGas         *uint64 `yaml:"ExtraDataGas,omitempty" json:"ExtraDataGas,omitempty"`
	BlockVotesBaseGas    *uint64 `yaml:"BlockVotesBaseGas,omitempty" json:"BlockVotesBaseGas,omitempty"`
	BlockVoteGas         *uint64 `yaml:"BlockVoteGas,omitempty" json:"BlockVoteGas,omitempty"`
	EpochVoteGas         *uint64 `yaml:"EpochVoteGas,omitempty" json:"EpochVoteGas,omitempty"`
	MisbehaviourProofGas *uint64 `yaml:"MisbehaviourProofGas,omitempty" json:"MisbehaviourProofGas,omitempty"`
}

type GasPowerPatch

type GasPowerPatch struct {
	AllocPerSec        *uint64   `yaml:"AllocPerSec,omitempty" json:"AllocPerSec,omitempty"`
	MaxAllocPeriod     *Duration `yaml:"MaxAllocPeriod,omitempty" json:"MaxAllocPeriod,omitempty"`
	StartupAllocPeriod *Duration `yaml:"StartupAllocPeriod,omitempty" json:"StartupAllocPeriod,omitempty"`
	MinStartupGas      *uint64   `yaml:"MinStartupGas,omitempty" json:"MinStartupGas,omitempty"`
}

type NetworkRulesPatch

type NetworkRulesPatch struct {
	Dag      *DagPatch      `yaml:"Dag,omitempty" json:"Dag,omitempty"`
	Emitter  *EmitterPatch  `yaml:"Emitter,omitempty" json:"Emitter,omitempty"`
	Epochs   *EpochsPatch   `yaml:"Epochs,omitempty" json:"Epochs,omitempty"`
	Blocks   *BlocksPatch   `yaml:"Blocks,omitempty" json:"Blocks,omitempty"`
	Economy  *EconomyPatch  `yaml:"Economy,omitempty" json:"Economy,omitempty"`
	Upgrades *UpgradesPatch `yaml:"Upgrades,omitempty" json:"Upgrades,omitempty"`
}

NetworkRulesPatch defines a set of network rules that can be applied to the network. Network rules contains all the fields in sonic's opera.Rules, but all fields are optional and only the non-nil fields will be applied to the network.

This type is used to define the initial rule set in the genesis, by applying the diff to the default rules: opera.FakeNetRules(opera.GetSonicUpgrades()) Additionally it can be sent serialized using json to change the network rules during execution.

func NewRulesPatchFromOperaRules

func NewRulesPatchFromOperaRules(rules opera.Rules) (NetworkRulesPatch, error)

func (*NetworkRulesPatch) PrettyPrint

func (p *NetworkRulesPatch) PrettyPrint() string

func (*NetworkRulesPatch) UnmarshalYAML

func (p *NetworkRulesPatch) UnmarshalYAML(node *yaml.Node) error

type UpgradesPatch

type UpgradesPatch struct {
	Berlin                       *bool `yaml:"Berlin,omitempty" json:"Berlin,omitempty"`
	London                       *bool `yaml:"London,omitempty" json:"London,omitempty"`
	Llr                          *bool `yaml:"Llr,omitempty" json:"Llr,omitempty"`
	Sonic                        *bool `yaml:"Sonic,omitempty" json:"Sonic,omitempty"`
	Allegro                      *bool `yaml:"Allegro,omitempty" json:"Allegro,omitempty"`
	Brio                         *bool `yaml:"Brio,omitempty" json:"Brio,omitempty"`
	SingleProposerBlockFormation *bool `yaml:"SingleProposerBlockFormation,omitempty" json:"SingleProposerBlockFormation,omitempty"`
	GasSubsidies                 *bool `yaml:"GasSubsidies,omitempty" json:"GasSubsidies,omitempty"`
	TransactionBundles           *bool `yaml:"TransactionBundles,omitempty" json:"TransactionBundles,omitempty"`
	TransactionPriorities        *bool `yaml:"TransactionPriorities,omitempty" json:"TransactionPriorities,omitempty"`
}

Jump to

Keyboard shortcuts

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