BlockKeeperPreEpochContract.sol

Overview

The BlockKeeperPreEpochContract.sol file defines the BlockKeeperPreEpoch smart contract, which serves as a preparatory contract within a blockchain node management and epoch lifecycle system. Its primary function is to manage the pre-epoch phase, including initialization of node wallets, stake locking, and transitioning to the main epoch contract after a specified delay. This contract handles the configuration and setup necessary before an epoch begins, such as managing reputation coefficients, licenses, stakes, and proxy lists.

This contract interacts closely with other contracts and libraries like AckiNackiBlockKeeperNodeWallet, BlockKeeperEpoch, BlockKeeperEpochProxyList, and utility libraries such as BlockKeeperLib. It enforces strict authorization and consistency checks to ensure secure deployment and management of epochs.


Contract: BlockKeeperPreEpoch

Properties


Constructor

constructor (
    uint64 waitStep,
    uint64 epochDuration,
    bytes bls_pubkey,
    mapping(uint8 => TvmCell) code,
    uint16 signerIndex, 
    uint128 rep_coef,
    LicenseStake[] licenses,
    optional(uint128) virtualStake,
    mapping(uint8 => string) ProxyList,
    uint128 reward_sum,
    string myIp,
    uint64 epochCliff,
    optional(string) nodeVersion
)
BlockKeeperPreEpoch preEpoch = new BlockKeeperPreEpoch(
    10, // waitStep
    1000, // epochDuration
    blsPubKeyBytes,
    codeMapping,
    2, // signerIndex
    12345, // rep_coef
    licensesArray,
    optionalVirtualStake,
    proxyListMapping,
    100000, // reward_sum
    "192.168.1.1", // myIp
    5, // epochCliff
    optionalNodeVersion
);

Functions

ensureBalance()

private pure

destroy(bool isProxyDelete)

public view senderIs(address(this)) accept

touch()

public pure accept

touchIn()

public senderIs(address(this)) accept

cancelPreEpoch()

public senderIs(_wallet) accept

receive() external


Getters

getDetails()

external view returns(
    uint256 pubkey,
    address root, 
    uint64 seqNoStart,
    address owner
)

getVersion()

external pure returns(string, string)

Important Implementation Details


Interactions with Other Contracts and Libraries


Visual Diagram: Contract Structure and Workflow

classDiagram
class BlockKeeperPreEpoch {
-string version
-mapping _code
-uint256 _owner_pubkey
-address _root
-uint64 _seqNoStart
-uint64 _seqNoDestruct
-uint64 _epochDuration
-uint64 _waitStep
-bytes _bls_pubkey
-varuint32 _stake
-uint16 _signerIndex
-uint128 _sumReputationCoef
-LicenseStake[] _licenses
-address _wallet
-optional(uint128) _virtualStake
-uint128 _reward_sum
-string _myIp
-bool isDestroy
-optional(string) _nodeVersion
+constructor()
+ensureBalance()
+destroy(isProxyDelete)
+touch()
+touchIn()
+cancelPreEpoch()
+getDetails()
+getVersion()
+receive()
}
class AckiNackiBlockKeeperNodeWallet
class BlockKeeperEpoch
class BlockKeeperEpochProxyList
class BlockKeeperLib
BlockKeeperPreEpoch ..> AckiNackiBlockKeeperNodeWallet : interacts with
BlockKeeperPreEpoch ..> BlockKeeperEpoch : deploys
BlockKeeperPreEpoch ..> BlockKeeperEpochProxyList : deploys & destroys
BlockKeeperPreEpoch ..> BlockKeeperLib : uses utilities

Usage Scenario / Workflow

  1. Deployment:
    BlockKeeperPreEpoch is deployed by the node's wallet contract, passing initialization parameters such as stake, keys, reputation, and proxy list.

  2. Stake Locking:
    Upon deployment, the node's stake is locked via the wallet contract.

  3. Proxy List Setup:
    A proxy list contract is deployed to manage proxy nodes for the upcoming epoch.

  4. Waiting Period:
    The contract waits for the specified waitStep and epochDuration before transitioning.

  5. Transition:
    The touch() function is called (externally or internally), which triggers touchIn(). This deploys the BlockKeeperEpoch contract, starting the active epoch.

  6. Destruction:
    If the pre-epoch expires or is canceled, the contract calls destroy(), unlocking stakes and optionally deleting the proxy list.

  7. Lifecycle Control:
    The wallet owner can cancel the pre-epoch at any time by calling cancelPreEpoch().


This contract is critical in orchestrating the node's lifecycle from initialization and stake locking to active epoch participation, ensuring secure and orderly transitions and resource management. For further details on related components, see the contracts and libraries referenced here.