def pull_query(self, msg: Msg, peer: Peer): avaxpython.config().logger().debug("Handling pull_query : Msg {} Peer {}".format(msg, peer)) chain_id = ID(msg.fields[Field.ChainID]) request_id = msg.fields[Field.RequestID] container_id = ID(msg.fields[Field.ContainerID]) deadline = msg.fields[Field.Deadline] peer.net.router.PullQuery(chain_id, request_id, deadline, container_id)
def get_ancestors(self, msg: Msg, peer: Peer): avaxpython.config().logger().debug("Handling get_ancestors : Msg {} Peer {}".format(msg, peer)) chain_id = ID(msg.fields[Field.ChainID]) request_id = msg.fields[Field.RequestID] container_id = ID(msg.fields[Field.ContainerID]) deadline = msg.fields[Field.Deadline] peer.net.router.GetAncestors(peer.id, chain_id, request_id, deadline, container_id)
def put(self, msg: Msg, peer: Peer): avaxpython.config().logger().debug("Handling put : Msg {} Peer {}".format(msg, peer)) chain_id = ID(msg.fields[Field.ChainID]) request_id = msg.fields[Field.RequestID] container = msg.fields[Field.ContainerBytes] container_id = ID(msg.fields[Field.ContainerID]) peer.net.router.Put(peer.id, chain_id, request_id, container_id, container)
def __init__(self, txid: ID = ID(), output_index: Uint32 = 0, symbol: bool = False, idx: ID = ID()): self.TxID: ID = txid self.OutputIndex = Uint32(output_index) # Symbol is false if the UTXO should be part of the DB self.Symbol: bool = symbol # id is the unique ID of a UTXO, it is calculated from TxID and OutputIndex self.id: ID = idx
def __init__(self, NetworkID: int = 0, SubnetID: ID = ID(), chain_id: ID = ID(), NodeID: ShortID = ShortID(), x_chain_id: ID = ID(), AVAXAssetID: ID = ID(), Log=None, DecisionDispatcher=None, ConsensusDispatcher=None, Lock=None, Keystore=None, SharedMemory=None, BCLookup=None, SNLookup=None, Namespace: str = "", Metrics=None, EpochFirstTransition=None, EpochDuration=None, Clock=None, bootstrapped: int = 0): """Context is information about the current execution. [NetworkID] is the ID of the network this context exists within. [chain_id] is the ID of the chain this context exists within. [NodeID] is the ID of this node""" self.NetworkID: int = NetworkID self.SubnetID: ID = SubnetID self.chain_id: ID = chain_id self.NodeID: ShortID = NodeID self.Xchain_id: ID = x_chain_id self.AVAXAssetID: ID = AVAXAssetID self.Log = Log self.DecisionDispatcher = DecisionDispatcher self.ConsensusDispatcher = ConsensusDispatcher self.Lock = Lock self.Keystore = Keystore self.SharedMemory = SharedMemory self.BCLookup = BCLookup self.SNLookup = SNLookup self.Namespace: str = Namespace self.Metrics = Metrics # Epoch management self.EpochFirstTransition = EpochFirstTransition self.EpochDuration = EpochDuration self.Clock = Clock # Non-zero iff this chain bootstrapped. Should only be accessed atomically. self.bootstrapped: int = bootstrapped
def __init__(self) -> None: super().__init__() self.NetworkID = Uint32() self.BlockchainID = ID() self.Outs = Slice() self.Ins = Slice() self.Memo = Slice()
def __init__(self) -> None: # Metadata, inputs and outputs self.BaseTx = BaseTx() # ID of the Subnet that validates this blockchain self.SubnetID = ID() # A human readable name for the chain; need not be unique self.ChainName = str() # ID of the VM running on the new chain self.VMID = ID() # IDs of the feature extensions running on the new chain self.FxIDs = Slice() # Byte representation of genesis state of the new chain self.GenesisData = Bytes() # Auth that will be allowing this validator into the network self.SubnetAuth = Verifiable()
def FromConfig(config: Config) -> Tuple[bytes, ID]: """FromConfig returns: 1) The byte representation of the genesis state of the platform chain (ie the genesis state of the network) 2) The asset ID of AVAX""" ret_b = b"" ret_id = ID() return ret_b, ret_id
def __init__(self) -> None: self.Version: int = Uint16(0) self.ChainID: ID = ID() self.Height: int = Uint64(0) self.Epoch: int = Uint32(0) self.ParentIDs: List[ID] = Slice() self.Txs = ByteSlices() self.Restrictions: List[ID] = Slice()
def __init__(self) -> None: self.BaseTx = BaseTx() # Which chain to send the funds to self.DestinationChain = ID() # Outputs that are exported to the chain self.ExportedOutputs = Slice()
def __init__(self) -> None: self.BaseTx = BaseTx() # Which chain to send the funds to self.DestinationChain = ID() # The outputs this transaction is sending to the other chain self.ExportedOuts = Slice()
def __init__(self) -> None: avax.Metadata # ID of the tx that created the delegator/validator being removed/rewarded TxID = ID() # Marks if this validator should be rewarded according to this node. self.shouldPreferCommit = Bool()
def __init__(self) -> None: self.BaseTx = BaseTx() # Which chain to consume the funds from self.SourceChain = ID() # Inputs that consume UTXOs produced on the chain self.ImportedInputs = Slice()
def __init__(self) -> None: self.State = SnowmanState() # VersionDB on top of underlying database # Important note: In order for writes to [DB] to be persisted, # DB.Commit() must be called # We use a versionDB here so user can do atomic commits as they see fit self.DB = None # The context of this vm self.Ctx = SnowContext() # ID of the preferred block self.preferred = ID() # ID of the last accepted block self.LastAcceptedID = ID() # unmarshals bytes to a block self.unmarshalBlockFunc = None # channel to send messages to the consensus engine self.ToEngine = None
def Initialize(self, Version, ChainID, Height, Epoch, ParentIDs, Txs, Restrictions, idx: ID = ID(), bbytes: bytes = Bytes(), innerStatelessVertex=None) -> None: super().Initialize(Version, ChainID, Height, Epoch, ParentIDs, Txs, Restrictions) # cache the ID of this vertex self.id: ID = idx # cache the binary format of this vertex self.bytes: bytes = bbytes self.innerStatelessVertex = innerStatelessVertex
def get_accepted_frontier(self, msg: Msg, peer: Peer): avaxpython.config().logger().debug("Handling get_accepted_frontier : Msg {} Peer {}".format(msg, peer)) chain_id = ID(msg.fields[Field.ChainID]) request_id = msg.fields[Field.RequestID] deadline = int(peer.net.clock.time() + msg.fields[Field.Deadline]) peer.net.router.GetAcceptedFrontier(peer.id, chain_id, request_id, deadline)
Donations address: X-avax1qr6yzjykcjmeflztsgv6y88dl0xnlel3chs3r4 Thank you! """ # --#--#-- from avaxpython.ids.ID import ID from avaxpython.vms.components.core.snowman_state import SnowmanState from avaxpython.snow.context import Context as SnowContext errBadData = TypeError("got unexpected value from database") # If the status of this ID is not choices.Accepted, # the db has not yet been initialized dbInitializedID = ID(b'db init') class SnowmanVM: """SnowmanVM provides the core functionality shared by most snowman vms""" def __init__(self) -> None: self.State = SnowmanState() # VersionDB on top of underlying database # Important note: In order for writes to [DB] to be persisted, # DB.Commit() must be called # We use a versionDB here so user can do atomic commits as they see fit self.DB = None # The context of this vm
def Empty(): return ID()
def __init__(self) -> None: self.Validator = Validator() self.Subnet = ID()
def ToID(bts: bytes) -> bytes: n = hashlib.new('sha256') n.update(bts) return ID(n.digest())
def __init__(self) -> None: self.id = ID() self.status = Status() self.bytes = Bytes()
def chits(self, msg: Msg, peer: Peer): avaxpython.config().logger().debug("Handling chits : Msg {} Peer {}".format(msg, peer)) chain_id = ID(msg.fields[Field.ChainID]) request_id = msg.fields[Field.RequestID] votes = msg.fields[Field.ContainerIDs] peer.net.router.Chits(chain_id, request_id, votes)
def __init__(self): self.EnableP2PTLS = True self.TxFee=0 # Transaction fee for transactions that create new state self.CreationTxFee=0 # Staking uptime requirements self.UptimeRequirement=0.0 # Minimum stake, in nAVAX, required to validate the primary network self.MinValidatorStake=0 # Maximum stake, in nAVAX, allowed to be placed on a single validator in # the primary network self.MaxValidatorStake=0 # Minimum stake, in nAVAX, that can be delegated on the primary network self.MinDelegatorStake=0 # Minimum delegation fee, in the range [0, 1000000], that can be charged # for delegation on the primary network. self.MinDelegationFee=0 # MinStakeDuration is the minimum amount of time a validator can validate # for in a single period. self.MinStakeDuration=60 # MaxStakeDuration is the maximum amount of time a validator can validate # for in a single period. self.MaxStakeDuration=0 # StakeMintingPeriod is the amount of time for a consumption period. self.StakeMintingPeriod=0 # EpochFirstTransition is the time that the transition from epoch 0 to 1 # should occur. self.EpochFirstTransition=0 # EpochDuration is the amount of time that an epoch runs for. self.EpochDuration=0 # Time that Apricot phase 0 rules go into effect self.ApricotPhase0Time=0 # protocol to use for opening the network interface self.Nat = None # TODO nat.Router # Attempted NAT Traversal did we attempt self.AttemptedNATTraversal = False # ID of the network this node should connect to self.NetworkID = 0 # Assertions configuration self.EnableAssertions = True # Crypto configuration self.EnableCrypto = True # Database to use for the node self.DB = None # TODO database.Database # Staking configuration # TODO obtain IP : port from configuration self.StakingIP : DynamicIPDesc = DynamicIPDesc("0.0.0.0", 9651) self.EnableP2PTLS = True # TODO bool self.EnableStaking = True # TODO bool self.StakingKeyFile = "" # TODO string self.StakingCertFile = "" # TODO string self.DisabledStakingWeight = 0 # TODO uint64 # Throttling self.MaxNonStakerPendingMsgs=0 # TODO uint32 self.StakerMSGPortion=0.0 # TODO float64 self.StakerCPUPortion=0.0 # TODO float64 self.SendQueueSize=0 # TODO uint32 self.MaxPendingMsgs=0 # TODO uint32 # Network configuration self.NetworkConfig = None # TODO timer.AdaptiveTimeoutConfig # Benchlist Configuration self.BenchlistConfig = None # TODO benchlist.Config # Bootstrapping configuration self.BootstrapPeers = [] # TODO []*Peer # HTTP configuration self.HTTPHost = "" # TODO string self.HTTPPort = 0 # TODO uint16 self.HTTPSEnabled = True # TODO bool self.HTTPSKeyFile = "" # TODO string self.HTTPSCertFile = "" # TODO string self.APIRequireAuthToken = True # bool self.APIAuthPassword = "" # TODO string # Enable/Disable APIs self.AdminAPIEnabled = False # TODO bool self.InfoAPIEnabled = False # TODO bool self.KeystoreAPIEnabled = False # TODO bool self.MetricsAPIEnabled = False # TODO bool self.HealthAPIEnabled = False # TODO bool # Logging configuration self.LoggingConfig = None # TODO logging.Config # Plugin directory self.PluginDir = "" # TODO string # Consensus configuration self.ConsensusParams = AvalancheParams() # Throughput configuration self.ThroughputPort = 0 # TODO uint16 self.ThroughputServerEnabled = False # TODO bool # IPC configuration self.IPCAPIEnabled = False # TODO bool self.IPCPath = "" # TODO string self.IPCDefaultChainIDs = [] # TODO []string # Router that is used to handle incoming consensus messages self.ConsensusRouter : ChainRouter = None self.ConsensusGossipFrequency = 30 # TODO time.Duration self.ConsensusShutdownTimeout = 60 # TODO time.Duration # Dynamic Update duration for IP or NAT traversal self.DynamicUpdateDuration = 60 # TODO time.Duration self.DynamicPublicIPResolver = None # TODO dynamicip.Resolver # Throttling incoming connections self.ConnMeterResetDuration = 120 # TODO time.Duration self.ConnMeterMaxConns = 30 # TODO int # Subnet Whitelist self.WhitelistedSubnets = {} # TODO ids.Set # Restart on disconnect settings self.RestartOnDisconnected = True # TODO bool self.DisconnectedCheckFreq = 60 # TODO time.Duration self.DisconnectedRestartTimeout = 60 # TODO time.Duration # Coreth self.CorethConfig = "" # TODO string self.AvaxAssetID = ID(bytearray.fromhex(constants.AvaxAssetIDBytesHex)) self.GenesisBytes: bytes = None
def __init__(self, id: ID = ID()) -> None: self.ID: ID = id
Help support this Open Source project! Donations address: X-avax1qr6yzjykcjmeflztsgv6y88dl0xnlel3chs3r4 Thank you! """ # --#--#-- from avaxpython.ids.ID import ID from avaxpython.vms.components.state.state import State from avaxpython.snow.consensus.snowman.block import Block as SnowmanBlock errWrongType = TypeError("got unexpected type from database") # state.Get(Db, IDTypeID, lastAcceptedID) == ID of last accepted block lastAcceptedID = ID(b'last') class SnowmanState(State): """SnowmanState is a wrapper around state.State In additions to the methods exposed by state.State, SnowmanState exposes a few methods needed for managing state in a snowman vm""" _avax_interface = True def __init__(self) -> None: super().__init__() def GetBlock(db, block_id) -> SnowmanBlock: pass
def accepted(self, msg: Msg, peer: Peer): avaxpython.config().logger().debug("Handling accepted : Msg {} Peer {}".format(msg, peer)) chain_id = ID(msg.fields[Field.ChainID]) request_id = msg.fields[Field.RequestID] container_ids = msg.fields[Field.ContainerIDs] peer.net.router.Accepted(chain_id, request_id, container_ids)
def __init__(self) -> None: self.Metadata = Metadata() self.PrntID = ID() self.Hght = Uint64() self.VM = SnowmanVM()