Skip to content

Commit 7e51215

Browse files
committed
native staking - store beacon deposit pubkeys to check for multiple usage
1 parent eced437 commit 7e51215

14 files changed

+464
-49
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.git
22
/node_modules
33
/lib
4+
/dump
45
/*Versions.json
56
npm-debug.log
67

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/node_modules
22
/lib
33
/builds
4+
/dump
45

56
/**Versions.json
67

abi/beacon-deposit-contract.json

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
[
2+
{
3+
"inputs": [],
4+
"stateMutability": "nonpayable",
5+
"type": "constructor"
6+
},
7+
{
8+
"anonymous": false,
9+
"inputs": [
10+
{
11+
"indexed": false,
12+
"internalType": "bytes",
13+
"name": "pubkey",
14+
"type": "bytes"
15+
},
16+
{
17+
"indexed": false,
18+
"internalType": "bytes",
19+
"name": "withdrawal_credentials",
20+
"type": "bytes"
21+
},
22+
{
23+
"indexed": false,
24+
"internalType": "bytes",
25+
"name": "amount",
26+
"type": "bytes"
27+
},
28+
{
29+
"indexed": false,
30+
"internalType": "bytes",
31+
"name": "signature",
32+
"type": "bytes"
33+
},
34+
{
35+
"indexed": false,
36+
"internalType": "bytes",
37+
"name": "index",
38+
"type": "bytes"
39+
}
40+
],
41+
"name": "DepositEvent",
42+
"type": "event"
43+
},
44+
{
45+
"inputs": [
46+
{
47+
"internalType": "bytes",
48+
"name": "pubkey",
49+
"type": "bytes"
50+
},
51+
{
52+
"internalType": "bytes",
53+
"name": "withdrawal_credentials",
54+
"type": "bytes"
55+
},
56+
{
57+
"internalType": "bytes",
58+
"name": "signature",
59+
"type": "bytes"
60+
},
61+
{
62+
"internalType": "bytes32",
63+
"name": "deposit_data_root",
64+
"type": "bytes32"
65+
}
66+
],
67+
"name": "deposit",
68+
"outputs": [],
69+
"stateMutability": "payable",
70+
"type": "function"
71+
},
72+
{
73+
"inputs": [],
74+
"name": "get_deposit_count",
75+
"outputs": [
76+
{
77+
"internalType": "bytes",
78+
"name": "",
79+
"type": "bytes"
80+
}
81+
],
82+
"stateMutability": "view",
83+
"type": "function"
84+
},
85+
{
86+
"inputs": [],
87+
"name": "get_deposit_root",
88+
"outputs": [
89+
{
90+
"internalType": "bytes32",
91+
"name": "",
92+
"type": "bytes32"
93+
}
94+
],
95+
"stateMutability": "view",
96+
"type": "function"
97+
},
98+
{
99+
"inputs": [
100+
{
101+
"internalType": "bytes4",
102+
"name": "interfaceId",
103+
"type": "bytes4"
104+
}
105+
],
106+
"name": "supportsInterface",
107+
"outputs": [
108+
{
109+
"internalType": "bool",
110+
"name": "",
111+
"type": "bool"
112+
}
113+
],
114+
"stateMutability": "pure",
115+
"type": "function"
116+
}
117+
]

db/migrations/1717097272796-Data.js renamed to db/migrations/1717645844084-Data.js

+22-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema.graphql

+22
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,28 @@ type GovernanceProposalVote @entity {
535535
type: GovernanceVoteType!
536536
txHash: String!
537537
timestamp: DateTime!
538+
}type BeaconDepositEvent @entity {
539+
id: ID! # `chainId:logId`
540+
chainId: Int! @index
541+
address: String! @index
542+
timestamp: DateTime! @index
543+
blockNumber: Int! @index
544+
txHash: String! @index
545+
caller: String! @index
546+
# Event Data
547+
pubkey: BeaconDepositPubkey!
548+
withdrawalCredentials: String!
549+
amount: String!
550+
signature: String!
551+
index: String!
552+
}
553+
554+
type BeaconDepositPubkey @entity {
555+
id: ID! # `pubkey`
556+
createDate: DateTime!
557+
lastUpdated: DateTime!
558+
count: Int!
559+
deposits: [BeaconDepositEvent!] @derivedFrom(field: "pubkey")
538560
}# OETH Vault: 0x39254033945AA2E4809Cc2977E7087BEE48bd7Ab
539561
"""
540562
The Vault entity tracks the OETH vault balance over time.

schema/native-staking.graphql

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
type BeaconDepositEvent @entity {
2+
id: ID! # `chainId:logId`
3+
chainId: Int! @index
4+
address: String! @index
5+
timestamp: DateTime! @index
6+
blockNumber: Int! @index
7+
txHash: String! @index
8+
caller: String! @index
9+
# Event Data
10+
pubkey: BeaconDepositPubkey!
11+
withdrawalCredentials: String!
12+
amount: String!
13+
signature: String!
14+
index: String!
15+
}
16+
17+
type BeaconDepositPubkey @entity {
18+
id: ID! # `pubkey`
19+
createDate: DateTime!
20+
lastUpdated: DateTime!
21+
count: Int!
22+
deposits: [BeaconDepositEvent!] @derivedFrom(field: "pubkey")
23+
}

src/abi/beacon-deposit-contract.ts

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import * as p from '@subsquid/evm-codec'
2+
import { event, fun, indexed, ContractBase } from '@subsquid/evm-abi'
3+
import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi'
4+
5+
export const events = {
6+
DepositEvent: event("0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5", {"pubkey": p.bytes, "withdrawal_credentials": p.bytes, "amount": p.bytes, "signature": p.bytes, "index": p.bytes}),
7+
}
8+
9+
export const functions = {
10+
deposit: fun("0x22895118", {"pubkey": p.bytes, "withdrawal_credentials": p.bytes, "signature": p.bytes, "deposit_data_root": p.bytes32}, ),
11+
get_deposit_count: fun("0x621fd130", {}, p.bytes),
12+
get_deposit_root: fun("0xc5f2892f", {}, p.bytes32),
13+
supportsInterface: fun("0x01ffc9a7", {"interfaceId": p.bytes4}, p.bool),
14+
}
15+
16+
export class Contract extends ContractBase {
17+
18+
get_deposit_count() {
19+
return this.eth_call(functions.get_deposit_count, {})
20+
}
21+
22+
get_deposit_root() {
23+
return this.eth_call(functions.get_deposit_root, {})
24+
}
25+
26+
supportsInterface(interfaceId: SupportsInterfaceParams["interfaceId"]) {
27+
return this.eth_call(functions.supportsInterface, {interfaceId})
28+
}
29+
}
30+
31+
/// Event types
32+
export type DepositEventEventArgs = EParams<typeof events.DepositEvent>
33+
34+
/// Function types
35+
export type DepositParams = FunctionArguments<typeof functions.deposit>
36+
export type DepositReturn = FunctionReturn<typeof functions.deposit>
37+
38+
export type Get_deposit_countParams = FunctionArguments<typeof functions.get_deposit_count>
39+
export type Get_deposit_countReturn = FunctionReturn<typeof functions.get_deposit_count>
40+
41+
export type Get_deposit_rootParams = FunctionArguments<typeof functions.get_deposit_root>
42+
export type Get_deposit_rootReturn = FunctionReturn<typeof functions.get_deposit_root>
43+
44+
export type SupportsInterfaceParams = FunctionArguments<typeof functions.supportsInterface>
45+
export type SupportsInterfaceReturn = FunctionReturn<typeof functions.supportsInterface>
46+

src/main-mainnet.ts

+2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import { OGN_ADDRESS, OGN_REWARDS_SOURCE_ADDRESS, XOGN_ADDRESS } from '@utils/ad
1010

1111
import * as curve from './mainnet/processors/curve'
1212
import { erc20s } from './mainnet/processors/erc20s'
13+
import * as nativeStaking from './mainnet/processors/native-staking'
1314
import * as validate from './mainnet/validators/validate-mainnet'
1415

1516
export const processor = {
1617
stateSchema: 'mainnet-processor',
1718
processors: [
19+
nativeStaking,
1820
curve,
1921
...erc20s(),
2022
// createGovernanceProcessor({ from: 0000000000, address: OGN_GOVERNANCE_ADDRESS }),

0 commit comments

Comments
 (0)