2

I've setup a small network with two nodes using authorityRound engine (parity). My question is about the mining. If I have two validators (A and B), who will mining the blocks? the node A or B?

I ask because in my block explorer I see always that the author is the same:

For example, I see something like this:

block | hash | author

1 | 0x.. | A

2 | 0x.. | A

3 | 0x.. | A

4 | 0x.. | A

n | 0x.. | A

Thanks in advance.

UPDATE:

I'm using this settings:

  • genesis chain

enter image description here

  • The Smart contract for to manage the validators was copied from https://github.com/paritytech/contracts/issues/96

    contract AdminValidatorList { address public owner;

    address[] public validatorList = [<your first validator address>];
    address[] public pendingList = [<your first validator address>];
    
    mapping(address => bool) public isAdmin;
    
    modifier onlyAdmin() {
        require(isAdmin[msg.sender] == true);
        _;
    }
    
    event validatorAdded(address newvalidator);
    event validatorRemoved(address oldvalidator);
    event adminAdded(address newadmin);
    event adminRemoved(address oldadmin);
    event InitiateChange(bytes32 indexed _parent_hash, address[] _new_set);
    
    function AdminValidatorList() public {
        isAdmin[validatorList[0]] = true;       
    }
    
    // Called on every block to update node validator list.
    function getValidators() public constant returns (address[] _validators) {
        return validatorList;
    }
    
    function getPendingValidators() public constant returns (address[] _p) {
        return pendingList;
    }
    
    // Add a validator to the list.
    function addValidator(address validator) public onlyAdmin {
        for (uint i = 0; i < pendingList.length; i++) {
            require(pendingList[i] != validator);
        }
    
        pendingList.push(validator);
        validatorAdded(validator);
        InitiateChange(block.blockhash(block.number - 1),pendingList);
    }
    
    // Remove a validator from the list.
    function removeValidator(address validator) public onlyAdmin returns (bool success){
    
        uint i=0;
        uint count = pendingList.length;
        success = false;
    
        // you don't want to leave no validators - can't delete any until you have a minimum of 3. 
        // This is in case your 1 remaining node goes down. Leave a safety margin of 2
        if (count > 2) { 
            for (i=0; i<count;i++) {
                if (pendingList[i] == validator) {
                    if (i < pendingList.length-1) {
                        pendingList[i] = pendingList[pendingList.length-1];
                    }
                    pendingList.length--;
                    success = true;
                    validatorRemoved(validator);
                    InitiateChange(block.blockhash(block.number - 1),pendingList);
                    break;
                }
            }
        }
        return success;
    }
    
    // Add an admin.
    function addAdmin(address admin) public onlyAdmin {
        isAdmin[admin] = true;
        adminAdded(admin);
    }
    
    // Remove an admin.
    function removeAdmin(address admin) public onlyAdmin {
        isAdmin[admin] = false;
        adminRemoved(admin);
    }
    
    function finalizeChange() public {
        validatorList = pendingList;
    }
    

    }

I know both nodes connect properly because if I use static validators works fine.

  • It should be A - B - A - B ... Please share your configurations to dig into it. – soc1c Jan 17 '18 at 11:49
0

I think only one node mines blocks because you have defined in the contract the first node's address, instead defining a list :

address[] public validatorList = [<your first validator address>];
address[] public pendingList = [<your first validator address>];

you have to add the other one using addValidator function or initiate your validatorlist with both addresses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.