Skip to content

Commit bdce27e

Browse files
committed
Rename finalized history network to history network
1 parent 987dd13 commit bdce27e

13 files changed

+44
-54
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

portal/network/finalized_history/finalized_history_endpoints.nim renamed to portal/network/history/history_endpoints.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77

88
{.push raises: [].}
99

10-
import results, chronicles, chronos, ./finalized_history_network
10+
import results, chronicles, chronos, ./history_network
1111

12-
export results, finalized_history_network
12+
export results, history_network
1313

1414
proc getBlockBody*(
15-
n: FinalizedHistoryNetwork, header: Header
15+
n: HistoryNetwork, header: Header
1616
): Future[Opt[BlockBody]] {.async: (raises: [CancelledError], raw: true).} =
1717
n.getContent(blockBodyContentKey(header.number), BlockBody, header)
1818

1919
proc getReceipts*(
20-
n: FinalizedHistoryNetwork, header: Header
20+
n: HistoryNetwork, header: Header
2121
): Future[Opt[BlockBody]] {.async: (raises: [CancelledError], raw: true).} =
2222
n.getContent(blockBodyContentKey(header.number), BlockBody, header)

portal/network/finalized_history/finalized_history_network.nim renamed to portal/network/history/history_network.nim

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import
1818
../../database/content_db,
1919
# ../network_metadata,
2020
../wire/[portal_protocol, portal_stream, portal_protocol_config, ping_extensions],
21-
"."/[finalized_history_content, finalized_history_validation]
21+
"."/[history_content, history_validation]
2222

2323
from eth/common/accounts import EMPTY_ROOT_HASH
2424

25-
export finalized_history_content, headers
25+
export history_content, headers
2626

2727
logScope:
2828
topics = "portal_fin_hist"
@@ -34,7 +34,7 @@ type
3434
async: (raises: [CancelledError]), gcsafe
3535
.}
3636

37-
FinalizedHistoryNetwork* = ref object
37+
HistoryNetwork* = ref object
3838
portalProtocol*: PortalProtocol
3939
contentDB*: ContentDB
4040
contentQueue*: AsyncQueue[(Opt[NodeId], ContentKeysList, seq[seq[byte]])]
@@ -57,7 +57,7 @@ func toContentIdHandler(contentKey: ContentKeyByteList): results.Opt[ContentId]
5757
toContentId(contentKey)
5858

