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

Increase strictness of base types #305

Merged
merged 5 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
go-version: ^1.18
id: go
- name: Install staticcheck
- name: Install speccheck
run: go install github.com/lightclient/rpctestgen/cmd/speccheck@latest
- name: Install staticcheck
- name: Run speccheck
run: speccheck -v
2 changes: 1 addition & 1 deletion src/eth/state.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
title: Storage keys
type: array
items:
$ref: '#/components/schemas/hash32'
$ref: '#/components/schemas/bytesMax32'
- name: Block
required: true
schema:
Expand Down
18 changes: 11 additions & 7 deletions src/schemas/base-types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,39 @@ bytes:
title: hex encoded bytes
type: string
pattern: ^0x[0-9a-f]*$
bytesMax32:
title: 32 hex encoded bytes
type: string
pattern: ^0x[0-9a-f]{0,64}$
bytes8:
title: 8 hex encoded bytes
type: string
pattern: ^0x[0-9a-f]{16}$
bytes32:
title: 32 hex encoded bytes
type: string
pattern: ^0x([0-9a-f][0-9a-f]){0,32}$
pattern: ^0x[0-9a-f]{64}$
bytes256:
title: 256 hex encoded bytes
type: string
pattern: ^0x[0-9a-f]{512}$
bytes65:
title: 65 hex encoded bytes
type: string
pattern: ^0x[0-9a-f]{512}$
pattern: ^0x[0-9a-f]{65}$
uint:
title: hex encoded unsigned integer
type: string
pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
uint64:
title: hex encoded unsigned integer
title: hex encoded 64 bit unsigned integer
type: string
pattern: ^0x([1-9a-f][0-9a-f]{0,15})|0$
pattern: ^0x([1-9a-f]+[0-9a-f]{0,15})|0$
uint256:
title: hex encoded unsigned integer
title: hex encoded 256 bit unsigned integer
type: string
pattern: ^0x[0-9a-f]{0,64}$
pattern: ^0x([1-9a-f]+[0-9a-f]{0,31})|0$
hash32:
title: 32 byte hex value
type: string
pattern: ^0x([0-9a-f][0-9a-f]){0,32}$
pattern: ^0x[0-9a-f]{64}$
2 changes: 1 addition & 1 deletion src/schemas/receipt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ReceiptInfo:
root:
title: state root
description: The post-transaction state root. Only specified for transactions included before the Byzantium upgrade.
$ref: '#/components/schemas/bytes32'
$ref: '#/components/schemas/hash32'
status:
title: status
description: Either 1 (success) or 0 (failure). Only specified for transactions included after the Byzantium upgrade.
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/state.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ StorageProof:
properties:
key:
title: key
$ref: '#/components/schemas/hash32'
$ref: '#/components/schemas/bytesMax32'
value:
title: value
$ref: '#/components/schemas/uint256'
Expand Down
2 changes: 2 additions & 0 deletions tests/eth_getStorage/get-storage-invalid-key-too-large.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":12,"method":"eth_getStorageAt","params":["0xaa00000000000000000000000000000000000000","0x00000000000000000000000000000000000000000000000000000000000000000","latest"]}
<< {"jsonrpc":"2.0","id":12,"error":{"code":-32000,"message":"hex string of odd length"}}
2 changes: 2 additions & 0 deletions tests/eth_getStorage/get-storage-invalid-key.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":11,"method":"eth_getStorageAt","params":["0xaa00000000000000000000000000000000000000","0xasdf","latest"]}
<< {"jsonrpc":"2.0","id":11,"error":{"code":-32000,"message":"invalid hex string"}}