Code Monkey home page Code Monkey logo

marketplace-benchmarks's Introduction

Marketplace Benchmarks

Marketplace Benchmarks is a repository which runs a variety of generalized tests on NFT marketplaces to benchmark them for gas efficiency. View benchmark results here for EOA calls and here for direct calls.

Setup

Install Foundry

To install Foundry (assuming a Linux or macOS system):

curl -L https://foundry.paradigm.xyz | bash

This will download foundryup. To start Foundry, run:

foundryup

To install dependencies:

forge install

Run Tests

Tests are all run against mainnet deployments of active marketplaces, as such, a Mainnet Ethereum RPC is required. This will log gas snapshots for each individual test operation.

forge test --fork-url <ETH_MAINNET_RPC> -vv

Adding A Marketplace

  1. Create a marketplace config in /src/marketplaces
  2. Integrate into GenericMarketplaceTest
    • Import your marketplace config
    • Create a global variable for your marketpalce config
    • Deploy and set your marketplace config in the constructor
    • Create a new test named test<YOUR_MARKETPLACE> which calls benchmarkMarket(BaseMarketConfig config) with your marketplace config.

Marketplace Config

A marketplace config must inherits BaseMarketConfig. See SeaportConfig for reference.

Required Functions
  • beforeAllPrepareMarketplace(address seller, address buyer) - This function must set the approval targets for the marketplace. These addresses will be used prior to each test to reset buyer/seller approvals.
  • name() - This function must return the name of the marketplace to use in benchmarking results
  • market() - This function must return the address of the marketplace. It is used to reset the marketplace storage between tests.
Optional Functions

There are a variety of different types of tests which your market can support by implementing any of the functions defined in the Test Payload Calls section of BaseMarketConfig. Tests that use unimplemented payload calls will show up as incompatable with your marketplace.

beforeAllPrepareMarketplaceCall is an optional setup function which allows for any arbitrary calls to be sent from any address. For example: it was used to deploy Wyvern proxies for the buyer and seller prior to benchmarking Wyvern.

Adding A Test

Anyone can add a generalized test to this repository which will enable for checkpointing different functionalities across marketplaces.

Creating the Generalized Test

Generalized tests are written in GenericMarketplaceTest. Use the simple ERC721->Ether test as a reference.

  1. Ensure that the buyer (Bob) and seller (Alice) have sufficient funds for the transaction. Each user is dealt enough ETH prior to the test.
  2. Find an appropriate payload call in BaseMarketConfig. If none exists, you may create a new one.
  3. Use _benchmarkCallWithParams to call the payload.
  4. Add assertions throughout the test to ensure that the marketplace is actually doing what you expect it to.

marketplace-benchmarks's People

Contributors

0age avatar arr00 avatar d1ll0n avatar slokh avatar sudo-owen avatar hardlydifficult avatar zeframlou avatar dependabot[bot] avatar sambarnes avatar djviau avatar 0xhiroshi avatar phil-ociraptor avatar d3kum1d0r1y4100 avatar

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.