5959
proc new*(
60-
T: type FinalizedHistoryNetwork,
60+
T: type HistoryNetwork,
6161
portalNetwork: PortalNetwork,
6262
baseProtocol: protocol.Protocol,
6363
contentDB: ContentDB,
@@ -78,7 +78,7 @@ proc new*(
7878

7979
portalProtocol = PortalProtocol.new(
8080
baseProtocol,
81-
getProtocolId(portalNetwork, PortalSubnetwork.finalizedHistory),
81+
getProtocolId(portalNetwork, PortalSubnetwork.history),
8282
toContentIdHandler,
8383
createGetHandler(contentDB),
8484
createStoreHandler(contentDB, portalConfig.radiusConfig),
@@ -90,7 +90,7 @@ proc new*(
9090
pingExtensionCapabilities = pingExtensionCapabilities,
9191
)
9292

93-
FinalizedHistoryNetwork(
93+
HistoryNetwork(
9494
portalProtocol: portalProtocol,
9595
contentDB: contentDB,
9696
contentQueue: contentQueue,
@@ -101,10 +101,7 @@ proc new*(
101101
)
102102

103103
proc getContent*(
104-
n: FinalizedHistoryNetwork,
105-
contentKey: ContentKey,
106-
V: type ContentValueType,
107-
header: Header,
104+
n: HistoryNetwork, contentKey: ContentKey, V: type ContentValueType, header: Header
108105
): Future[Opt[V]] {.async: (raises: [CancelledError]).} =
109106
## Get the decoded content for the given content key.
110107
##
@@ -161,11 +158,11 @@ proc getContent*(
161158
Opt.none(V)
162159

163160
proc validateContent(
164-
n: FinalizedHistoryNetwork, content: seq[byte], contentKeyBytes: ContentKeyByteList
161+
n: HistoryNetwork, content: seq[byte], contentKeyBytes: ContentKeyByteList
165162
): Future[Result[void, string]] {.async: (raises: [CancelledError]).} =
166163
# TODO: specs might turn out to just disable offers. Although I think for for getting initial data in the network
167164
# this might be an issue. Unless history expiry gets deployed together with Portal.
168-
let contentKey = finalized_history_content.decode(contentKeyBytes).valueOr:
165+
let contentKey = history_content.decode(contentKeyBytes).valueOr:
169166
return err("Error decoding content key")
170167

171168
let header = ?(await n.getHeader(contentKey.blockNumber()))
@@ -189,7 +186,7 @@ proc validateContent(
189186
ok()
190187

191188
proc validateContent(
192-
n: FinalizedHistoryNetwork,
189+
n: HistoryNetwork,
193190
srcNodeId: Opt[NodeId],
194191
contentKeys: ContentKeysList,
195192
contentItems: seq[seq[byte]],
@@ -218,7 +215,7 @@ proc validateContent(
218215

219216
return true
220217

221-
proc contentQueueWorker(n: FinalizedHistoryNetwork) {.async: (raises: []).} =
218+
proc contentQueueWorker(n: HistoryNetwork) {.async: (raises: []).} =
222219
try:
223220
while true:
224221
let (srcNodeId, contentKeys, contentItems) = await n.contentQueue.popFirst()
@@ -236,7 +233,7 @@ proc contentQueueWorker(n: FinalizedHistoryNetwork) {.async: (raises: []).} =
236233
except CancelledError:
237234
trace "contentQueueWorker canceled"
238235

239-
proc statusLogLoop(n: FinalizedHistoryNetwork) {.async: (raises: []).} =
236+
proc statusLogLoop(n: HistoryNetwork) {.async: (raises: []).} =
240237
try:
241238
while true:
242239
await sleepAsync(60.seconds)
@@ -246,9 +243,8 @@ proc statusLogLoop(n: FinalizedHistoryNetwork) {.async: (raises: []).} =
246243
except CancelledError:
247244
trace "statusLogLoop canceled"
248245

249-
proc start*(n: FinalizedHistoryNetwork) =
250-
info "Starting Portal finalized chain history network",
251-
protocolId = n.portalProtocol.protocolId
246+
proc start*(n: HistoryNetwork) =
247+
info "Starting Portal chain history network", protocolId = n.portalProtocol.protocolId
252248

253249
n.portalProtocol.start()
254250

@@ -257,8 +253,8 @@ proc start*(n: FinalizedHistoryNetwork) =
257253

258254
n.statusLogLoop = statusLogLoop(n)
259255

260-
proc stop*(n: FinalizedHistoryNetwork) {.async: (raises: []).} =
261-
info "Stopping Portal finalized chain history network"
256+
proc stop*(n: HistoryNetwork) {.async: (raises: []).} =
257+
info "Stopping Portal chain history network"
262258

263259
var futures: seq[Future[void]]
264260
futures.add(n.portalProtocol.stop())

portal/network/finalized_history/finalized_history_validation.nim renamed to portal/network/history/history_validation.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import
1111
eth/trie/ordered_trie,
1212
eth/common/[headers_rlp, blocks_rlp, receipts, hashes],
13-
./finalized_history_content
13+
./history_content
1414

1515
func validateBlockBody*(body: BlockBody, header: Header): Result[void, string] =
1616
## Validate the block body against the txRoot, ommersHash and withdrawalsRoot

portal/network/portal_node.nim

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import
1717
../database/content_db,
1818
./network_metadata,
1919
./wire/[portal_stream, portal_protocol_config],
20-
./finalized_history/finalized_history_network,
20+
./history/history_network,
2121
./beacon/[beacon_init_loader, beacon_light_client],
2222
./legacy_history/[history_network, history_content],
2323
./state/[state_network, state_content]
@@ -43,7 +43,7 @@ type
4343
discovery: protocol.Protocol
4444
contentDB: ContentDB
4545
streamManager: StreamManager
46-
finalizedHistoryNetwork*: Opt[FinalizedHistoryNetwork]
46+
historyNetwork*: Opt[HistoryNetwork]
4747
beaconNetwork*: Opt[BeaconNetwork]
4848
legacyHistoryNetwork*: Opt[LegacyHistoryNetwork]
4949
stateNetwork*: Opt[StateNetwork]
@@ -109,10 +109,10 @@ proc new*(
109109
# Get it from binary file containing SSZ encoded accumulator
110110
loadAccumulator()
111111

112-
finalizedHistoryNetwork =
113-
if PortalSubnetwork.finalizedHistory in subnetworks:
112+
historyNetwork =
113+
if PortalSubnetwork.history in subnetworks:
114114
Opt.some(
115-
FinalizedHistoryNetwork.new(
115+
HistoryNetwork.new(
116116
network,
117117
discovery,
118118
contentDB,
@@ -125,7 +125,7 @@ proc new*(
125125
)
126126
)
127127
else:
128-
Opt.none(FinalizedHistoryNetwork)
128+
Opt.none(HistoryNetwork)
129129

130130
beaconNetwork =
131131
if PortalSubnetwork.beacon in subnetworks:
@@ -216,7 +216,7 @@ proc new*(
216216
discovery: discovery,
217217
contentDB: contentDB,
218218
streamManager: streamManager,
219-
finalizedHistoryNetwork: finalizedHistoryNetwork,
219+
historyNetwork: historyNetwork,
220220
beaconNetwork: beaconNetwork,
221221
legacyHistoryNetwork: legacyHistoryNetwork,
222222
stateNetwork: stateNetwork,
@@ -250,8 +250,8 @@ proc start*(n: PortalNode) =
250250

251251
n.discovery.start()
252252

253-
if n.finalizedHistoryNetwork.isSome():
254-
n.finalizedHistoryNetwork.value.start()
253+
if n.historyNetwork.isSome():
254+
n.historyNetwork.value.start()
255255
if n.beaconNetwork.isSome():
256256
n.beaconNetwork.value.start()
257257
if n.legacyHistoryNetwork.isSome():
@@ -269,8 +269,8 @@ proc stop*(n: PortalNode) {.async: (raises: []).} =
269269

270270
var futures: seq[Future[void]]
271271

272-
if n.finalizedHistoryNetwork.isSome():
273-
futures.add(n.finalizedHistoryNetwork.value.stop())
272+
if n.historyNetwork.isSome():
273+
futures.add(n.historyNetwork.value.stop())
274274
if n.beaconNetwork.isSome():
275275
futures.add(n.beaconNetwork.value.stop())
276276
if n.legacyHistoryNetwork.isSome():

portal/network/wire/portal_protocol.nim

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,12 @@ func getProtocolId*(
308308
case network
309309
of PortalNetwork.none, PortalNetwork.mainnet:
310310
case subnetwork
311-
of PortalSubnetwork.finalizedHistory:
311+
of PortalSubnetwork.history:
312312
[portalPrefix, 0x00]
313313
of PortalSubnetwork.state:
314314
[portalPrefix, 0x0A]
315315
of PortalSubnetwork.legacyHistory:
316316
[portalPrefix, 0x0B]
317-
of PortalSubnetwork.history:
318-
raiseAssert "Not yet supported"
319317
of PortalSubnetwork.beacon:
320318
[portalPrefix, 0x0C]
321319
of PortalSubnetwork.transactionIndex:
@@ -326,14 +324,12 @@ func getProtocolId*(
326324
[portalPrefix, 0x0F]
327325
of PortalNetwork.angelfood:
328326
case subnetwork
329-
of PortalSubnetwork.finalizedHistory:
327+
of PortalSubnetwork.history:
330328
[portalPrefix, 0x40]
331329
of PortalSubnetwork.state:
332330
[portalPrefix, 0x4A]
333331
of PortalSubnetwork.legacyHistory:
334332
[portalPrefix, 0x4B]
335-
of PortalSubnetwork.history:
336-
raiseAssert "Not yet supported"
337333
of PortalSubnetwork.beacon:
338334
[portalPrefix, 0x4C]
339335
of PortalSubnetwork.transactionIndex:

portal/network/wire/portal_protocol_config.nim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type
1717

1818
# The Portal sub-protocols
1919
PortalSubnetwork* = enum
20-
finalizedHistory
2120
state
2221
history
2322
legacyHistory

portal/rpc/rpc_portal_finalized_history_api.nim renamed to portal/rpc/rpc_portal_history_api.nim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import
1313
stew/byteutils,
1414
../common/common_types,
1515
../network/wire/portal_protocol,
16-
../network/finalized_history/finalized_history_content,
17-
../network/finalized_history/finalized_history_validation,
16+
../network/history/history_content,
17+
../network/history/history_validation,
1818
./rpc_types
1919

2020
export tables
2121

22-
# Portal Finalized History Network JSON-RPC API
22+
# Portal History Network JSON-RPC API
2323
# Note:
2424
# - This API is not part of the Portal Network specification yet.
2525
# - Lower level API calls are not implemented as they are typically only used for (Hive)
@@ -40,7 +40,7 @@ TraceResponse.useDefaultSerializationIn JrpcConv
4040
proc installPortalFinalizedHistoryApiHandlers*(
4141
rpcServer: RpcServer, p: PortalProtocol
4242
) =
43-
rpcServer.rpc("portal_finalizedHistoryGetContent") do(
43+
rpcServer.rpc("portal_historyGetContent") do(
4444
contentKeyBytes: string, headerBytes: string
4545
) -> ContentInfo:
4646
let
@@ -73,7 +73,7 @@ proc installPortalFinalizedHistoryApiHandlers*(
7373
utpTransfer: contentLookupResult.utpTransfer,
7474
)
7575

76-
rpcServer.rpc("portal_finalizedHistoryTraceGetContent") do(
76+
rpcServer.rpc("portal_historyTraceGetContent") do(
7777
contentKeyBytes: string, headerBytes: string
7878
) -> TraceContentLookupResult:
7979
let
@@ -114,7 +114,7 @@ proc installPortalFinalizedHistoryApiHandlers*(
114114

115115
res
116116

117-
rpcServer.rpc("portal_finalizedHistoryPutContent") do(
117+
rpcServer.rpc("portal_historyPutContent") do(
118118
contentKeyBytes: string, contentValueBytes: string
119119
) -> PutContentResult:
120120
let

0 commit comments

Comments
 (0)