Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0392d9f
feat(benchmark): move benchmarking to ts script for additional config…
ElasticBottle Aug 8, 2023
34b7214
chore: remove unused env variable
ElasticBottle Aug 9, 2023
240749c
chore: add .env.benchmark to gitignore
ElasticBottle Aug 9, 2023
6d74d86
feat(server): add txProcessedTimestamp to returned transaction object
ElasticBottle Aug 9, 2023
bbe28cf
feat(worker): override gas fee setting to allow for sending of transa…
ElasticBottle Aug 9, 2023
83a12df
feat(benchmark): Add better info for initial send reqeust
ElasticBottle Aug 9, 2023
9541f10
docs(core): add description for benchmark file
ElasticBottle Aug 9, 2023
9b6c578
chore(core): remove logs from getFeeData
ElasticBottle Aug 9, 2023
dc10fd1
chore(benchmark): Update timings to reflect + print status for easy v…
ElasticBottle Aug 9, 2023
3ccceaf
chore: update @thirdweb-dev/sdk and /chains
ElasticBottle Aug 11, 2023
98106c7
chore(benchmark): add benchmarking env file support
ElasticBottle Aug 21, 2023
ef08d38
feat(benchmark): update write vars
ElasticBottle Aug 21, 2023
6a080ed
docs(benchmark): add docs to readme on how to run local benchmark
ElasticBottle Aug 21, 2023
b8715ab
Merge branch 'main' into winston/plat-1058
farhanW3 Aug 25, 2023
f494418
merged changes
farhanW3 Aug 25, 2023
b56be68
Merge branch 'winston/plat-1058' of github.com:thirdweb-dev/web3-api …
farhanW3 Aug 25, 2023
f3e0f43
Added blockNumber & txMinedTimestamp column to transactions table
farhanW3 Aug 25, 2023
2852f12
updated status response example
farhanW3 Aug 25, 2023
d6b489a
updated Query & tx selection based on receipt
farhanW3 Aug 25, 2023
d9e4d45
updated resposne for tx statuse end-point
farhanW3 Aug 25, 2023
cc97933
updated benchmark with Procssing Time, Mined Time
farhanW3 Aug 26, 2023
ee66019
Merge branch 'main' into winston/plat-1058
farhanW3 Sep 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .env.benchmark.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
THIRDWEB_SDK_SECRET_KEY=

# benchmark vars
NODE_ENV=benchmark
BENCHMARK_HOST='http://127.0.0.1:3005'
BENCHMARK_URL_PATH='/contract/polygon/0x01De66609582B874FA34ab288859ACC4592aec04/write'
BENCHMARK_POST_BODY='{
"function_name": "mintTo",
"args": ["0xCF3D06a19263976A540CFf8e7Be7b026801C52A6", "0","", "1"]
}'
# Total request has to be more than the total concurrency
BENCHMARK_CONCURRENCY=2
BENCHMARK_REQUESTS=2
SAMPLE_EDITION_CONTRACT_INFO='{
"contractMetadata": {
"name": "TW WEB3API",
"description": "thirdweb web3API sample collection for testing",
"image": "ipfs://QmYxT4LnK8sqLupjbS6eRvu1si7Ly2wFQAqFebxhWntcf6",
"external_link": "",
"app_uri": "",
"seller_fee_basis_points": 0,
"fee_recipient": "0xCF3D06a19263976A540CFf8e7Be7b026801C52A6",
"symbol": "TWT",
"platform_fee_basis_points": 0,
"platform_fee_recipient": "0xCF3D06a19263976A540CFf8e7Be7b026801C52A6",
"primary_sale_recipient": "0xCF3D06a19263976A540CFf8e7Be7b026801C52A6",
"trusted_forwarders": []
}
}'
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ CHAIN_OVERRIDES=<path_or_url_to_file>
# from "http://example1.com" or from a subdomain of "example2.com".
ACCESS_CONTROL_ALLOW_ORIGIN=*


# benchmark vars [Optional]
BENCHMARK_HOST='http://localhost:3005'
BENCHMARK_URL_PATH='/contract/mumbai/0xc8be6265C06aC376876b4F62670adB3c4d72EABA/write'
Expand All @@ -64,3 +63,4 @@ BENCHMARK_POST_BODY='{
}'
BENCHMARK_CONCURRENCY=10
BENCHMARK_REQUESTS=10

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ web_modules/

# dotenv environment variable files
.env
.env.benchmark
.env.development.local
.env.test.local
.env.production.local
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
SHELL := /bin/bash

