Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
avkos committed Oct 19, 2023
1 parent 4896948 commit f6ecc03
Show file tree
Hide file tree
Showing 14 changed files with 1,898 additions and 268 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
lib
lib
.idea
21 changes: 14 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "web3-plugin-template",
"name": "web3-plugin-tx-eip4844",
"version": "1.0.0",
"description": "Template plugin to extend web3.js with additional methods",
"main": "lib/index.js",
Expand All @@ -19,23 +19,30 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "[email protected]:web3/web3.js-plugin-template.git"
"url": "[email protected]:web3/web3.js-plugin-tx-eip4844.git"
},
"dependencies": {
"@chainsafe/ssz": "^0.14.0",
"@ethereumjs/rlp": "4",
"ethereum-cryptography": "^2.1.2",
"web3-eth-accounts": "^4.0.6",
"web3-utils": "^4.0.6",
"web3-validator": "^2.0.2"
},
"devDependencies": {
"@chainsafe/eslint-config": "^2.0.0",
"@ethereumjs/common": "^3.2.0",
"@ethereumjs/util": "^8.1.0",
"@types/jest": "^29.5.2",
"@types/node": "^20.2.6",
"eslint": "8",
"crypto": "^1.0.1",
"eslint": "^8.51.0",
"jest": "^29.5.0",
"jest-extended": "^4.0.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.3",
"web3": "^4.0.3"
"web3": "^4.1.2"
},
"peerDependencies": {
"web3": ">= 4.0.3"
}
"peerDependencies": {}
}
23 changes: 23 additions & 0 deletions src/eip4844/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { secp256k1 } from "ethereum-cryptography/secp256k1";

export const MAX_INTEGER = BigInt(
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
);
export const SECP256K1_ORDER = secp256k1.CURVE.n;
export const SECP256K1_ORDER_DIV_2 = SECP256K1_ORDER / BigInt(2);
export const BIGINT_27 = BigInt(27);
export const BIGINT_0 = BigInt(0);
export const BIGINT_1 = BigInt(1);
export const LIMIT_BLOBS_PER_TX = 16777216; // 2 ** 24
export const FIELD_ELEMENTS_PER_BLOB = 4096;
export const BYTES_PER_FIELD_ELEMENT = 32;
export const USEFUL_BYTES_PER_BLOB = 32 * FIELD_ELEMENTS_PER_BLOB;
export const MAX_BLOBS_PER_TX = 2;
export const MAX_USEFUL_BYTES_PER_TX =
USEFUL_BYTES_PER_BLOB * MAX_BLOBS_PER_TX - 1;
export const BLOB_SIZE = BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB;
export const BIGINT_CACHE: bigint[] = [];
for (let i = 0; i <= 256 * 256 - 1; i++) {
BIGINT_CACHE[i] = BigInt(i);
}
36 changes: 36 additions & 0 deletions src/eip4844/hardfork.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { HardforkConfig } from "./types.js";

enum Status {
Draft = "draft",
Review = "review",
Final = "final",
}

export const hardforks: HardforkConfig = {
name: "cancun",
comment:
"Next feature hardfork after shanghai, includes proto-danksharding EIP 4844 blobs (still WIP hence not for production use), transient storage opcodes, parent beacon block root availability in EVM, selfdestruct only in same transaction, and blob base fee opcode",
url: "https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md",
status: Status.Final,
eips: [1153, 4844, 4788, 5656, 6780, 7516],
};
export enum Hardfork {
Chainstart = "chainstart",
Homestead = "homestead",
Dao = "dao",
TangerineWhistle = "tangerineWhistle",
SpuriousDragon = "spuriousDragon",
Byzantium = "byzantium",
Constantinople = "constantinople",
Petersburg = "petersburg",
Istanbul = "istanbul",
MuirGlacier = "muirGlacier",
Berlin = "berlin",
London = "london",
ArrowGlacier = "arrowGlacier",
GrayGlacier = "grayGlacier",
MergeForkIdTransition = "mergeForkIdTransition",
Paris = "paris",
Shanghai = "shanghai",
Cancun = "cancun",
}
Loading

0 comments on commit f6ecc03

Please sign in to comment.