Skip to content

Commit 156833c

Browse files
committed
new object pools view
1 parent 17f044d commit 156833c

File tree

12 files changed

+317
-244
lines changed

12 files changed

+317
-244
lines changed

.gitmodules

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,13 @@
212212
[submodule "vendor/eth2-networks"]
213213
path = vendor/eth2-networks
214214
url = https://github.com/eth2-clients/eth2-networks.git
215+
216+
[submodule "vendor/DOtherSide"]
217+
path = vendor/DOtherSide
218+
url = https://github.com/filcuc/DOtherSide.git
219+
branch = master
220+
[submodule "vendor/nimqml"]
221+
path = vendor/nimqml
222+
url = https://github.com/filcuc/nimqml.git
223+
branch = master
224+

beacon_chain/rpc/eth2_json_rest_serialization.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ type
198198
DataRestPoolAttestations* = DataEnclosedObject[seq[Attestation]]
199199
DataRestPoolAttesterSlashings* = DataEnclosedObject[seq[AttesterSlashing]]
200200
DataRestPoolProposerSlashings* = DataEnclosedObject[seq[ProposerSlashing]]
201-
DataRestPoolVoluntaryExits* = DataEnclosedObject[seq[VoluntaryExit]]
201+
DataRestPoolVoluntaryExits* = DataEnclosedObject[seq[SignedVoluntaryExit]]
202202
DataRestProposerDuties* = DataRootEnclosedObject[seq[RestProposerDuty]]
203203
DataRestSignedBeaconBlock* = DataEnclosedObject[phase0.SignedBeaconBlock]
204204
DataRestSyncInfo* = DataEnclosedObject[RestSyncInfo]

ngui/attestationlist.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import
2-
std/[tables],
2+
std/[sequtils, tables],
33
NimQml,
44
../beacon_chain/rpc/beacon_rest_client,
55
../beacon_chain/spec/[datatypes, helpers],
@@ -39,9 +39,9 @@ QtObject:
3939
proc delete(self: AttestationList) =
4040
self.QAbstractTableModel.delete
4141

42-
proc newAttestationList*(data: seq[AttestationInfo]): AttestationList =
42+
proc newAttestationList*(data: seq[Attestation]): AttestationList =
4343
new(result, delete)
44-
result.data = ObjectTableModelImpl[AttestationInfo](items: data)
44+
result.data = ObjectTableModelImpl[AttestationInfo](items: data.mapIt(it.toAttestationInfo()))
4545
result.setup
4646

4747
method rowCount(self: AttestationList, index: QModelIndex = nil): int =
@@ -59,8 +59,8 @@ QtObject:
5959
method roleNames(self: AttestationList): Table[int, string] =
6060
self.data.roleNames()
6161

62-
proc setNewData*(self: AttestationList, v: seq[AttestationInfo]) =
63-
self.data.setNewData(self, v)
62+
proc setNewData*(self: AttestationList, v: seq[Attestation]) =
63+
self.data.setNewData(self, v.mapIt(it.toAttestationInfo()))
6464

6565
proc sort*(self: AttestationList, section: int) {.slot.} =
6666
self.data.sort(self, section)

ngui/blockmodel.nim

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ import
55
NimQml,
66
../beacon_chain/rpc/beacon_rest_client,
77
../beacon_chain/spec/[datatypes, crypto],
8-
./attestationlist, ./depositlist, ./utils
8+
"."/[
9+
attestationlist, depositlist, attesterslashinglist, proposerslashinglist,
10+
voluntaryexitlist, utils]
911

1012
QtObject:
1113
type
1214
BlockModel* = ref object of QObject
1315
blck: SignedBeaconBlock
1416
attestationsx: AttestationList
1517
depositsx: DepositList
18+
attester_slashingsx: AttesterSlashingList
19+
proposer_slashingsx: ProposerSlashingList
20+
voluntary_exitsx: VoluntaryExitList
1621
genesis_time*: uint64
1722

