0

I have a private parity chain where all transaction are always sent with maximum gas. I also have PoA with AURA set to 1 sec to make sure that blocks are generated as fast as possible. However, it still be very slow, and I have no idea what can I tune to make it work, it's just a blackbox with no ways to interact with.

My current JSON looks like this:

...
"params": {
    "maximumExtraDataSize": "0x20",
    "minGasLimit": "0x1388",
    "networkID": "0x2323",    
    "gasLimitBoundDivisor": "0x400"
  },
  "genesis": {
    "seal": {
      "authorityRound": {
        "step": "0x0",
        "signature": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
      }
    },
    "difficulty": "0x20000",
    "gasLimit": "0x165A0BC00"
  },
...

Full version is placed here.

I'm looking for literally any possibility to make it work faster. I have a smart contract which just is saving some fields in blockchain:

pragma solidity ^0.4.23;

contract Owned {
    address public owner;

    constructor() public { 
        owner = tx.origin;
    }

    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }

    function isDeployed() public pure returns(bool) {
        return true;
    }
}

contract Season is Owned {
    uint64 public begin;
    uint64 public end;
    string name;

    Request[] requests;
    mapping(bytes30 => uint) requestServiceNumberToIndex;

    event RequestCreated(bytes30 indexed serviceNumber, uint index);

    constructor(uint64 begin_, uint64 end_, string name_) public {
        begin = begin_;
        end = end_;
        name = name_;
    }

    function createRequest(bytes30 serviceNumber, uint64 date, DeclarantType declarantType, string declarantName, uint64 fairId, uint64[] assortment, uint64 district, uint64 region, string additionalData) public onlyOwner {     
        uint index = requestServiceNumberToIndex[serviceNumber];

        require(index == 0 && (requests.length == 0 || requests[0].serviceNumber != serviceNumber));

        requests.length++;
        index = requests.length - 1;    
        requestServiceNumberToIndex[serviceNumber] = index;

        Request storage request = requests[index];

        request.serviceNumber = serviceNumber;
        request.date = date;
        request.declarantType = declarantType;
        request.declarantName = declarantName;
        request.fairId = fairId;
        request.district = district;
        request.region = region;
        request.assortment = assortment;
        request.additionalData = additionalData;

        emit RequestCreated(serviceNumber, index);
    }

    function getSeasonDetails() public view returns(uint64, uint64, string) {
        return (begin, end, name);
    }

    function getRequestByServiceNumber(bytes30 serviceNumber) public view returns(bytes30, uint64, DeclarantType, string, uint64, uint64[], uint64, uint64, string) {
        return getRequestByIndex(requestServiceNumberToIndex[serviceNumber]);
    }

    function getRequestByIndex(uint index) public view returns(bytes30, uint64, DeclarantType, string, uint64, uint64[], uint64, uint64, string) {
        Request storage request = requests[index];
        bytes30 serviceNumber = request.serviceNumber;
        string memory declarantName = request.declarantName;
        uint64[] memory assortment = getAssortment(request);        
        string memory additionalData = request.additionalData;
        return (serviceNumber, request.date, request.declarantType, declarantName, request.fairId, assortment, request.district, request.region, additionalData);
    }

    function getAssortment(Request request) private pure returns(uint64[]) {
        uint64[] memory memoryAssortment = new uint64[](request.assortment.length);
        for (uint i = 0; i < request.assortment.length; i++) {
            memoryAssortment[i] = request.assortment[i];
        }
        return memoryAssortment;
    }

    struct Request {
        bytes30 serviceNumber;
        uint64 date;
        DeclarantType  declarantType;
        string declarantName;
        uint64 fairId;
        uint64[] assortment;
        uint64 district;
        uint64 region;
        string additionalData;
    }

    enum DeclarantType {
        A,
        B,
        C,
        D
    }
}

And I can only run createRequest twice per second.

Could it be speeded up in any way. I need some improvements to make it 5-10x faster, but I'm out of ideas.

  • For private ethereum blockchain try quorum. – Jitendra Kumar. Balla Jun 5 '18 at 5:44
  • Have you tried sending transactions with the correct amount of gas instead of the maximum? I don't have much experience with parity but is there a chance the sealer node is only including one transaction per block because of the gas values you're supplying? – TC8 Jun 5 '18 at 6:08
  • @JitendraKumar.Balla ty, i'l try this approach – Alex Zhukovskiy Jun 5 '18 at 8:50
  • @TC8 I was able to lower gas amount to 0.5 of maximum, lower value cause transaction to fail. Thank you for advice too, it may speed up the overall process. – Alex Zhukovskiy Jun 5 '18 at 8:51

Your Answer

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

Browse other questions tagged or ask your own question.