0

I have a series of contracts that work perfectly fine on testrpc but not when I deploy to Rinkeby. I am using a standard token contract with Zeppelin that I am having no issues with.

The issue is with the registry contract. I have a BaseRegistry contract that is from https://regis.nu/. I can show it here but I think what's important is that my child contract is inheriting from the BaseContract. Here is the ChildRegistry:

pragma solidity ^0.4.11;

import "./BaseRegistry.sol";
import "../token/Token.sol";
import "../node/Node.sol";


contract ChildRegistry is BaseRegistry {

address public owner;
address public nodeDelegateAddress;
address[] public registeredNodes;

address public delegateContract;
address[] public previousDelegates;
uint256 public count;
address public tokenAddress;

  event DelegateChanged(address oldAddress, address newAddress);

  function ChildRegistry() {
    // constructor
  }

  function changeDelegate(address _newDelegate) returns (bool) {
    /*assert(owner == msg.sender);*/

    if (_newDelegate != delegateContract) {
        previousDelegates.push(delegateContract);
        var oldDelegate = delegateContract;
        delegateContract = _newDelegate;
        DelegateChanged(oldDelegate, _newDelegate);
        return true;
      }
    return false;

}

  function registerNode() {
    delegateContract.delegatecall(bytes4(sha3("registerNode()")));
  }

  function createNodeContract () {
    delegateContract.delegatecall(bytes4(sha3("createNodeContract()")));
  }

  function getNodes() constant returns (address[]) {
    return registeredNodes;
  }

  function setTokenAddress(address _tokenAddress) {
    delegateContract.delegatecall(bytes4(sha3("setTokenAddress(address)")), _tokenAddress);
  }
  function setNodeDelegateAddress(address _nodeDelegateAddress) {
    delegateContract.delegatecall(bytes4(sha3("setNodeDelegateAddress(address)")), _nodeDelegateAddress);
  }


}

The ChildRegistry is calling the delegate contract and updating its own state once it's set:

pragma solidity ^0.4.11;

import "./BaseRegistry.sol";
import "../token/Token.sol";
import "../node/Node.sol";


contract ChildRegistryDelegate is BaseRegistry {

address public owner;
address public nodeDelegateAddress;
address[] public registeredNodes;

address public delegateContract;
address[] public previousDelegates;
uint256 public count;
address public tokenAddress;

  function ChildRegistryDelegate() {
    // constructor
  }


  function registerNode() {

    count += 1;

    Token existingToken = Token(tokenAddress);
    token.burn(1,msg.sender);
    register(msg.sender, "string");      
  //tokenAddress.call(bytes4(sha3("burn(uint256,address)")),1,msg.sender);

    createNodeContract();
  }

  function createNodeContract () {

    Node newNode = new Node();
    newNode.changeDelegate(nodeDelegateAddress);
    newNode.setOwner(msg.sender);
    newNode.setTokenAddress(tokenAddress);
    registeredNodes.push(newNode);

    /*newNode.call(bytes4(sha3("changeDelegate(address)")), nodeDelegateAddress);
    newNode.call(bytes4(sha3("setOwner(address)")), msg.sender);
    newNode.call(bytes4(sha3("changeDelegate(address)")), tokenAddress);*/

    registeredNodes.push(newNode);
  }

  function getNodes() constant returns (address[]) {
    return registeredNodes;
  }

  function setTokenAddress(address _tokenAddress) {
    tokenAddress = _tokenAddress;
  }

  function setNodeDelegateAddress(address _nodeDelegateAddress) {
    assert(owner == msg.sender);
    nodeDelegateAddress = _nodeDelegateAddress;
  }

}

When I deploy the contracts I set the proper delegates manually. I know the delegatecall works because I can setTokenAddress and setNodeDelegateAddress perfectly fine. The issue is when I registerNode. On testrpc, it works fine. When I deploy to Rinkeby, nothing works. Nothing gets added to registeredNodes, register does not get called, and the token.burn does not work.

I added the count to see the the delegatecall would work then, and it does. The burn also works when I comment everything out and add tokenAddress.call(bytes4(sha3("burn(uint256,address)")),1,msg.sender);.

When I call createNodeContract, nothing works either. When I comment all the function calls and just try Node newNode = new Node(); and registeredNodes.push(newNode); nothing happens.

I'm not sure why this is happening. I have a feeling it has to do with the BaseRegistry contract and how it's inheriting. I also think it might be how I am deploying my contracts with truffle. Here is my 2_deploy_contracts.js:

var Token = artifacts.require('./Token.sol')
var ChildRegistry = artifacts.require('./ChildRegistry.sol')
var ChildRegistryDelegate = artifacts.require('./ChildRegistryDelegate.sol')
var NodeDelegate = artifacts.require('./NodeDelegate.sol')

module.exports = function(deployer) {
  deployer.deploy(Token);
  deployer.deploy(ChildRegistry);
  deployer.deploy(ChildRegistryDelegate);
  deployer.deploy(NodeDelegate);
};

I also thought it may have to do with how I'm deploying them. I have no idea. Anything would be helpful. Thank you.

  • Did you check the transaction on Rinkeby? Is it reverting or not? – Luiz Soares Nov 23 '17 at 11:02
  • It's going through just fine, just nothing happens. – Michael O'Rourke Nov 23 '17 at 11:03
0

Figured it out. Geth console was not reading my truffle.js file for some reason. Looks like this:

rinkeby: {
  host: "localhost",
  port: 8545,
  network_id: "4",
  from: "0xfc7846d06fab273c62cda0d29eac0936a22eeca4",
  gas: 2000000
}

Still isn't reading it. Everything works, but the transactions were running out of gas and failing. Have to add the gas manually {from:sender, gas:2000000} in each transaction for them to work.

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.