1823
proc delete*(self: BlockModel) =
@@ -24,17 +29,23 @@ QtObject:
2429
proc newBlockModel*(blck: SignedBeaconBlock, genesis_time: uint64): BlockModel =
2530
let res = BlockModel(
2631
blck: blck,
27-
attestationsx: newAttestationList(blck.message.body.attestations.mapIt(it.toAttestationInfo())),
32+
attestationsx: newAttestationList(blck.message.body.attestations.asSeq()),
2833
depositsx: newDepositList(blck.message.body.deposits.mapIt(it.toDepositInfo())),
34+
attester_slashingsx: newAttesterSlashingList(blck.message.body.attester_slashings.asSeq()),
35+
proposer_slashingsx: newProposerSlashingList(blck.message.body.proposer_slashings.asSeq()),
36+
voluntary_exitsx: newVoluntaryExitList(blck.message.body.voluntary_exits.asSeq()),
2937
genesis_time: genesis_time,
3038
)
3139
res.setup()
3240
res
3341

3442
proc `blck=`*(self: BlockModel, blck: SignedBeaconBlock) =
35-
self.blck = blck
36-
self.attestationsx.setNewData(blck.message.body.attestations.mapIt(it.toAttestationInfo()))
37-
self.depositsx.setNewData(blck.message.body.deposits.mapIt(it.toDepositInfo()))
43+
self.blck = blck
44+
self.attestationsx.setNewData(blck.message.body.attestations.asSeq())
45+
self.depositsx.setNewData(blck.message.body.deposits.mapIt(it.toDepositInfo()))
46+
self.attester_slashingsx.setNewData(blck.message.body.attester_slashings.asSeq())
47+
self.proposer_slashingsx.setNewData(blck.message.body.proposer_slashings.asSeq())
48+
self.voluntary_exitsx.setNewData(blck.message.body.voluntary_exits.asSeq())
3849

3950
proc slot*(self: BlockModel): int {.slot.} = self.blck.message.slot.int
4051
QtProperty[int] slot: read = slot
@@ -65,20 +76,20 @@ QtObject:
6576
proc graffiti*(self: BlockModel): string {.slot.} = $self.blck.message.body.graffiti
6677
QtProperty[string] graffiti: read = graffiti
6778

68-
proc proposer_slashings*(self: BlockModel): string {.slot.} = RestJson.encode(self.blck.message.body.proposer_slashings, pretty=true)
69-
QtProperty[string] proposer_slashings: read = proposer_slashings
79+
proc proposer_slashings*(self: BlockModel): QVariant {.slot.} = newQVariant(self.proposer_slashingsx)
80+
QtProperty[QVariant] proposer_slashings: read = proposer_slashings
7081

71-
proc attester_slashings*(self: BlockModel): string {.slot.} = RestJson.encode(self.blck.message.body.attester_slashings.asSeq(), pretty=true)
72-
QtProperty[string] attester_slashings: read = attester_slashings
82+
proc attester_slashings*(self: BlockModel): QVariant {.slot.} = newQVariant(self.attester_slashingsx)
83+
QtProperty[QVariant] attester_slashings: read = attester_slashings
7384

7485
proc attestations*(self: BlockModel): QVariant {.slot.} = newQVariant(self.attestationsx)
7586
QtProperty[QVariant] attestations: read = attestations
7687

7788
proc deposits*(self: BlockModel): QVariant {.slot.} = newQVariant(self.depositsx)
7889
QtProperty[QVariant] deposits: read = deposits
7990

80-
proc voluntary_exits*(self: BlockModel): string {.slot.} = RestJson.encode(self.blck.message.body.voluntary_exits.asSeq(), pretty=true)
81-
QtProperty[string] voluntary_exits: read = voluntary_exits
91+
proc voluntary_exits*(self: BlockModel): QVariant {.slot.} = newQVariant(self.voluntary_exitsx)
92+
QtProperty[QVariant] voluntary_exits: read = voluntary_exits
8293

