ethereum / ethereum/execution-apis

JSONRPC: Account update subscription

Open
#615 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Io
Stars
1.1k
Forks
530
Avg merge
5d 8h
Merged PRs (30d)
9

Description

### Motivation
___

There is no universal solution to see activity of an address. Today, one way is to listen and look block logs activity but they are not covering all cases, some are not emitting events. in addition to subscribe to nonce, balance, code update, this method tries to watch all account activity by looking at the KECCAK256 and SSTORE level.

### Websocket specification
___

Parameters:

1. `accountUpdate`
2. `object`
2.a. `nonce` (optional): boolean to subscribe to nonce update
2.b. `balance` (optional): boolean to subscribe to balance update
2.c. `code` (optional): boolean to subscribe to code update
2.d. `storageSlots` (optional): list of storage slots update (SSTORE)
2.f. `preKeccak256StorageKey` (optional): list of keccak256 input used as storage key
3. List of addresses to watch. If null, watch all changes (optional)

```json
{
"jsonrpc": "2.0",
"method": "eth_subscribe",
"params": [
"accountUpdate",
{
"nonce": true, // optional
"balance": true, // optional
"code": true, // optional
"storageSlots": [
"..." // storage slots - optional
],
"preKeccak256StorageKey": [
"..." // list of addresses used in a keccak256 for an SSTORE - optional
],
},
[...] // list of smart contract/EOA addresses - optional
],
"id": 1
}
>>>
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x9ce59a13059e417087c02d3236a0b1cc"
}
```

Notification Response:
- `subscription id`
- `result`
- `blockHash`: 32 bytes. Hash of the block including this transaction
- `blockNumber`: Block number including this transaction.
- `transactionHash`: 32 bytes. The hash of the transaction.
- OR
- `nonceUpdate`
- `balanceUpdate`
- `codeUpdate`
- `storageUpdate` object:
- `account address`: list of accounts with update
- `storageKey` list of storage key with update
- `preKeccak256StorageKey` Input of the Keccak256 used for the storage
- `value` new value of the storage key

```json
>>>
{
"jsonrpc": "2.0",
"method": "eth_subscription",
"params": {
"subscription": "0x9ce59a13059e417087c02d3236a0b1cc",
"result": {
"blockHash": "0xabc",
"blockNumber": 1213232,
"transactionHash": "0x38c0a3cea017d3c9213d86037beb0f5ac49e46d262925139dd536f30a12e5461",
"storageUpdate": {
"0xc8ba32cab1757528daf49033e3673fae77dcf05d": { // smart contract address
"0x59fb7853eb21f604d010b94c123acbeae621f09ce15ee5d7616485b1e78a72e9" { // storage key
"preKeccak256StorageKeyy": ["0x000000000000000000000000974caa59e49682cda0ad2bbe82983419a2ecc4000000000000000000000000000000000000000000000000000000000000000006"] // pre-processed storage key value (if applicable)
"value": "0x00000000000000c42b56a52aedf18667c8ae258a0280a8912641c80c48cd9548" // storage value
}
}
}
}
}
}
>>>
{
"jsonrpc": "2.0",
"method": "eth_subscription",
"params": {
"subscription": "0x9ce59a13059e417087c02d3236a0b1cc",
"result": {
"blockNumber": 1213232,
"blockHash": "0xabc",
"txHash": "0x38c0a3cea017d3c9213d86037beb0f5ac49e46d262925139dd536f30a12e5461",
"nonceUpdate": "0x1"
}
}
}
>>>
{
"jsonrpc": "2.0",
"method": "eth_subscription",
"params": {
"subscription": "0x9ce59a13059e417087c02d3236a0b1cc",
"result": {
"blockNumber": 1213232,
"blockHash": "0xabc",
"txHash": "0x38c0a3cea017d3c9213d86037beb0f5ac49e46d262925139dd536f30a12e5461",
"balanceUpdate": "0xaa"
}
}
}
```

### HTTP filter subscription specification
___

Parameters:

1. `object`
1.a. `nonce` (optional): boolean to subscribe to nonce update
1.b. `balance` (optional): boolean to subscribe to balance update
1.c. `code` (optional): boolean to subscribe to code update
1.d. `storageSlots` (optional): list of storage slots update (SSTORE)
1.f. `preKeccak256StorageKey` (optional): list of keccak256 input used as storage key
2. List of addresses to watch. If null, watch all changes (optional)

```json
{
"jsonrpc": "2.0",
"method": "eth_newStorageUpdateFilter",
"params": [
{
"nonce": true, // optional
"balance": true, // optional
"code": true, // optional
"storageSlots": [
"..." // storage slots - optional
],
"preKeccak256StorageKey": [
"..." // list of addresses used in a keccak256 for an SSTORE - optional
],
},
[...] // list of smart contract/EOA addresses - optional
],
"id": 1
}
>>>
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x9ce59a13059e417087c02d3236a0b1cc"
}
```

eth_getFilterChanges response:

```json
{
"jsonrpc": "2.0",
"method": "eth_getFilterChanges",
"params": ["0x9ce59a13059e417087c02d3236a0b1cc"],
"id": 1
}
>>>
{
"jsonrpc": "2.0",
"id": 73,
"result": [
{
"blockHash": "0xabc",
"blockNumber": 1213232,
"transactionHash": "0x38c0a3cea017d3c9213d86037beb0f5ac49e46d262925139dd536f30a12e5461",
"storageUpdate": {
"0xc8ba32cab1757528daf49033e3673fae77dcf05d": { // smart contract address
"0x59fb7853eb21f604d010b94c123acbeae621f09ce15ee5d7616485b1e78a72e9" { // storage key
"preKeccak256StorageKeyy": ["0x000000000000000000000000974caa59e49682cda0ad2bbe82983419a2ecc4000000000000000000000000000000000000000000000000000000000000000006"] // pre-processed storage key value (if applicable)
"value": "0x00000000000000c42b56a52aedf18667c8ae258a0280a8912641c80c48cd9548" // storage value
}
}
}
}
[...]
]
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.