Skip to content

Commit

Permalink
🐛 Fix(api): Replace enum with string type for EvmError (#811)
Browse files Browse the repository at this point in the history
## Description

_Concise description of proposed changes_

## Testing

Explain the quality checks that have been done on the code changes

## Additional Information

- [ ] I read the [contributing docs](../docs/contributing.md) (if this
is your first contribution)

Your ENS/address:



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Documentation**
- Updated the API documentation to reflect the correct line numbers for
various entities.

- **New Features**
- Enhanced the error message system to include a broader range of
EVM-related errors.

- **Bug Fixes**
- Fixed a bug in the "@tevm/api" package to correctly handle EVM error
types without the need for external imports.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Will Cory <[email protected]>
  • Loading branch information
roninjin10 and Will Cory authored Jan 11, 2024
1 parent 8b3218b commit 87427f3
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-foxes-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tevm/api": patch
---

Fixed bug with EVM errors requiring importing ethereumjs enum to typematch
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions tevm/docs/modules/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Properties shared accross call-like params

#### Defined in

vm/api/dist/index.d.ts:77
vm/api/dist/index.d.ts:76

___

Expand All @@ -292,7 +292,7 @@ Header information of an ethereum block

#### Defined in

vm/api/dist/index.d.ts:43
vm/api/dist/index.d.ts:42

___

Expand Down Expand Up @@ -496,7 +496,7 @@ Error type of errors thrown while internally executing a call in the EVM

| Name | Type |
| :------ | :------ |
| `TEVMErrorMessage` | extends `EVMErrorMessage` = `EVMErrorMessage` |
| `TEVMErrorMessage` | extends `TevmEVMErrorMessage` = `TevmEVMErrorMessage` |

#### Defined in

Expand Down Expand Up @@ -524,7 +524,7 @@ Error thrown when balance parameter is invalid

#### Defined in

vm/api/dist/index.d.ts:219
vm/api/dist/index.d.ts:218

___

Expand Down Expand Up @@ -560,7 +560,7 @@ Error thrown when bytecode parameter is invalid

#### Defined in

vm/api/dist/index.d.ts:204
vm/api/dist/index.d.ts:203

___

Expand All @@ -584,7 +584,7 @@ Error thrown when data parameter is invalid

#### Defined in

vm/api/dist/index.d.ts:214
vm/api/dist/index.d.ts:213

___

Expand Down Expand Up @@ -620,7 +620,7 @@ Error thrown when function name is invalid

#### Defined in

vm/api/dist/index.d.ts:224
vm/api/dist/index.d.ts:223

___

Expand Down Expand Up @@ -740,7 +740,7 @@ Error thrown when storage root parameter is invalid

#### Defined in

vm/api/dist/index.d.ts:209
vm/api/dist/index.d.ts:208

___

Expand Down Expand Up @@ -830,7 +830,7 @@ Generic log information

#### Defined in

vm/api/dist/index.d.ts:180
vm/api/dist/index.d.ts:179

___

Expand Down Expand Up @@ -990,7 +990,7 @@ for tevm users.

#### Defined in

vm/api/dist/index.d.ts:194
vm/api/dist/index.d.ts:193

___

Expand Down
8 changes: 4 additions & 4 deletions tevm/docs/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const accountParams: import('@tevm/api').AccountParams = {

#### Defined in

vm/api/dist/index.d.ts:17
vm/api/dist/index.d.ts:16

___

Expand Down Expand Up @@ -139,7 +139,7 @@ const callParams: import('@tevm/api').CallParams = {

#### Defined in

vm/api/dist/index.d.ts:142
vm/api/dist/index.d.ts:141

___

Expand Down Expand Up @@ -191,7 +191,7 @@ Tevm params to execute a call on a contract

#### Defined in

vm/api/dist/index.d.ts:160
vm/api/dist/index.d.ts:159

___

Expand Down Expand Up @@ -258,7 +258,7 @@ Tevm params for deploying and running a script

#### Defined in

vm/api/dist/index.d.ts:170
vm/api/dist/index.d.ts:169

___

Expand Down
4 changes: 2 additions & 2 deletions vm/api/docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,11 @@ Error type of errors thrown while internally executing a call in the EVM

| Name | Type |
| :------ | :------ |
| `TEVMErrorMessage` | extends `EVMErrorMessage` = `EVMErrorMessage` |
| `TEVMErrorMessage` | extends `TevmEVMErrorMessage` = `TevmEVMErrorMessage` |

#### Defined in

[errors/EvmError.ts:7](https://github.com/evmts/tevm-monorepo/blob/main/vm/api/src/errors/EvmError.ts#L7)
[errors/EvmError.ts:45](https://github.com/evmts/tevm-monorepo/blob/main/vm/api/src/errors/EvmError.ts#L45)

___

Expand Down
1 change: 0 additions & 1 deletion vm/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@ethereumjs/evm": "^2.1.0",
"@tevm/tsconfig": "workspace:^",
"@tevm/tsupconfig": "workspace:^",
"abitype": "^0.10.3",
Expand Down
42 changes: 40 additions & 2 deletions vm/api/src/errors/EvmError.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
import type { TypedError } from './TypedError.js'
import { EVMErrorMessage } from '@ethereumjs/evm'

export type TevmEVMErrorMessage =
| 'out of gas'
| 'code store out of gas'
| 'code size to deposit exceeds maximum code size'
| 'stack underflow'
| 'stack overflow'
| 'invalid JUMP'
| 'invalid opcode'
| 'value out of range'
| 'revert'
| 'static state change'
| 'internal error'
| 'create collision'
| 'stop'
| 'refund exhausted'
| 'value overflow'
| 'insufficient balance'
| 'invalid BEGINSUB'
| 'invalid RETURNSUB'
| 'invalid JUMPSUB'
| 'invalid bytecode deployed'
| 'invalid EOF format'
| 'initcode exceeds max initcode size'
| 'invalid input length'
| 'attempting to AUTHCALL without AUTH set'
| 'attempting to execute AUTHCALL with nonzero external value'
| 'invalid Signature: s-values greater than secp256k1n/2 are considered invalid'

// BLS errors
| 'invalid input length'
| 'point not on curve'
| 'input is empty'
| 'fp point not in field'

// Point Evaluation Errors
| 'kzg commitment does not match versioned hash'
| 'kzg inputs invalid'
| 'kzg proof invalid'

/**
* Error type of errors thrown while internally executing a call in the EVM
*/
export type EvmError<
TEVMErrorMessage extends EVMErrorMessage = EVMErrorMessage,
TEVMErrorMessage extends TevmEVMErrorMessage = TevmEVMErrorMessage,
> = TypedError<TEVMErrorMessage>
2 changes: 1 addition & 1 deletion vm/vm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@
"publishConfig": {
"access": "public"
}
}
}

1 comment on commit 87427f3

@vercel
Copy link

@vercel vercel bot commented on 87427f3 Jan 11, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

evmts-docs – ./

evmts-docs-git-main-evmts.vercel.app
evmts.dev
evmts-docs-evmts.vercel.app

Please sign in to comment.