8394
proc signature*(self: BlockModel): string {.slot.} = toDisplayHex(self.blck.signature)
8495
QtProperty[string] signature: read = signature

ngui/mainmodel.nim

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import
2-
NimQml, blockmodel, footermodel, epochmodel, peerlist, slotlist, nodemodel
2+
NimQml,
3+
"."/[
4+
blockmodel, footermodel, epochmodel, peerlist, slotlist, nodemodel,
5+
poolmodel]
36

47
import
58
std/[os, strutils],
69
chronos, metrics,
710

811
# Local modules
912
../beacon_chain/rpc/[beacon_rest_client, rest_utils],
13+
../beacon_chain/ssz/merkleization,
1014
../beacon_chain/spec/[datatypes, digest, crypto, helpers]
1115

1216
QtObject:
@@ -18,6 +22,7 @@ QtObject:
1822
peerList: PeerList
1923
epochModel: EpochModel
2024
nodeModel: NodeModel
25+
poolModel: PoolModel
2126

2227
genesis: RestBeaconGenesis
2328
currentIndex: int
@@ -34,13 +39,13 @@ QtObject:
3439
let
3540
client = RestClientRef.new("http://127.0.0.1:8190").get()
3641

37-
let
42+
var
3843
headBlock = (waitFor client.getBlock(BlockIdent.init(BlockIdentType.Head))).data.data
3944
epoch = headBlock.message.slot.epoch
4045
genesis = (waitFor client.getBeaconGenesis()).data.data
4146
peerList = newPeerList(@[])
4247

43-
# peerList.setNewData(waitFor client.get_v1_node_peers(some(newseq[string]()), some(newseq[string]())))
48+
headBlock.root = hash_tree_root(headBlock.message)
4449

4550
let res = MainModel(
4651
app: app,
@@ -50,6 +55,7 @@ QtObject:
5055
peerList: peerList,
5156
epochModel: newEpochModel(client, epoch.int),
5257
nodeModel: newNodeModel(client),
58+
poolModel: newPoolModel(client),
5359
genesis: genesis,
5460
)
5561
res.setup()
@@ -126,10 +132,15 @@ QtObject:
126132
QtProperty[QVariant] nodeModel:
127133
read = getNodeModel
128134

