Skip to content

Commit

Permalink
Upgrade to Shanghai (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylar authored Apr 13, 2023
1 parent a174624 commit 6ffdec8
Show file tree
Hide file tree
Showing 12 changed files with 582 additions and 484 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ evm.codes is brought to you by [smlXL](https://www.smlxl.io), powered by open-so

The app requires the following dependencies:

- [NodeJS](https://nodejs.org/) >= 14
- [NodeJS](https://nodejs.org/) >= 18
- [Yarn](https://yarnpkg.com/)

## 👩‍💻 Local Development
Expand Down
1 change: 0 additions & 1 deletion components/ChainSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const ChainSelector = () => {
shortcut: ['f'],
keywords: 'fork network evm',
section: 'Preferences',
children: forkIds,
},
])
}
Expand Down
1 change: 1 addition & 0 deletions components/ui/Hamburger.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react/no-unknown-property */
import React from 'react'

import cn from 'classnames'
Expand Down
14 changes: 9 additions & 5 deletions context/ethereumContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import React, { createContext, useEffect, useState, useRef } from 'react'
import { Block } from '@ethereumjs/block'
import { Common, Chain } from '@ethereumjs/common'
import { HardforkConfig } from '@ethereumjs/common/src/types'
import { TypedTransaction, TxData, Transaction } from '@ethereumjs/tx'
import { VM } from '@ethereumjs/vm'
import { RunState, InterpreterStep } from '@ethereumjs/evm/dist/interpreter'
import { EvmError } from '@ethereumjs/evm/src/exceptions'
import { Opcode } from '@ethereumjs/evm/src/opcodes'
import { getActivePrecompiles } from '@ethereumjs/evm/src/precompiles'
import { EvmError } from '@ethereumjs/evm/src/exceptions'
import { TypedTransaction, TxData, Transaction } from '@ethereumjs/tx'
import { Address, Account } from '@ethereumjs/util'
import { VM } from '@ethereumjs/vm'
//
import OpcodesMeta from 'opcodes.json'
import PrecompiledMeta from 'precompiled.json'
Expand Down Expand Up @@ -424,7 +424,11 @@ export const EthereumProvider: React.FC<{}> = ({ children }) => {

common.hardforks().forEach((fork) => {
// ignore null block forks
if (fork.block || fork.name === mergeHardforkName) {
if (
fork.block ||
fork.name === mergeHardforkName ||
fork.name === CURRENT_FORK // Hack for Shanghai the timestamp is not set yet
) {
forks.push(fork)

// set initially selected fork
Expand Down Expand Up @@ -531,7 +535,7 @@ export const EthereumProvider: React.FC<{}> = ({ children }) => {
// respectively AFTER applying the original methods.
// This is necessary in order to handle storage operations easily.
const _setupStateManager = () => {
var proxyStateManager = traceMethodCalls(vm.evm.eei)
const proxyStateManager = traceMethodCalls(vm.evm.eei)
vm.evm.eei.putContractStorage = proxyStateManager.putContractStorage
vm.evm.eei.clearContractStorage = proxyStateManager.clearContractStorage

Expand Down
31 changes: 31 additions & 0 deletions docs/opcodes/5F.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
fork: Shanghai
group: Push Operations
---

*Index 1 is top of the stack.*

## Notes

The new value is put on top of the stack, incrementing all the other value indices. The values for a specific opcode thus have to be pushed in reverse order of the stack. For example, with [MSTORE](/#52), the first value pushed would have to be `value`, and then `offset`.

## Stack output

0. `value`: pushed value, equal to 0.

## Example

| * | * |
|---|---|
| **Code** | `0x5F` |
| **Text** | `PUSH0` |

| * | Input | Output |
|--:|------:|-------:|
| 1 | | `0x00` |

## Error cases

The state changes done by the current context are [reverted](#FD) in those cases:
- Not enough gas.
- Stack overflow.
5 changes: 2 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const { withPlausibleProxy } = require('next-plausible')

module.exports = withPlausibleProxy()({
reactStrictMode: true,
webpack5: true,
serverRuntimeConfig: {
APP_ROOT: __dirname,
},
Expand All @@ -18,8 +17,8 @@ module.exports = withPlausibleProxy()({
include: [dir],
use: [
defaultLoaders.babel,
{ loader: 'ts-loader', options: { transpileOnly: true } }
]
{ loader: 'ts-loader', options: { transpileOnly: true } },
],
})

config.resolve.fallback = {
Expand Down
4 changes: 2 additions & 2 deletions opcodes.json
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,8 @@
},
"5f": {
"input": "",
"output": "",
"description": ""
"output": "0",
"description": "Place value 0 on stack"
},
"60": {
"input": "",
Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"typecheck": "tsc --pretty"
},
"dependencies": {
"@ethereumjs/block": "^4.0.1",
"@ethereumjs/common": "^3.0.1",
"@ethereumjs/evm": "^1.2.0",
"@ethereumjs/statemanager": "^1.0.1",
"@ethereumjs/tx": "^4.0.1",
"@ethereumjs/util": "^8.0.2",
"@ethereumjs/vm": "^6.2.0",
"@ethereumjs/block": "^4.2.0",
"@ethereumjs/common": "^3.1.0",
"@ethereumjs/evm": "^1.3.0",
"@ethereumjs/statemanager": "^1.0.3",
"@ethereumjs/tx": "^4.1.0",
"@ethereumjs/util": "^8.0.4",
"@ethereumjs/vm": "^6.4.0",
"@kunigi/string-compression": "1.0.2",
"@mdx-js/loader": "^1.6.22",
"@mdx-js/react": "^1.6.22",
Expand Down Expand Up @@ -77,12 +77,13 @@
"sort-package-json": "^1.52.0",
"swc-loader": "^0.2.3",
"tailwindcss": "^3.1.2",
"tinyify": "^3.0.0",
"tinyify": "^4.0.0",
"ts-loader": "^9.3.1",
"typescript": "^4.4.4",
"webpack": "^5.74.0"
},
"resolutions": {
"@ethereumjs/util": "8.0.2"
"@types/react": "17.0.2",
"@types/react-dom": "17.0.2"
}
}
6 changes: 3 additions & 3 deletions util/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { BN } from 'ethereumjs-util'
import { IInstruction, IReferenceItem } from 'types'

// Version here: https://github.com/ethereum/solc-bin/blob/gh-pages/bin/list.txt
export const compilerSemVer = 'v0.8.17'
export const compilerVersion = `soljson-${compilerSemVer}+commit.8df45f5f`
export const compilerSemVer = 'v0.8.19'
export const compilerVersion = `soljson-${compilerSemVer}+commit.7dd6d404`

/**
* Gets target EVM version from a hardfork name
Expand Down Expand Up @@ -73,7 +73,7 @@ export const getBytecodeFromMnemonic = (
continue
}

if (line.startsWith('PUSH')) {
if (line !== 'PUSH0' && line.startsWith('PUSH')) {
const parts = line.split(/\s+/)

if (parts.length !== 2) {
Expand Down
2 changes: 1 addition & 1 deletion util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export const GITHUB_REPO_URL = 'https://github.com/comitylabs/evm.codes'

// Currently active hardfork from the ones available:
// See: https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/common/src/hardforks
export const CURRENT_FORK = 'merge'
export const CURRENT_FORK = 'shanghai'
2 changes: 1 addition & 1 deletion util/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ export const calculatePrecompiledDynamicFee = (
}

if (common.gteHardfork('berlin')) {
result.imul(multComplexityEIP2565(maxLen)).idivn(Gquaddivisor)
result.imul(multComplexityEIP2565(maxLen)).idivn(Gquaddivisor)
if (result.ltn(200)) {
result = new BN(200)
}
Expand Down
Loading

1 comment on commit 6ffdec8

@vercel
Copy link

@vercel vercel bot commented on 6ffdec8 Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.