Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vyper support to Sourcify #1784

Draft
wants to merge 8 commits into
base: staging
Choose a base branch
from
Draft
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@
"console": "integratedTerminal"
// "internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
"name": "Mocha - bytecode-utils",
"cwd": "${workspaceFolder}/packages/bytecode-utils",
"program": "${workspaceRoot}/node_modules/.bin/mocha",
"args": [
"-r",
"ts-node/register",
"./test/**/*.spec.ts",
"--no-timeout",
// Run a single test when debugging
// "--grep=v0.6.12",
"--exit"
],
"sourceMaps": true,
"smartStep": true,
"console": "integratedTerminal"
// "internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

[![codecov](https://codecov.io/gh/ethereum/sourcify/branch/staging/graph/badge.svg?token=eN6XDAwWfV)](https://codecov.io/gh/ethereum/sourcify)

Sourcify ([sourcify.dev](https://sourcify.dev)) is a Solidity source code verification service for Ethereum smart contracts.
Sourcify ([sourcify.dev](https://sourcify.dev)) is a source code verification service for Ethereum smart contracts supporting Solidity and Vyper.

Different than other verification services, Sourcify leverages the [Solidity metadata](https://docs.sourcify.dev/docs/metadata/) file to ["fully verify"](https://docs.sourcify.dev/docs/full-vs-partial-match/) the contracts.
Different than other verification services, Sourcify leverages the [metadata](https://docs.sourcify.dev/docs/metadata/) file to ["fully verify"](https://docs.sourcify.dev/docs/full-vs-partial-match/) the Solidity contracts.

Sourcify mainly consists of:

Expand Down
5 changes: 4 additions & 1 deletion package-lock.json

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

51 changes: 42 additions & 9 deletions packages/bytecode-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,57 @@ yarn add @ethereum-sourcify/bytecode-utils

## Usage

### Solidity Contracts

```ts
import { decode } from "@ethereum-sourcify/bytecode-utils";
import { decode, AuxdataStyle } from "@ethereum-sourcify/bytecode-utils";

const bytecodeRaw = "0x60806040526004361061003f5760003560e01...7265206c656e677468a2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b0033"

decode(bytecodeRaw);
// For Solidity contracts
decode(bytecodeRaw, AuxdataStyle.SOLIDITY);
```

### Result
**Result example**

```json
{
"cbor": {
"bytes": "0xa2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b",
"length": 51
},
"ipfs": "QmdD3hpMj6mEFVy9DP4QqjHaoeYbhKsYvApX1YZNfjTVWp",
"solcVersion": "0.6.11"
"experimental": true
"solcVersion": "0.6.11",
"experimental": true,
"bzzr0": "...",
"bzzr1": "..."
}
```

### Vyper Contracts

```ts
import { decode, AuxdataStyle } from "@ethereum-sourcify/bytecode-utils";

const vyperBytecodeRaw = "0x..."; // Your Vyper contract bytecode

// For Vyper contracts
decode(vyperBytecodeRaw, AuxdataStyle.VYPER);
```

**Result example**

```json
{
"integrity": "...",
"runtimeSize": 1234,
"dataSizes": [32, 64, 128],
"immutableSize": 256,
"vyperVersion": "0.3.10"
}
```

#### Vyper Version Compatibility Notes

Different Vyper compiler versions use different auxdata formats:

- **Before v0.3.5**: Auxdata only contains version information in cbor, without length data after it
- **v0.3.5 to v0.3.9**: Auxdata includes version and length information in cbor
- **v0.3.10 to v0.4.0**: Auxdata is stored as a cbor array with version object as last element
- **v0.4.1 and later**: Auxdata cbor array includes integrity check as first element
3 changes: 2 additions & 1 deletion packages/bytecode-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"@ethersproject/bytes": "5.7.0",
"base-x": "4.0.0",
"bs58": "5.0.0",
"cbor-x": "1.6.0"
"cbor-x": "1.6.0",
"semver": "^7.6.3"
},
"devDependencies": {
"@types/chai": "4.3.20",
Expand Down
Loading