diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..422c3919cb --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +.next +dist +node_modules/ diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000000..4d765f2817 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": ["next/core-web-vitals", "prettier"] +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..c87c9b392c --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..ed8032e23c --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +.next +node_modules +yarn.lock +package-lock.json +public +build diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000..c4e3a5c973 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "printWidth": 100, + "trailingComma": "none", + "semi": true, + "arrowParens": "avoid", + "singleQuote": true, + "jsxSingleQuote": true, + "tabWidth": 2, + "useTabs": false +} diff --git a/README.md b/README.md index 62509f9fe6..3c633bc383 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,47 @@ This repo will act as a shared workspace for the geth website team in developing Resources: - the project management notes: https://www.notion.so/efdn/Build-new-Geth-website-bf35a46cfe5848db83ac3acb5191eb1c -- some draft figma files for design sketching: https://www.figma.com/file/ekzIgwyeVKLtFSAcnA0Q0D/geth-website?node-id=6%3A31 +- some draft figma files for design sketching: https://www.figma.com/file/ekzIgwyeVKLtFSAcnA0Q0D/geth-website?node-id=6%3A31 - content planning notes: https://www.notion.so/efdn/Content-Strategy-3252234338814a749374fa7f11049083 - meeting notes: https://www.notion.so/efdn/Call-notes-46aa0202810a402ebfda07b046761cbd - Notes: -**Dev note**: Remember that the fiules in `vulnerabilities` must be served at the same URLs as they are currently to avoid breaking some Geth functions related to security auditing. \ No newline at end of file +**Dev note**: Remember that the fiules in `vulnerabilities` must be served at the same URLs as they are currently to avoid breaking some Geth functions related to security auditing. + +--- + +This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). + +## Getting Started + +First, run the development server: + +```bash +npm run dev +# or +yarn dev +``` + +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. + +You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. + +[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. + +The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. + +## Learn More + +To learn more about Next.js, take a look at the following resources: + +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. + +You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! + +## Deploy on Vercel + +The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. + +Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. diff --git a/content/docs/getting_started/Backup--restore.md b/content/docs/getting_started/Backup--restore.md deleted file mode 100644 index 6d038572d1..0000000000 --- a/content/docs/getting_started/Backup--restore.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: Backup & Restore -sort_key: C ---- - -Most important info first: **REMEMBER YOUR PASSWORD** and **BACKUP YOUR KEYSTORE**. - -## Data Directory - -Everything `geth` persists gets written inside its data directory. The default data -directory locations are platform specific: - -* Mac: `~/Library/Ethereum` -* Linux: `~/.ethereum` -* Windows: `%LOCALAPPDATA%\Ethereum` - -Accounts are stored in the `keystore` subdirectory. The contents of this directories -should be transportable between nodes, platforms, implementations (C++, Go, Python). - -To configure the location of the data directory, the `--datadir` parameter can be -specified. See [CLI Options](../interface/command-line-options) for more details. - -Note the [ethash dag](../interface/mining) is stored at `~/.ethash` (Mac/Linux) or -`%APPDATA%\Ethash` (Windows) so that it can be reused by all clients. You can store this -in a different location by using a symbolic link. - -## Cleanup - -Geth's blockchain and state databases can be removed with: - -``` -geth removedb -``` - -This is useful for deleting an old chain and sync'ing to a new one. It only affects data -directories that can be re-created on synchronisation and does not touch the keystore. - -## Blockchain Import/Export - -Export the blockchain in binary format with: - -``` -geth export -``` - -Or if you want to back up portions of the chain over time, a first and last block can be -specified. For example, to back up the first epoch: - -``` -geth export 0 29999 -``` - -Note that when backing up a partial chain, the file will be appended rather than -truncated. - -Import binary-format blockchain exports with: - -``` -geth import -``` - -_See https://eth.wiki/en/howto/blockchain-import-and-export-instructions for more info_ - - -And finally: **REMEMBER YOUR PASSWORD** and **BACKUP YOUR KEYSTORE** diff --git a/content/docs/interacting_with_geth/RPC/objects.md b/content/docs/interacting_with_geth/RPC/objects.md deleted file mode 100644 index 504cfa624c..0000000000 --- a/content/docs/interacting_with_geth/RPC/objects.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -title: Objects -description: Data structures used for RPC methods ---- - -The following are data structures which are used for various RPC methods. - -### Transaction call object - -The *transaction call object* contains all the necessary parameters for executing an EVM contract method. - -| Field | Type | Bytes | Optional | Description | -|:-----------|:-----------|:------|:---------|:------------| -| `from` | `Address` | 20 | Yes | Address the transaction is simulated to have been sent from. Defaults to first account in the local keystore or the `0x00..0` address if no local accounts are available. | -| `to` | `Address` | 20 | No | Address the transaction is sent to. | -| `gas` | `Quantity` | <8 | Yes | Maximum gas allowance for the code execution to avoid infinite loops. Defaults to `2^63` or whatever value the node operator specified via `--rpc.gascap`. | -| `gasPrice` | `Quantity` | <32 | Yes | Number of `wei` to simulate paying for each unit of gas during execution. Defaults to `1 gwei`. | -| `maxFeePerGas` | `Quantity` | <32 | Yes | Maximum fee per gas the transaction should pay in total. Relevant for type-2 transactions. | -| `maxPriorityFeePerGas` | `Quantity` | <32 | Yes | Maximum tip per gas that's given directly to the miner. Relevant for type-2 transactions. | -| `value` | `Quantity` | <32 | Yes | Amount of `wei` to simulate sending along with the transaction. Defaults to `0`. | -| `nonce` | `Quantity` | <8 | Yes | Nonce of sender account. | -| `input` | `Binary` | any | Yes | Binary data to send to the target contract. Generally the 4 byte hash of the method signature followed by the ABI encoded parameters. For details please see the [Ethereum Contract ABI](https://docs.soliditylang.org/en/v0.7.0/abi-spec.html). This field was previously called `data`. | -| `accessList` | `AccessList` | any | Yes | A list of addresses and storage keys that the transaction plans to access. Used in non-legacy, i.e. type 1 and 2 transactions. | -| `chainId` | `Quantity` | <32 | Yes | Transaction only valid on networks with this chain ID. Used in non-legacy, i.e. type 1 and 2 transactions. | - -Example for a legacy transaction: - -```json -{ - "from": "0xd9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f3", - "to": "0xebe8efa441b9302a0d7eaecc277c09d20d684540", - "gas": "0x1bd7c", - "data": "0xd459fc46000000000000000000000000000000000000000000000000000000000046c650dbb5e8cb2bac4d2ed0b1e6475d37361157738801c494ca482f96527eb48f9eec488c2eba92d31baeccfb6968fad5c21a3df93181b43b4cf253b4d572b64172ef000000000000000000000000000000000000000000000000000000000000008c00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000002b85c0c828d7a98633b4e1b65eac0c017502da909420aeade9a280675013df36bdc71cffdf420cef3d24ba4b3f9b980bfbb26bd5e2dcf7795b3519a3fd22ffbb2000000000000000000000000000000000000000000000000000000000000000238fb6606dc2b5e42d00c653372c153da8560de77bd9afaba94b4ab6e4aa11d565d858c761320dbf23a94018d843772349bd9d92301b0ca9ca983a22d86a70628", -} -``` - -Example for a type-1 transaction: - -```json -{ - "from": "0xd9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f3", - "to": "0xebe8efa441b9302a0d7eaecc277c09d20d684540", - "gas": "0x1bd7c", - "data": "0xd459fc46000000000000000000000000000000000000000000000000000000000046c650dbb5e8cb2bac4d2ed0b1e6475d37361157738801c494ca482f96527eb48f9eec488c2eba92d31baeccfb6968fad5c21a3df93181b43b4cf253b4d572b64172ef000000000000000000000000000000000000000000000000000000000000008c00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000002b85c0c828d7a98633b4e1b65eac0c017502da909420aeade9a280675013df36bdc71cffdf420cef3d24ba4b3f9b980bfbb26bd5e2dcf7795b3519a3fd22ffbb2000000000000000000000000000000000000000000000000000000000000000238fb6606dc2b5e42d00c653372c153da8560de77bd9afaba94b4ab6e4aa11d565d858c761320dbf23a94018d843772349bd9d92301b0ca9ca983a22d86a70628", - "chainId": "0x1", - "accessList": [ - { - "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", - "storageKeys": ["0xda650992a54ccb05f924b3a73ba785211ba39a8912b6d270312f8e2c223fb9b1", "0x10d6a54a4754c8869d6886b5f5d7fbfa5b4 - 522237ea5c60d11bc4e7a1ff9390b"] - }, { - "address": "0xa2327a938febf5fec13bacfb16ae10ecbc4cbdcf", - "storageKeys": [] - }, - ] -} -``` - -Example for a type-2 transaction: - -```json -{ - "from": "0xd9c9cd5f6779558b6e0ed4e6acf6b1947e7fa1f3", - "to": "0xebe8efa441b9302a0d7eaecc277c09d20d684540", - "gas": "0x1bd7c", - "maxFeePerGas": "0x6b44b0285", - "maxPriorityFeePerGas": "0x6b44b0285", - "data": "0xd459fc46000000000000000000000000000000000000000000000000000000000046c650dbb5e8cb2bac4d2ed0b1e6475d37361157738801c494ca482f96527eb48f9eec488c2eba92d31baeccfb6968fad5c21a3df93181b43b4cf253b4d572b64172ef000000000000000000000000000000000000000000000000000000000000008c00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000002b85c0c828d7a98633b4e1b65eac0c017502da909420aeade9a280675013df36bdc71cffdf420cef3d24ba4b3f9b980bfbb26bd5e2dcf7795b3519a3fd22ffbb2000000000000000000000000000000000000000000000000000000000000000238fb6606dc2b5e42d00c653372c153da8560de77bd9afaba94b4ab6e4aa11d565d858c761320dbf23a94018d843772349bd9d92301b0ca9ca983a22d86a70628", - "chainId": "0x1", - "accessList": [] -} -``` diff --git a/next.config.js b/next.config.js new file mode 100644 index 0000000000..403aed7493 --- /dev/null +++ b/next.config.js @@ -0,0 +1,18 @@ +/** @type {import('next').NextConfig} */ + +const withMDX = require('@next/mdx')({ + extension: /\.mdx?$/, + options: { + remarkPlugins: [], + rehypePlugins: [] + // If you use `MDXProvider`, uncomment the following line. + // providerImportSource: "@mdx-js/react", + } +}); + +module.exports = withMDX({ + reactStrictMode: true, + swcMinify: true, + // Append the default value with md extensions + pageExtensions: ['ts', 'tsx', 'md', 'mdx'] +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000000..552c97702a --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "geth-site", + "private": false, + "description": "The website for geth.ethereum.org", + "version": "2.0.0", + "author": "Nicolás Quiroz ", + "scripts": { + "dev": "next dev", + "build": "npm run lint && next build && npm run format:fix", + "start": "next start", + "lint": "next lint", + "format:fix": "prettier . --write --config .prettierrc --ignore-path .prettierignore --loglevel warn" + }, + "dependencies": { + "@chakra-ui/react": "^2.3.2", + "@emotion/react": "^11.10.4", + "@emotion/styled": "^11.10.4", + "@mdx-js/loader": "^2.1.3", + "@mdx-js/react": "^2.1.3", + "@next/mdx": "^12.3.0", + "focus-visible": "^5.2.0", + "framer-motion": "^7.3.2", + "next": "^12.3.0", + "react": "18.2.0", + "react-dom": "18.2.0", + "react-syntax-highlighter": "^15.5.0" + }, + "devDependencies": { + "@types/node": "18.7.16", + "@types/react": "18.0.18", + "@types/react-dom": "18.0.6", + "@types/react-syntax-highlighter": "^15.5.5", + "eslint": "8.23.0", + "eslint-config-next": "12.2.5", + "eslint-config-prettier": "^8.5.0", + "prettier": "^2.7.1", + "typescript": "4.8.2" + } +} diff --git a/assets/qubes-client.py b/public/code/qubes-client.py similarity index 100% rename from assets/qubes-client.py rename to public/code/qubes-client.py diff --git a/assets/qubes.Clefsign b/public/code/qubes.Clefsign similarity index 100% rename from assets/qubes.Clefsign rename to public/code/qubes.Clefsign diff --git a/vulnerabilities/vulnerabilities.json b/public/docs/vulnerabilities/vulnerabilities.json similarity index 99% rename from vulnerabilities/vulnerabilities.json rename to public/docs/vulnerabilities/vulnerabilities.json index bee0e66dd8..b1168cacae 100644 --- a/vulnerabilities/vulnerabilities.json +++ b/public/docs/vulnerabilities/vulnerabilities.json @@ -93,9 +93,7 @@ "fixed": "v1.9.20", "summary": "A consensus-vulnerability in Geth could cause a chain split, where vulnerable versions refuse to accept the canonical chain.", "description": "A flaw was repoted at 2020-08-11 by John Youngseok Yang (Software Platform Lab), where a particular sequence of transactions could cause a consensus failure.\n\n- Tx 1:\n - `sender` invokes `caller`.\n - `caller` invokes `0xaa`. `0xaa` has 3 wei, does a self-destruct-to-self\n - `caller` does a `1 wei` -call to `0xaa`, who thereby has 1 wei (the code in `0xaa` still executed, since the tx is still ongoing, but doesn't redo the selfdestruct, it takes a different path if callvalue is non-zero)\n\n-Tx 2:\n - `sender` does a 5-wei call to 0xaa. No exec (since no code). \n\nIn geth, the result would be that `0xaa` had `6 wei`, whereas OE reported (correctly) `5` wei. Furthermore, in geth, if the second tx was not executed, the `0xaa` would be destructed, resulting in `0 wei`. Thus obviously wrong. \n\nIt was determined that the root cause was this [commit](https://github.com/ethereum/go-ethereum/commit/223b950944f494a5b4e0957fd9f92c48b09037ad) from [this PR](https://github.com/ethereum/go-ethereum/pull/19953). The semantics of `createObject` was subtly changd, into returning a non-nil object (with `deleted=true`) where it previously did not if the account had been destructed. This return value caused the new object to inherit the old `balance`.\n", - "links": [ - "https://github.com/ethereum/go-ethereum/security/advisories/GHSA-xw37-57qp-9mm4" - ], + "links": ["https://github.com/ethereum/go-ethereum/security/advisories/GHSA-xw37-57qp-9mm4"], "published": "2020-12-10", "severity": "High", "CVE": "CVE-2020-26265", diff --git a/vulnerabilities/vulnerabilities.json.minisig b/public/docs/vulnerabilities/vulnerabilities.json.minisig similarity index 100% rename from vulnerabilities/vulnerabilities.json.minisig rename to public/docs/vulnerabilities/vulnerabilities.json.minisig diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000..718d6fea48 Binary files /dev/null and b/public/favicon.ico differ diff --git a/assets/clef_qubes_http.png b/public/images/clef_qubes_http.png similarity index 100% rename from assets/clef_qubes_http.png rename to public/images/clef_qubes_http.png diff --git a/assets/clef_qubes_qrexec.png b/public/images/clef_qubes_qrexec.png similarity index 100% rename from assets/clef_qubes_qrexec.png rename to public/images/clef_qubes_qrexec.png diff --git a/assets/clef_sign_flow.png b/public/images/clef_sign_flow.png similarity index 100% rename from assets/clef_sign_flow.png rename to public/images/clef_sign_flow.png diff --git a/assets/devcon2_labelled.webp b/public/images/devcon2_labelled.webp similarity index 100% rename from assets/devcon2_labelled.webp rename to public/images/devcon2_labelled.webp diff --git a/assets/ethstats-mainnet.png b/public/images/ethstats-mainnet.png similarity index 100% rename from assets/ethstats-mainnet.png rename to public/images/ethstats-mainnet.png diff --git a/assets/grafana1.png b/public/images/grafana1.png similarity index 100% rename from assets/grafana1.png rename to public/images/grafana1.png diff --git a/assets/grafana2.png b/public/images/grafana2.png similarity index 100% rename from assets/grafana2.png rename to public/images/grafana2.png diff --git a/assets/grafana3.png b/public/images/grafana3.png similarity index 100% rename from assets/grafana3.png rename to public/images/grafana3.png diff --git a/assets/grafana4.png b/public/images/grafana4.png similarity index 100% rename from assets/grafana4.png rename to public/images/grafana4.png diff --git a/assets/grafana5.png b/public/images/grafana5.png similarity index 100% rename from assets/grafana5.png rename to public/images/grafana5.png diff --git a/assets/grafana6.png b/public/images/grafana6.png similarity index 100% rename from assets/grafana6.png rename to public/images/grafana6.png diff --git a/assets/grafana7.png b/public/images/grafana7.png similarity index 100% rename from assets/grafana7.png rename to public/images/grafana7.png diff --git a/assets/grafana8.png b/public/images/grafana8.png similarity index 100% rename from assets/grafana8.png rename to public/images/grafana8.png diff --git a/assets/node_architecture.png b/public/images/node_architecture.png similarity index 100% rename from assets/node_architecture.png rename to public/images/node_architecture.png diff --git a/assets/node_basic.png b/public/images/node_basic.png similarity index 100% rename from assets/node_basic.png rename to public/images/node_basic.png diff --git a/assets/qrexec-example.png b/public/images/qrexec-example.png similarity index 100% rename from assets/qrexec-example.png rename to public/images/qrexec-example.png diff --git a/assets/qubes_newaccount-1.png b/public/images/qubes_newaccount-1.png similarity index 100% rename from assets/qubes_newaccount-1.png rename to public/images/qubes_newaccount-1.png diff --git a/assets/qubes_newaccount-2.png b/public/images/qubes_newaccount-2.png similarity index 100% rename from assets/qubes_newaccount-2.png rename to public/images/qubes_newaccount-2.png diff --git a/assets/remix-compiler.png b/public/images/remix-compiler.png similarity index 100% rename from assets/remix-compiler.png rename to public/images/remix-compiler.png diff --git a/assets/remix-deploy.png b/public/images/remix-deploy.png similarity index 100% rename from assets/remix-deploy.png rename to public/images/remix-deploy.png diff --git a/assets/remix-func.png b/public/images/remix-func.png similarity index 100% rename from assets/remix-func.png rename to public/images/remix-func.png diff --git a/assets/remix.png b/public/images/remix.png similarity index 100% rename from assets/remix.png rename to public/images/remix.png diff --git a/assets/wireframe1.png b/public/images/wireframe1.png similarity index 100% rename from assets/wireframe1.png rename to public/images/wireframe1.png diff --git a/assets/wireframe2.png b/public/images/wireframe2.png similarity index 100% rename from assets/wireframe2.png rename to public/images/wireframe2.png diff --git a/assets/wireframe3.png b/public/images/wireframe3.png similarity index 100% rename from assets/wireframe3.png rename to public/images/wireframe3.png diff --git a/assets/wireframe4.png b/public/images/wireframe4.png similarity index 100% rename from assets/wireframe4.png rename to public/images/wireframe4.png diff --git a/assets/wireframe5.png b/public/images/wireframe5.png similarity index 100% rename from assets/wireframe5.png rename to public/images/wireframe5.png diff --git a/public/vercel.svg b/public/vercel.svg new file mode 100644 index 0000000000..fbf0e25a65 --- /dev/null +++ b/public/vercel.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/components/MDXComponents.tsx b/src/components/MDXComponents.tsx new file mode 100644 index 0000000000..4e309b4812 --- /dev/null +++ b/src/components/MDXComponents.tsx @@ -0,0 +1,115 @@ +import { Heading, Link, Stack, Text } from '@chakra-ui/react'; +import NextLink from 'next/link'; +import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'; +import { nightOwl } from 'react-syntax-highlighter/dist/cjs/styles/prism'; + +import bash from 'react-syntax-highlighter/dist/cjs/languages/prism/bash'; +import go from 'react-syntax-highlighter/dist/cjs/languages/prism/go'; +import graphql from 'react-syntax-highlighter/dist/cjs/languages/prism/graphql'; +import java from 'react-syntax-highlighter/dist/cjs/languages/prism/java'; +import javascript from 'react-syntax-highlighter/dist/cjs/languages/prism/javascript'; +import json from 'react-syntax-highlighter/dist/cjs/languages/prism/json'; +import python from 'react-syntax-highlighter/dist/cjs/languages/prism/python'; +import sh from 'react-syntax-highlighter/dist/cjs/languages/prism/shell-session'; +import solidity from 'react-syntax-highlighter/dist/cjs/languages/prism/solidity'; +import swift from 'react-syntax-highlighter/dist/cjs/languages/prism/swift'; + +// syntax highlighting languages supported +SyntaxHighlighter.registerLanguage('bash', bash); +SyntaxHighlighter.registerLanguage('go', go); +SyntaxHighlighter.registerLanguage('graphql', graphql); +SyntaxHighlighter.registerLanguage('java', java); +SyntaxHighlighter.registerLanguage('javascript', javascript); +SyntaxHighlighter.registerLanguage('json', json); +SyntaxHighlighter.registerLanguage('python', python); +SyntaxHighlighter.registerLanguage('sh', sh); +SyntaxHighlighter.registerLanguage('solidity', solidity); +SyntaxHighlighter.registerLanguage('swift', swift); + +import { getProgrammingLanguageName } from '../utils'; + +const MDXComponents = { + // paragraphs + p: ({ children }: any) => { + return ( + + {children} + + ); + }, + // links + a: ({ children, href }: any) => { + return ( + + + {children} + + + ); + }, + // headings + h1: ({ children }: any) => { + return ( + + {children} + + ); + }, + h2: ({ children }: any) => { + return ( + + {children} + + ); + }, + h3: ({ children }: any) => { + return ( + + {children} + + ); + }, + h4: ({ children }: any) => { + return ( + + {children} + + ); + }, + // pre + pre: ({ children }: any) => { + return ( + +
{children}
+
+ ); + } + // code + // code: (code: any) => { + // const language = getProgrammingLanguageName(code); + + // return !!code.inline ? ( + // + // {code.children[0]} + // + // ) : ( + // + // {code.children[0]} + // + // ); + // } +}; + +export default MDXComponents; diff --git a/src/components/UI/.delete-me b/src/components/UI/.delete-me new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/components/index.ts b/src/components/index.ts new file mode 100644 index 0000000000..b7f39642bb --- /dev/null +++ b/src/components/index.ts @@ -0,0 +1 @@ +export { default } from './MDXComponents'; diff --git a/src/components/layouts/Layout.tsx b/src/components/layouts/Layout.tsx new file mode 100644 index 0000000000..0e1b011e2b --- /dev/null +++ b/src/components/layouts/Layout.tsx @@ -0,0 +1,14 @@ +import { Container } from '@chakra-ui/react'; +import { FC } from 'react'; + +interface Props { + children?: React.ReactNode; +} + +export const Layout: FC = ({ children }) => { + return ( + + {children} + + ); +}; diff --git a/src/components/layouts/index.ts b/src/components/layouts/index.ts new file mode 100644 index 0000000000..9fc685e2aa --- /dev/null +++ b/src/components/layouts/index.ts @@ -0,0 +1 @@ +export { Layout } from './Layout'; diff --git a/src/hooks/.delete-me b/src/hooks/.delete-me new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx new file mode 100644 index 0000000000..5d1f2b46dd --- /dev/null +++ b/src/pages/_app.tsx @@ -0,0 +1,23 @@ +import { ChakraProvider } from '@chakra-ui/react'; +import { AppProps } from 'next/app'; + +import { Layout } from '../components/layouts'; + +import 'focus-visible/dist/focus-visible'; + +import theme from '../theme'; + +import { MDXProvider } from '@mdx-js/react'; +import MDXComponents from '../components/'; + +export default function App({ Component, pageProps }: AppProps) { + return ( + + + + + + + + ); +} diff --git a/src/pages/about.mdx b/src/pages/about.mdx new file mode 100644 index 0000000000..320681c997 --- /dev/null +++ b/src/pages/about.mdx @@ -0,0 +1,5 @@ +# About + +## Subtitle + +Text sample for testing only diff --git a/src/pages/api/hello.ts b/src/pages/api/hello.ts new file mode 100644 index 0000000000..eb4cc6657b --- /dev/null +++ b/src/pages/api/hello.ts @@ -0,0 +1,10 @@ +// Next.js API route support: https://nextjs.org/docs/api-routes/introduction +import type { NextApiRequest, NextApiResponse } from 'next'; + +type Data = { + name: string; +}; + +export default function handler(req: NextApiRequest, res: NextApiResponse) { + res.status(200).json({ name: 'John Doe' }); +} diff --git a/content/docs/developers/contributing.md b/src/pages/docs/developers/contributing.md similarity index 87% rename from content/docs/developers/contributing.md rename to src/pages/docs/developers/contributing.md index 126395d0a5..522ecf8845 100644 --- a/content/docs/developers/contributing.md +++ b/src/pages/docs/developers/contributing.md @@ -11,11 +11,11 @@ If you'd like to contribute to the Geth source code, please fork the [Github rep Please make sure your contributions adhere to our coding guidelines: -* Code must adhere to the official Go formatting guidelines (i.e. uses gofmt). -* Code must be documented adhering to the official Go commentary guidelines. -* Pull requests need to be based on and opened against the master branch. -* Commit messages should be prefixed with the package(s) they modify. - E.g. "eth, rpc: make trace configs optional" +- Code must adhere to the official Go formatting guidelines (i.e. uses gofmt). +- Code must be documented adhering to the official Go commentary guidelines. +- Pull requests need to be based on and opened against the master branch. +- Commit messages should be prefixed with the package(s) they modify. + E.g. "eth, rpc: make trace configs optional" Pull requests generally need to be based on and opened against the `master` branch, unless by explicit agreement because the work is contributing to some more complex feature branch. diff --git a/content/docs/developers/dapp-developer/built-in-tracers.md b/src/pages/docs/developers/dapp-developer/built-in-tracers.md similarity index 82% rename from content/docs/developers/dapp-developer/built-in-tracers.md rename to src/pages/docs/developers/dapp-developer/built-in-tracers.md index fc01d24aea..2c93414daf 100644 --- a/content/docs/developers/dapp-developer/built-in-tracers.md +++ b/src/pages/docs/developers/dapp-developer/built-in-tracers.md @@ -5,25 +5,24 @@ description: Explanation of the tracers that come bundled in Geth as part of the Geth comes bundled with a choice of tracers ready for usage through the [tracing API](/docs/rpc/ns-debug). Some of them are implemented natively in Go, and others in JS. In this page a summary of each of these will be outlined. They have to be specified by name when sending a request. The only exception is the opcode logger (otherwise known as struct logger) which is the default tracer for all the methods and cannot be specified by name. - ## Struct logger Struct logger or opcode logger is a native Go tracer which executes a transaction and emits the opcode and execution context at every step. This is the tracer that will be used when no name is passed to the API, e.g. `debug.traceTransaction()`. The following information is emitted at each step: -| field | type | description | -|------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------| -| pc | uint64 | program counter | -| op | byte | opcode to be executed | -| gas | uint64 | remaining gas | -| gasCost | uint64 | cost for executing op | -| memory | []byte | EVM memory. Enabled via `enableMemory` | -| memSize | int | Size of memory | -| stack | []uint256 | EVM stack. Disabled via `disableStack` | -| returnData | []byte | Last call's return data. Enabled via `enableReturnData` | -| storage | map[hash]hash | Storage slots of current contract read from and written to. Only emitted for `SLOAD` and `SSTORE`. Disabled via `disableStorage` | -| depth | int | Current call depth | -| refund | uint64 | Refund counter | -| error | string | Error message if any | +| field | type | description | +| ---------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| pc | uint64 | program counter | +| op | byte | opcode to be executed | +| gas | uint64 | remaining gas | +| gasCost | uint64 | cost for executing op | +| memory | []byte | EVM memory. Enabled via `enableMemory` | +| memSize | int | Size of memory | +| stack | []uint256 | EVM stack. Disabled via `disableStack` | +| returnData | []byte | Last call's return data. Enabled via `enableReturnData` | +| storage | map[hash]hash | Storage slots of current contract read from and written to. Only emitted for `SLOAD` and `SSTORE`. Disabled via `disableStorage` | +| depth | int | Current call depth | +| refund | uint64 | Refund counter | +| error | string | Error message if any | Note that the fields `memory`, `stack`, `returnData`, and `storage` have dynamic size and depending on the exact transaction they could grow large in size. This is specially true for `memory` which could blow up the trace size. It is recommended to keep them disabled unless they are explicitly required for a given use-case. @@ -52,18 +51,18 @@ The `4byteTracer` collects the function selectors of every function executed in The `callTracer` tracks all the call frames executed during a transaction, including depth 0. The result will be a nested list of call frames, resembling how EVM works. They form a tree with the top-level call at root and sub-calls as children of the higher levels. Each call frame has the following fields: -| field | type | description | -|---------|-------------|-------------------------------------------| -| type | string | CALL or CREATE | -| from | string | address | -| to | string | address | -| value | string | hex-encoded amount of value transfer | -| gas | string | hex-encoded gas provided for call | -| gasUsed | string | hex-encoded gas used during call | -| input | string | call data | -| output | string | return data | -| error | string | error, if any | -| calls | []callframe | list of sub-calls | +| field | type | description | +| ------- | ----------- | ------------------------------------ | +| type | string | CALL or CREATE | +| from | string | address | +| to | string | address | +| value | string | hex-encoded amount of value transfer | +| gas | string | hex-encoded gas provided for call | +| gasUsed | string | hex-encoded gas used during call | +| input | string | call data | +| output | string | return data | +| error | string | error, if any | +| calls | []callframe | list of sub-calls | Things to note about the call tracer: @@ -79,7 +78,7 @@ This tracer is noop. It returns an empty object and is only meant for testing th Executing a transaction requires the prior state, including account of sender and recipient, contracts that are called during execution, etc. The `prestateTracer` replays the tx and tracks every part of state that is touched. This is similar to the concept of a [stateless witness](https://ethresear.ch/t/the-stateless-client-concept/172), the difference being this tracer doesn't return any cryptographic proof, rather only the trie leaves. The result is an object. The keys are addresses of accounts. The value is an object with the following fields: | field | type | description | -|---------|-------------------|-------------------------------| +| ------- | ----------------- | ----------------------------- | | balance | string | balance in Wei | | nonce | uint64 | nonce | | code | string | hex-encoded bytecode | diff --git a/content/docs/developers/dapp-developer/custom-tracer.md b/src/pages/docs/developers/dapp-developer/custom-tracer.md similarity index 73% rename from content/docs/developers/dapp-developer/custom-tracer.md rename to src/pages/docs/developers/dapp-developer/custom-tracer.md index 231760a4c6..a025c87dcd 100644 --- a/content/docs/developers/dapp-developer/custom-tracer.md +++ b/src/pages/docs/developers/dapp-developer/custom-tracer.md @@ -11,42 +11,41 @@ Transaction traces include the complete status of the EVM at every point during ### A simple filter -Filters are Javascript functions that select information from the trace to persist and discard based on some conditions. The following Javascript function returns only the sequence of opcodes executed by the transaction as a comma-separated list. The function could be written directly in the Javascript console, but it is cleaner to write it in a separate re-usable file and load it into the console. +Filters are Javascript functions that select information from the trace to persist and discard based on some conditions. The following Javascript function returns only the sequence of opcodes executed by the transaction as a comma-separated list. The function could be written directly in the Javascript console, but it is cleaner to write it in a separate re-usable file and load it into the console. 1. Create a file, `filterTrace_1.js`, with this content: ```javascript - - tracer = function(tx) { - return debug.traceTransaction(tx, {tracer: + tracer = function (tx) { + return debug.traceTransaction(tx, { + tracer: '{' + - 'retVal: [],' + - 'step: function(log,db) {this.retVal.push(log.getPC() + ":" + log.op.toString())},' + - 'fault: function(log,db) {this.retVal.push("FAULT: " + JSON.stringify(log))},' + - 'result: function(ctx,db) {return this.retVal}' + + 'retVal: [],' + + 'step: function(log,db) {this.retVal.push(log.getPC() + ":" + log.op.toString())},' + + 'fault: function(log,db) {this.retVal.push("FAULT: " + JSON.stringify(log))},' + + 'result: function(ctx,db) {return this.retVal}' + '}' - }) // return debug.traceTransaction ... - } // tracer = function ... - + }); // return debug.traceTransaction ... + }; // tracer = function ... ``` 2. Run the [JavaScript console](https://geth.ethereum.org/docs/interface/javascript-console). - 3. Get the hash of a recent transaction from a node or block explorer. 4. Run this command to run the script: ```javascript - loadScript("filterTrace_1.js") + loadScript('filterTrace_1.js'); ``` 5. Run the tracer from the script. Be patient, it could take a long time. ```javascript - tracer("") + tracer(''); ``` The bottom of the output looks similar to: + ```sh "3366:POP", "3367:JUMP", "1355:JUMPDEST", "1356:PUSH1", "1358:MLOAD", "1359:DUP1", "1360:DUP3", "1361:ISZERO", "1362:ISZERO", "1363:ISZERO", "1364:ISZERO", "1365:DUP2", "1366:MSTORE", "1367:PUSH1", "1369:ADD", "1370:SWAP2", "1371:POP", "1372:POP", "1373:PUSH1", @@ -56,10 +55,10 @@ Filters are Javascript functions that select information from the trace to persi 6. Run this line to get a more readable output with each string in its own line. ```javascript - console.log(JSON.stringify(tracer(""), null, 2)) + console.log(JSON.stringify(tracer(''), null, 2)); ``` -More information about the `JSON.stringify` function is available [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). +More information about the `JSON.stringify` function is available [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). The commands above worked by calling the same `debug.traceTransaction` function that was previously explained in [basic traces](https://geth.ethereum.org/docs/dapp/tracing), but with a new parameter, `tracer`. This parameter takes the JavaScript object formated as a string. In the case of the trace above, it is: @@ -71,6 +70,7 @@ The commands above worked by calling the same `debug.traceTransaction` function result: function(ctx,db) {return this.retVal} } ``` + This object has three member functions: - `step`, called for each opcode. @@ -86,21 +86,22 @@ The `step` function adds to `retVal` the program counter and the name of the opc For actual filtered tracing we need an `if` statement to only log relevant information. For example, to isolate the transaction's interaction with storage, the following tracer could be used: ```javascript -tracer = function(tx) { - return debug.traceTransaction(tx, {tracer: +tracer = function (tx) { + return debug.traceTransaction(tx, { + tracer: '{' + - 'retVal: [],' + - 'step: function(log,db) {' + - ' if(log.op.toNumber() == 0x54) ' + - ' this.retVal.push(log.getPC() + ": SLOAD");' + - ' if(log.op.toNumber() == 0x55) ' + - ' this.retVal.push(log.getPC() + ": SSTORE");' + - '},' + - 'fault: function(log,db) {this.retVal.push("FAULT: " + JSON.stringify(log))},' + - 'result: function(ctx,db) {return this.retVal}' + + 'retVal: [],' + + 'step: function(log,db) {' + + ' if(log.op.toNumber() == 0x54) ' + + ' this.retVal.push(log.getPC() + ": SLOAD");' + + ' if(log.op.toNumber() == 0x55) ' + + ' this.retVal.push(log.getPC() + ": SSTORE");' + + '},' + + 'fault: function(log,db) {this.retVal.push("FAULT: " + JSON.stringify(log))},' + + 'result: function(ctx,db) {return this.retVal}' + '}' - }) // return debug.traceTransaction ... -} // tracer = function ... + }); // return debug.traceTransaction ... +}; // tracer = function ... ``` The `step` function here looks at the opcode number of the op, and only pushes an entry if the opcode is `SLOAD` or `SSTORE` ([here is a list of EVM opcodes and their numbers](https://github.com/wolflo/evm-opcodes)). We could have used `log.op.toString()` instead, but it is faster to compare numbers rather than strings. @@ -120,7 +121,6 @@ The output looks similar to this: ] ``` - ### Stack Information The trace above reports the program counter (PC) and whether the program read from storage or wrote to it. That alone isn't particularly useful. To know more, the `log.stack.peek` function can be used to peek into the stack. `log.stack.peek(0)` is the stack top, `log.stack.peek(1)` the entry below it, etc. @@ -129,28 +129,28 @@ The values returned by `log.stack.peek` are Go `big.Int` objects. By default the #### Storage Information -The function below provides a trace of all the storage operations and their parameters. This gives a more complete picture of the program's interaction with storage. +The function below provides a trace of all the storage operations and their parameters. This gives a more complete picture of the program's interaction with storage. ```javascript -tracer = function(tx) { - return debug.traceTransaction(tx, {tracer: +tracer = function (tx) { + return debug.traceTransaction(tx, { + tracer: '{' + - 'retVal: [],' + - 'step: function(log,db) {' + - ' if(log.op.toNumber() == 0x54) ' + - ' this.retVal.push(log.getPC() + ": SLOAD " + ' + - ' log.stack.peek(0).toString(16));' + - ' if(log.op.toNumber() == 0x55) ' + - ' this.retVal.push(log.getPC() + ": SSTORE " +' + - ' log.stack.peek(0).toString(16) + " <- " +' + - ' log.stack.peek(1).toString(16));' + - '},' + - 'fault: function(log,db) {this.retVal.push("FAULT: " + JSON.stringify(log))},' + - 'result: function(ctx,db) {return this.retVal}' + + 'retVal: [],' + + 'step: function(log,db) {' + + ' if(log.op.toNumber() == 0x54) ' + + ' this.retVal.push(log.getPC() + ": SLOAD " + ' + + ' log.stack.peek(0).toString(16));' + + ' if(log.op.toNumber() == 0x55) ' + + ' this.retVal.push(log.getPC() + ": SSTORE " +' + + ' log.stack.peek(0).toString(16) + " <- " +' + + ' log.stack.peek(1).toString(16));' + + '},' + + 'fault: function(log,db) {this.retVal.push("FAULT: " + JSON.stringify(log))},' + + 'result: function(ctx,db) {return this.retVal}' + '}' - }) // return debug.traceTransaction ... -} // tracer = function ... - + }); // return debug.traceTransaction ... +}; // tracer = function ... ``` The output is similar to: @@ -176,35 +176,36 @@ storage, so here we can't. The solution is to have a flag, `afterSload`, which is only true in the opcode right after an `SLOAD`, when we can see the result at the top of the stack. ```javascript -tracer = function(tx) { - return debug.traceTransaction(tx, {tracer: +tracer = function (tx) { + return debug.traceTransaction(tx, { + tracer: '{' + - 'retVal: [],' + - 'afterSload: false,' + - 'step: function(log,db) {' + - ' if(this.afterSload) {' + - ' this.retVal.push(" Result: " + ' + - ' log.stack.peek(0).toString(16)); ' + - ' this.afterSload = false; ' + - ' } ' + - ' if(log.op.toNumber() == 0x54) {' + - ' this.retVal.push(log.getPC() + ": SLOAD " + ' + - ' log.stack.peek(0).toString(16));' + - ' this.afterSload = true; ' + - ' } ' + - ' if(log.op.toNumber() == 0x55) ' + - ' this.retVal.push(log.getPC() + ": SSTORE " +' + - ' log.stack.peek(0).toString(16) + " <- " +' + - ' log.stack.peek(1).toString(16));' + - '},' + - 'fault: function(log,db) {this.retVal.push("FAULT: " + JSON.stringify(log))},' + - 'result: function(ctx,db) {return this.retVal}' + + 'retVal: [],' + + 'afterSload: false,' + + 'step: function(log,db) {' + + ' if(this.afterSload) {' + + ' this.retVal.push(" Result: " + ' + + ' log.stack.peek(0).toString(16)); ' + + ' this.afterSload = false; ' + + ' } ' + + ' if(log.op.toNumber() == 0x54) {' + + ' this.retVal.push(log.getPC() + ": SLOAD " + ' + + ' log.stack.peek(0).toString(16));' + + ' this.afterSload = true; ' + + ' } ' + + ' if(log.op.toNumber() == 0x55) ' + + ' this.retVal.push(log.getPC() + ": SSTORE " +' + + ' log.stack.peek(0).toString(16) + " <- " +' + + ' log.stack.peek(1).toString(16));' + + '},' + + 'fault: function(log,db) {this.retVal.push("FAULT: " + JSON.stringify(log))},' + + 'result: function(ctx,db) {return this.retVal}' + '}' - }) // return debug.traceTransaction ... -} // tracer = function ... + }); // return debug.traceTransaction ... +}; // tracer = function ... ``` -The output now contains the result in the line that follows the `SLOAD`. +The output now contains the result in the line that follows the `SLOAD`. ```javascript [ @@ -229,64 +230,55 @@ So the storage has been treated as if there are only 2256 cells. Howe However, `log.contract.getAddress()` returns an array of bytes. To convert this to the familiar hexadecimal representation of Ethereum addresses, `this.byteHex()` and `array2Hex()` can be used. ```javascript -tracer = function(tx) { - return debug.traceTransaction(tx, {tracer: +tracer = function (tx) { + return debug.traceTransaction(tx, { + tracer: '{' + - 'retVal: [],' + - 'afterSload: false,' + - 'callStack: [],' + - - 'byte2Hex: function(byte) {' + - ' if (byte < 0x10) ' + - ' return "0" + byte.toString(16); ' + - ' return byte.toString(16); ' + - '},' + - - 'array2Hex: function(arr) {' + - ' var retVal = ""; ' + - ' for (var i=0; i