Coder Social home page Coder Social logo

ethereum-benchmark's Introduction

TRANSACTIONS PER SECOND RATE TEST IN BESU NETWORK

PURPOSE

Determine how much transactions can be stored on each block

Establish limitations of Hyperledger Besu when it is exposed to a stress test.

Preliminary concepts

  1. Gas
  2. Data with transactions
  3. Block Period Seconds
  4. Gas Limit

TERMINOLOGY

  1. Stimulus: Transactions that are sent to a node in a period of time at some rate(transactions per second) and each transaction containing a certain amount of gas.
  2. Source: The node which sends the stimulus to some node in a Besu network.
  3. Response: The receipts that are sent back to the source; in this test the time that each response takes to be done and how much receipts are sent from the tested node will be measured.

REQUIREMENTS

  • You must have docker and docker-compose installed on the machine you want to run the program.

HOW TO USE

  • Clone the repository

  • Enter into the folder ethereum-node-benchmark/server

  • run npm install

  • Create the folder logs into the server folder:

    mkdir logs
  • Located in the root folder open docker-compose.yml; there you will have the posibility to SET the following enviroment variables:

      - TEST_TYPE=1 # 0: ether sending test, 1: smart contract test
      - SMART_CONTRACT_OPTION=1 #0: lightweigth Smart Contract test (33314 gas/tx), 1: Heavy contract test (213890 gas/tx), 2: Falcon Signature test (64100 gas/tx), 3: Relat PQ Meta Tx
      - DESIRED_RATE_TX=1 #Rate in tx/s
      - TEST_TIME_MINUTES=0.1 #choose the time
      - RPC_URL=http://RPC_URL:PORT
      - MAX_GAS_PER_TX=1000000
      - NUMBER_OF_CONTAINERS=1
      - STORE_DATA=TRUE
    ############ SETTING FOR ETHER TESTING (IF REQUIRED) ##############      
      - AMOUNT_DATA_BYTES=0 #only set this value if you choose TEST_TYPE=0
    ############ SETTING FOR SMART CONTRACT TESTING ##############
      #- SMART_CONTRACT_ADDRESS=0x8eC60639166f38Fb1455f77F956761Bc9c14FD6b # DO NOT COPY PASTE - to avoid deploying a contract again

    Where:

    1. TEST_TYPE=<0,1> : If you choose "0" then only ether send transactions will be simulated. Otherwise if you choose 1 then you should also configure the type of smart contract to send (indicated in the next step)
    2. SMART_CONTRACT_OPTION=<0,1>: If you choose 0 then a new contract with a setter method that consumes 33314 gas/tx will be deployed. Otherwise if you choose "1" then a more complex contract is deployed, in that contract a method that consumes 213890 gas/tx will be used for the subsequent test.
    3. DESIRED_RATE_TX : Is the rate at which pantheon node will receive transactions in a period of one second.
    4. AMOUNT_DATA_BYTES : Is The amount of bytes to add on each transaction.
    5. TEST_TIME_MINUTES : Is the period of time, in minutes, at which Pantheon will be exposed to a bunch of transactions sent from this code when it is running.
    6. RPC_URL : the rpc url that point to the pantheon node to test
    7. MAX_GAS_PER_TX is the maximum amount of allowed gas per transaction; in our case it is set to 1 million gas, because for our configuration it is the maximum allowed per transaction; beyond that point the transactions are put in a queue and starts consuming ram. It is worth to say to not touch this value during this test.
    8. NUMBER_OF_CONTAINERS is the number of containers you have configured on this docker-compose file.
    9. STORE_DATA : Only set to true on the first container; in te rest of copies set to false.

    Be mindful that you can run as many containers as you want; and also on each of those; you can customize different RPC URLs.

    Note: This project is created whith the assumption that all containers runs with the same rate(DESIRED_RATE_TX).

    If you want to simulate data(AMOUNT_DATA>0) for a long time,then it is recommended to run a test for one minute verifying that the amount of data is not too big that takes the stimulus be done in more than a minute; if so, you can reduce the amount of data(bytes) to be sent per transaction on each container and increment the number of containers in such way you reach the your desired rate.

  • Now you are ready to run the project by using:

    docker-compose up --build
  • After tests have finished the results will be created at server/logs directory; it can be used to plot a graph with that data.

Results

Find an article about conclusions here

Copyright 2020 LACChain

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

ethereum-benchmark's People

Contributors

antonio-leal-batista avatar eum602 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ethereum-benchmark's Issues

where to set private keys with ETH

hello

thank you for creating this repo
I can't find where I can sent the private key of some wallet funded with (my) ETH. I see you generate couple of random wallets, but they are all empty.
I thought there should be some sort of "master" account to fund them

Thank you again

Making tests for custm functions

Hey, i want to know how my smart contracts methods will function when simulated an x couple of time, like the average transaction fee, change in gasPrice etc, but i do not really know how to implement it correctly, here is the smart contract`// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

/** Smart contract to list products */
contract Listing {
struct Item {
address seller;
string name;
string description;
uint256 price;
bool isAvailable;
}

// Mapping items to unique identifiers
mapping(uint256 => Item) public items;

// Counter to generate unique id
uint256 public itemIdCounter;

// Event emitted when a new product is listed
event ItemListed(
    uint256 itemId,
    address indexed seller,
    string name,
    uint256 price
);

// Event emitted when item is deleted
event ItemDeleted(uint256 itemId, address indexed seller);

// Modifier to ensure only the seller can perform certain actions
modifier onlySeller(uint256 itemId) {
    require(msg.sender == items[itemId].seller, "You are not the seller");
    _;
}

// Function to list a new item
function listNewItem(
    string memory itemName,
    string memory itemDescription,
    uint256 price
) external {
    require(price > 0, "Price must be greater than 0");

    // Increment item id counter to generate a unique id for the new item
    itemIdCounter++;

    // Create a new item and store it in the mapping
    items[itemIdCounter] = Item({
        seller: msg.sender,
        name: itemName,
        description: itemDescription,
        price: price,
        isAvailable: true
    });

    // Emit an event to notify a new item has been listed
    emit ItemListed(itemIdCounter, msg.sender, itemName, price);
}

// Function to get details of a listed item
function getItemDetails(
    uint256 itemId
) external view returns (Item memory) {
    return items[itemId];
}

// Function to purchase a listed item
function purchaseItem(uint256 itemId) external payable {
    // Check item availability
    require(items[itemId].isAvailable, "Item is not available");

    // Check if the sent value matches the item's price
    require(
        msg.value == items[itemId].price,
        "Incorrect payment amount for item"
    );

    // Transfer funds to the seller
    payable(items[itemId].seller).transfer(msg.value);

    // Mark the item as sold
    items[itemId].isAvailable = false;
}

// Function to update details of a listed item
function updateItemDetails(
    uint256 itemId,
    string memory newItemName,
    string memory newItemDescription,
    uint256 newPrice
) external onlySeller(itemId) {
    require(newPrice > 0, "Price must be greater than zero");

    // Update details of the item
    items[itemId].name = newItemName;
    items[itemId].description = newItemDescription;
    items[itemId].price = newPrice;
}

// Function to delete a listed item
function deleteItem(uint256 itemId) external onlySeller(itemId) {
    // Mark the item as no longer available
    items[itemId].isAvailable = false;

    // Emit an event to notify deletion
    emit ItemDeleted(itemId, msg.sender);
}

}
` thank you in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.