export NODE_ENV=testing
export THIRDWEB_API_KEY=TEST
export POSTGRES_HOST=localhost
export POSTGRES_DATABASE_NAME=postgres
export POSTGRES_USER=postgres
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ The API defaults to `http://localhost:3005`

</details>

## Local Benchmarking

As a way to support quantifying the robustness of our system, we have added benchmarking. Benchmark results may vary based on the machine that is being used.

To run the benchmark:

1. Run local server with `yarn dev`
1. Set-up `.env.benchmark` (For sensible defaults: `cp .env.benchmark.example .env.benchmark`)
1. Run benchmark in a separate terminal with `yarn benchmark`

## Contributing

We welcome contributions from all developers, regardless of experience level. If you are interested in contributing, please read our [Contributing Guide](./.github/contributing.md) where you'll learn how the repo works, how to test your changes, and how to submit a pull request.
Expand Down
2 changes: 1 addition & 1 deletion core/database/dbConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const connectWithDatabase = async (): Promise<Knex> => {
};

// Set the appropriate databse client package
let dbClientPackage: any;
let dbClientPackage: typeof pg;
switch (dbClient) {
case "pg":
dbClientPackage = pg;
Expand Down
4 changes: 3 additions & 1 deletion core/database/sql-schemas/transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ ALTER COLUMN "maxFeePerGas" TYPE VARCHAR(255),
ALTER COLUMN "txType" TYPE VARCHAR(255),
ADD COLUMN IF NOT EXISTS "deployedContractAddress" VARCHAR(255),
ADD COLUMN IF NOT EXISTS "contractType" VARCHAR(255),
ADD COLUMN IF NOT EXISTS "errorMessage" TEXT DEFAULT NULL;
ADD COLUMN IF NOT EXISTS "errorMessage" TEXT DEFAULT NULL,
ADD COLUMN IF NOT EXISTS "txMinedTimestamp" TIMESTAMP,
ADD COLUMN IF NOT EXISTS "blockNumber" BIGINT;
41 changes: 41 additions & 0 deletions core/services/benchmark.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// ! Winston Notes: This file is currently not in used.
// Keeping it around for when we might want to track specific function timings.
// Note that you cannot track functions in worker and output timings in server.
// Tracking and outputting timings must be done in the same docker image.
// Might release this as my own npm package and bring it in as a dependency in the future
import { randomUUID } from "crypto";
import { PerformanceObserver, performance } from "perf_hooks";

export const watchPerformance = (
onNewEntry: (entry: PerformanceEntry) => void,
) => {
const performanceObserver = new PerformanceObserver((items) => {
items.getEntries().forEach((entry) => {
onNewEntry(entry);
});
});
performanceObserver.observe({ entryTypes: ["measure"], buffered: true });
};

export const timeFunction = <
F extends (...args: any) => any,
Args = F extends (args: infer A) => any ? A : never,
>(
fn: F,
resultTag: (args: Awaited<ReturnType<F>>) => string,
) => {
const result = async (args: Args): Promise<Awaited<ReturnType<F>>> => {
const marker = randomUUID();
const markerStart = `${marker}-start`;
const markerEnd = `${marker}-end`;

performance.mark(markerStart);
const fnResult = await fn(args);
performance.mark(markerEnd);

const measureName = resultTag(fnResult);
performance.measure(measureName, markerStart, markerEnd);
return fnResult;
};
return result;
};
10 changes: 10 additions & 0 deletions core/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ export const getWalletNonce = async (
throw error;
}
};

export const getFeeData = async (provider: providers.Provider) => {
try {
const feeData = await provider.getFeeData();

return feeData;
} catch (error) {
throw error;
}
};
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"lint": "eslint 'server/**/*.ts'",
"lint:fix": "eslint --fix 'server/**/*.ts'",
"test": "make test-evm",
"test:all": "mocha --exit"
"test:all": "mocha --exit",
"benchmark": "ts-node ./scripts/benchmark/index.ts"
},
"dependencies": {
"@fastify/cookie": "^8.3.0",
Expand Down Expand Up @@ -59,6 +60,7 @@
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@swc/core": "^1.3.41",
"@types/autocannon": "^7.9.1",
"@types/chai": "^4.3.5",
"@types/cookie": "^0.5.1",
"@types/express": "^4.17.17",
Expand All @@ -71,6 +73,7 @@
"@types/ws": "^8.5.5",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"autocannon": "^7.12.0",
"chai": "^4.3.7",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0",
Expand Down
Loading