135+
proc getPoolModel(self: MainModel): QVariant {.slot.} = newQVariant(self.poolModel)
136+
QtProperty[QVariant] poolModel:
137+
read = getPoolModel
138+
129139
proc onLoadBlock(self: MainModel, root: string) {.slot.} =
130140
try:
131-
let blck = waitFor(self.client.getBlock(
141+
var blck = waitFor(self.client.getBlock(
132142
BlockIdent.decodeString(root).tryGet())).data.data
143+
blck.root = hash_tree_root(blck.message)
133144
self.setBlck(blck)
134145
except CatchableError as exc:
135146
echo exc.msg

ngui/nodemodel.nim

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ QtObject:
1818
NodeModel* = ref object of QObject
1919
client: RestClientRef
2020
genesis: string
21-
attestations: string
22-
attester_slashings: string
23-
proposer_slashings: string
24-
voluntary_exits: string
2521
heads: string
2622
identity: string
2723
version: string
@@ -38,56 +34,16 @@ QtObject:
3834
res.setup()
3935
res
4036

41-
proc getGenesis*(self: NodeModel): string {.slot.} = self.genesis
37+
proc getgenesis*(self: NodeModel): string {.slot.} = self.genesis
4238
proc genesisChanged*(self: NodeModel, v: string) {.signal.}
43-
proc setGenesis*(self: NodeModel, v: string) =
39+
proc setgenesis*(self: NodeModel, v: string) =
4440
self.genesis = v
4541
self.genesisChanged(v)
4642
QtProperty[string] genesis:
4743
read = getgenesis
4844
notify = genesisChanged
4945
write = setgenesis
5046

51-
proc getattestations*(self: NodeModel): string {.slot.} = self.attestations
52-
proc attestationsChanged*(self: NodeModel, v: string) {.signal.}
53-
proc setattestations*(self: NodeModel, v: string) =
54-
self.attestations = v
55-
self.attestationsChanged(v)
56-
QtProperty[string] attestations:
57-
read = getattestations
58-
notify = attestationsChanged
59-
write = setattestations
60-
61-
proc getattester_slashings*(self: NodeModel): string {.slot.} = self.attester_slashings
62-
proc attester_slashingsChanged*(self: NodeModel, v: string) {.signal.}
63-
proc setattester_slashings*(self: NodeModel, v: string) =
64-
self.attester_slashings = v
65-
self.attester_slashingsChanged(v)
66-
QtProperty[string] attester_slashings:
67-
read = getattester_slashings
68-
notify = attester_slashingsChanged
69-
write = setattester_slashings
70-
71-
proc getproposer_slashings*(self: NodeModel): string {.slot.} = self.proposer_slashings
72-
proc proposer_slashingsChanged*(self: NodeModel, v: string) {.signal.}
73-
proc setproposer_slashings*(self: NodeModel, v: string) =
74-
self.proposer_slashings = v
75-
self.proposer_slashingsChanged(v)
76-
QtProperty[string] proposer_slashings:
77-
read = getproposer_slashings
78-
notify = proposer_slashingsChanged
79-
write = setproposer_slashings
80-
81-
proc getvoluntary_exits*(self: NodeModel): string {.slot.} = self.voluntary_exits
82-
proc voluntary_exitsChanged*(self: NodeModel, v: string) {.signal.}
83-
proc setvoluntary_exits*(self: NodeModel, v: string) =
84-
self.voluntary_exits = v
85-
self.voluntary_exitsChanged(v)
86-
QtProperty[string] voluntary_exits:
87-
read = getvoluntary_exits
88-
notify = voluntary_exitsChanged
89-
write = setvoluntary_exits
90-
9147
proc getheads*(self: NodeModel): string {.slot.} = self.heads
9248
proc headsChanged*(self: NodeModel, v: string) {.signal.}
9349
proc setheads*(self: NodeModel, v: string) =
@@ -129,12 +85,10 @@ QtObject:
12985
write = sethealth
13086

13187
proc update*(self: NodeModel) {.slot.} =
132-
self.setgenesis(xxx(waitFor self.client.getBeaconGenesis()))
133-
self.setattestations(xxx(waitFor self.client.getPoolAttestations(none(Slot), none(CommitteeIndex))))
134-
self.setattester_slashings(xxx(waitFor self.client.getPoolAttesterSlashings()))
135-
self.setproposer_slashings(xxx(waitFor self.client.getPoolProposerSlashings()))
136-
self.setvoluntary_exits(xxx(waitFor self.client.getPoolVoluntaryExits()))
137-
self.setheads(xxx(waitFor self.client.getDebugChainHeads()))
138-
self.setidentity(xxx(waitFor self.client.getNetworkIdentity()))
139-
self.setversion(xxx(waitFor self.client.getNodeVersion()))
140-
self.sethealth(xxx(waitFor self.client.getHealth()))
88+
self.setgenesis(xxx(waitFor(self.client.getBeaconGenesis()).data.data))
89+
self.setheads(xxx(waitFor(self.client.getDebugChainHeads()).data.data.mapIt(
90+
toBlockLink(it.root) & " @ " & $it.slot
91+
).join("\n")))
92+
self.setidentity(xxx(waitFor(self.client.getNetworkIdentity()).data.data))
93+
self.setversion(xxx(waitFor(self.client.getNodeVersion()).data.data.version))
94+
self.sethealth(xxx(waitFor(self.client.getHealth())))

0 commit comments

Comments
 (0)