AckiNackiBlockKeeperNodeWallet.sol

Overview

AckiNackiBlockKeeperNodeWallet.sol implements a smart contract that serves as the wallet for a BlockKeeper node within the Acki Nacki blockchain ecosystem. This contract manages stakes, licenses, and interactions with various BlockKeeper-related contracts such as pre-epoch, epoch, and cooler contracts. It handles the lifecycle of stakes, license management, slashing mechanisms, and communication with the root contract and other components managing epochs and consensus.

The contract stores and controls a collection of active stakes, license data, and code references for deployed contracts. It enforces permissions based on the owner's public key and contract addresses derived from known code cells, ensuring secure and verifiable management of node wallet state.


Contract: AckiNackiBlockKeeperNodeWallet

This contract inherits from Modifiers and manages:

State Variables


Constructor

constructor (
    TvmCell BlockKeeperPreEpochCode,
    TvmCell AckiNackiBlockKeeperNodeWalletCode,
    TvmCell BlockKeeperEpochCode,
    TvmCell BlockKeeperEpochCoolerCode,
    TvmCell BlockKeeperEpochProxyListCode,
    TvmCell BLSKeyCode,
    TvmCell SignerIndexCode,
    TvmCell LicenseCode,
    uint128 epochDuration,
    uint32 freeLicense,
    mapping(uint256=>bool) whiteListLicense,
    address licenseRoot,
    uint8 stakesCnt,
    uint8 walletTouch
)

Usage Example

new AckiNackiBlockKeeperNodeWallet(
    preEpochCode,
    nodeWalletCode,
    epochCode,
    coolerCode,
    proxyListCode,
    blsKeyCode,
    signerIndexCode,
    licenseCode,
    3600,
    100,
    whiteList,
    licenseRootAddr,
    0,
    10
);

Key Functions

1. setSigningPubkey

function setSigningPubkey(uint256 pubkey) public onlyOwnerPubkey(_owner_pubkey) accept

2. checkCooler

function checkCooler() private view returns(bool result)

3. License Management Functions

These functions ensure licenses are properly managed with respect to stake locking, balance, and privilege status.


4. Stake Lifecycle Management

These functions orchestrate the transition of stakes and licenses through pre-epoch, epoch, and cooler phases.


5. Slashing Mechanisms

Slashing is used to penalize misbehaving stakes, reducing their balances and removing privileges.


6. Token Withdrawals

Both methods ensure tokens are withdrawn only when not locked or during stake operations.


7. Utility and Helpers


Important Implementation Details and Algorithms


Interaction with Other Contracts

The wallet acts as a central state manager, coordinating between licenses, stakes, and different phases of staking through these contracts.


Data Structures


Error Handling

The contract uses require statements with error constants such as:

These ensure operations are valid and preserve contract invariants.


Mermaid Class Diagram

classDiagram
class AckiNackiBlockKeeperNodeWallet {
-string version
-mapping(uint8 => TvmCell) _code
-uint256 static _owner_pubkey
-address _root
-mapping(uint256 => Stake) _activeStakes
-uint8 _stakesCnt
-bool _isContinue
-mapping(uint256 => LicenseData) _licenses
-uint128 _licenses_count
-uint128 _epochDuration
-uint32 _freeLicense
-bool _isWaitStake
-uint128 _balance
-mapping(uint256 => bool) _whiteListLicense
-address _licenseRoot
-bool _isSlashing
-uint64 _walletLastTouch
-uint256 _signing_pubkey
-uint8 _walletTouch
+constructor(...)
+setSigningPubkey(pubkey)
+checkCooler() bool
+setLockToStake(license_number, lock)
+setLockToStakeByWallet(license_number, lock)
+removeLicense(license_number)
+setLicenseWhiteList(whiteListLicense)
+addLicense(license_number, reputationTime, last_touch, isPrivileged)
+addBalance(license_number)
+deleteLicense(license_number)
+setLockStake(seqNoStart, stake, bls_key, signerIndex, licenses)
+deleteLockStake(seqNoStart, bls_key, signerIndex, licenses)
+slash(slash_type, bls_key)
+updateLockStake(seqNoStart, seqNoFinish, stake, bls_key, signerIndex, licenses)
+stakeNotAccepted(epochDuration)
+stakeNotAcceptedContinue(epochDuration)
+sendBlockKeeperRequestWithStake(bls_pubkey, stake, signerIndex, ProxyList, myIp, nodeVersion)
+sendBlockKeeperRequestWithStakeContinue(bls_pubkey, stake, seqNoStartOld, signerIndex, ProxyList, nodeVersion)
+deployPreEpochContract(epochDuration, walletTouch, epochCliff, waitStep, bls_pubkey, signerIndex, rep_coef, virtualStake, ProxyList, reward_sum, myIp, nodeVersion)
+deployBlockKeeperContractContinue(walletTouch, seqNoStartold, bls_pubkey, signerIndex, virtualStake, ProxyList, sumReputationCoef, nodeVersion)
+cancelContinueStake(seqNoStartOld, bls_key, signerIndex, licenses)
+continueStakeAccept(seqNoStartOld)
+continueStakeNotAccept(seqNoStartOld, bls_key, signerIndex, licenses)
+updateLockStakeCooler(seqNoStart, seqNoFinish, licenses, isContinue, addReputationTime)
+unlockStakeCooler(seqNoStart, licenses, stake)
+slashCooler(seqNoStart, slash_type, slash_stake, licenses, isFromEpoch)
+slashStake(seqNoStart, slash_type, slash_stake, licenses, isContinue, bls_key_continue, signerIndex_continue, licenses_continue)
+withdrawToken(license_number, value)
+withdrawWalletToken(to, value)
+resetWallet()
+getDetails() returns (...)
+getEpochAddress() returns (optional(address))
+getSumBalanceForStake() returns (uint128)
+getProxyListAddr() returns (address)
+getProxyListCodeHash() returns (uint256)
+getProxyListCode() returns (TvmCell)
+getVersion() returns (string, string)
}

Notes on Interactions and Security

Refer to Modifiers for permission enforcement details and BlockKeeperLib for address calculation and utility methods used in this contract. Stake and license data structures and related constants are defined in imported files such as BLSKeyIndex.sol, SignerIndex.sol, and License.sol.


End of Documentation for AckiNackiBlockKeeperNodeWallet.sol