Update Request: remove PoR, add merkle root (#590)
* [build] update codex-contracts-eth * [contracts] update request parameters - Remove PoR parameters and totalChunks - Add merkleRoot
This commit is contained in:
parent
a805af02c1
commit
b62ccf5a8a
|
@ -28,14 +28,7 @@ type
|
|||
maxSlotLoss* {.serialize.}: uint64
|
||||
StorageContent* = object
|
||||
cid* {.serialize.}: string
|
||||
erasure*: StorageErasure
|
||||
por*: StoragePoR
|
||||
StorageErasure* = object
|
||||
totalChunks*: uint64
|
||||
StoragePoR* = object
|
||||
u*: seq[byte]
|
||||
publicKey*: seq[byte]
|
||||
name*: seq[byte]
|
||||
merkleRoot*: array[32, byte]
|
||||
Slot* = object
|
||||
request* {.serialize.}: StorageRequest
|
||||
slotIndex* {.serialize.}: UInt256
|
||||
|
@ -111,28 +104,9 @@ func fromTuple(_: type StorageAsk, tupl: tuple): StorageAsk =
|
|||
func fromTuple(_: type StorageContent, tupl: tuple): StorageContent =
|
||||
StorageContent(
|
||||
cid: tupl[0],
|
||||
erasure: tupl[1],
|
||||
por: tupl[2]
|
||||
merkleRoot: tupl[1]
|
||||
)
|
||||
|
||||
func fromTuple(_: type StorageErasure, tupl: tuple): StorageErasure =
|
||||
StorageErasure(
|
||||
totalChunks: tupl[0]
|
||||
)
|
||||
|
||||
func fromTuple(_: type StoragePoR, tupl: tuple): StoragePoR =
|
||||
StoragePoR(
|
||||
u: tupl[0],
|
||||
publicKey: tupl[1],
|
||||
name: tupl[2]
|
||||
)
|
||||
|
||||
func solidityType*(_: type StoragePoR): string =
|
||||
solidityType(StoragePoR.fieldTypes)
|
||||
|
||||
func solidityType*(_: type StorageErasure): string =
|
||||
solidityType(StorageErasure.fieldTypes)
|
||||
|
||||
func solidityType*(_: type StorageContent): string =
|
||||
solidityType(StorageContent.fieldTypes)
|
||||
|
||||
|
@ -142,12 +116,6 @@ func solidityType*(_: type StorageAsk): string =
|
|||
func solidityType*(_: type StorageRequest): string =
|
||||
solidityType(StorageRequest.fieldTypes)
|
||||
|
||||
func encode*(encoder: var AbiEncoder, por: StoragePoR) =
|
||||
encoder.write(por.fieldValues)
|
||||
|
||||
func encode*(encoder: var AbiEncoder, erasure: StorageErasure) =
|
||||
encoder.write(erasure.fieldValues)
|
||||
|
||||
func encode*(encoder: var AbiEncoder, content: StorageContent) =
|
||||
encoder.write(content.fieldValues)
|
||||
|
||||
|
@ -163,14 +131,6 @@ func encode*(encoder: var AbiEncoder, request: StorageRequest) =
|
|||
func encode*(encoder: var AbiEncoder, request: Slot) =
|
||||
encoder.write(request.fieldValues)
|
||||
|
||||
func decode*(decoder: var AbiDecoder, T: type StoragePoR): ?!T =
|
||||
let tupl = ?decoder.read(StoragePoR.fieldTypes)
|
||||
success StoragePoR.fromTuple(tupl)
|
||||
|
||||
func decode*(decoder: var AbiDecoder, T: type StorageErasure): ?!T =
|
||||
let tupl = ?decoder.read(StorageErasure.fieldTypes)
|
||||
success StorageErasure.fromTuple(tupl)
|
||||
|
||||
func decode*(decoder: var AbiDecoder, T: type StorageContent): ?!T =
|
||||
let tupl = ?decoder.read(StorageContent.fieldTypes)
|
||||
success StorageContent.fromTuple(tupl)
|
||||
|
|
|
@ -377,14 +377,7 @@ proc requestStorage*(
|
|||
),
|
||||
content: StorageContent(
|
||||
cid: $encodedBlk.cid,
|
||||
erasure: StorageErasure(
|
||||
totalChunks: encoded.blocksCount.uint64,
|
||||
),
|
||||
por: StoragePoR(
|
||||
u: @[], # TODO: PoR setup
|
||||
publicKey: @[], # TODO: PoR setup
|
||||
name: @[] # TODO: PoR setup
|
||||
)
|
||||
merkleRoot: array[32, byte].default # TODO: add merkle root for storage proofs
|
||||
),
|
||||
expiry: expiry
|
||||
)
|
||||
|
|
|
@ -12,7 +12,6 @@ import pkg/codex/utils/json as utilsjson
|
|||
import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
import pkg/libp2p
|
||||
import ../examples
|
||||
import ../helpers
|
||||
|
||||
checksuite "json serialization":
|
||||
|
@ -37,14 +36,7 @@ checksuite "json serialization":
|
|||
),
|
||||
content: StorageContent(
|
||||
cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob",
|
||||
erasure: StorageErasure(
|
||||
totalChunks: 12,
|
||||
),
|
||||
por: StoragePoR(
|
||||
u: @(array[480, byte].fromHex("0xc066dd7e405de5a795ce1e765209cfaa6de6c74829c607d1a2fe53107107a2981baccff95e2fc2e38d08303e8ab59a1169cfc9bfbfa2294c6df065456056a0d0106f66d6fe48300222758fd6fd286a1ac9060d1a295e19f931a8d3ad2c47eb131bea267fe942d460fda96fd4bf663148cd90fbb1b670dd97aae70394248b75cfbb98f71e8c69f50381e0558884d5d9aa75147923b55386c66f75f63024b698eeb0ff994bfdb610eea1b7c75e87bdb54843071bc64fbaf93e5dc214e875bd95bd30f167b69df1de819a34cc71a3a0465f5c1d1b7e5b98de6017ff3e3c059536f974471fe62e0f224eba8f96352a8ee51befbf4c31c88ad0fc8ff4e9d9da174a455a1c30fd61ac977145d3677a08167d508fae207f9458a9b19d4ceec2be30506e2d70cc0362c2bcdb0f73d63fa5e79f9b2901bc870ac8b2a264d50e1862ea177eb587bcd16ceb7d66f96f198cadec3f644af4d3cbe478bc1665818401f89107053d1750047fb7cfc47938bec2cd006db9c176ce337e41160077e353f87ab319e5b9df92282916ef99334c067f6ca20c3d7cbc12b95180b7bba762993a4dbdf4242032da8865988183738d279918906c3357701d74e5d8f5142315ae8f6d0f93537abc3545118e953f983317657a9d8b86e4305ea49e10f80ea07dc7ea7321b32c")),
|
||||
publicKey: @(array[96, byte].fromHex("0xb231b19de641f678d250623b2b76099ab4bbd67aac19dcf42ded946831e3366d2a20af0fd9e841197e7e64d7639da4518b76c353db480087e21d55b470f24a180d6d6c8265bf3895e2e4e4e54b8ca9334d62b22feeeed8e77e54bfbc8fae6b62")),
|
||||
name: @(array[512, byte].fromHex("0x75b2ac401efd21e60e84a69288da6fff28c7badaae885e417f35055a4e10cb514855f68a0ae18bf42861426c9fc34af13df2f2d04dc68933af78bf3fc396953f301b95f6d6af54ec9fc871c292096e45b91e836063f128c2d1469adbee49bc9b7d62985a858801e4df2cb77eb41ee7b50a8a4e5afb5b585f9034a2808f81bd95b9a3fbdd2579331023f1816a1ecbe7a31e386721a72e3d0ff6087326fba8442dfd22d1182c85906d796e697231c2d7d4a888ae256c79a9019974a4c729d981f3e554f48895e27fe8f45da46bc48c35cc74ae5a31dfea8baa1334fa7f106cdc4ec54452f39c823fa0af97769217cc16c78eb7d0c494c26d2f286f09a507bd04cb15963270bffefb28258176d9e10b7aaad76cdd86e0fe49437eb83c1c0650cb5920e32dc54f3a21a70308b7312b47ce57ef72c2c19eba5027612128b747e80b88c912d7fc10177e67beda0ed5bb8fdfc268bfa5a5c700da953c56bcc79b9186da99ee19a6fa954f44bdcbc7c7f4d208fb750bad587d5513fbaccd511b9b6e0cd798120de87b9c0c410b3b85c75a8a0f469d9973a1ec4c86982cf4fe1a2be21a9206aaabb1ad2fafa628d5156d2ec99ee30fc0ddb9dca6a4cd3a7987227315ceeaa832909853cabaf33c976b59cf5ed9643781d92ab769c0d0aa3bcef40b41b4b3e6fc5a00c9dfbf794047d9cfb97d9d669d00520b6492760a08dba65b0fd7e6d0"))
|
||||
)
|
||||
merkleRoot: array[32, byte].fromHex("0xc066dd7e405de5a795ce1e765209cfaa6de6c74829c607d1a2fe53107107a298")
|
||||
),
|
||||
expiry: 1691545330.u256,
|
||||
nonce: Nonce array[32, byte].fromHex("0xd4ebeadc44641c0a271153f6366f24ebb5e3aa64f9ee5e62794babc2e75950a1")
|
||||
|
@ -62,14 +54,7 @@ checksuite "json serialization":
|
|||
},
|
||||
"content": {
|
||||
"cid": "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob",
|
||||
"erasure": {
|
||||
"totalChunks": 12
|
||||
},
|
||||
"por": {
|
||||
"u": "0xc066dd7e405de5a795ce1e765209cfaa6de6c74829c607d1a2fe53107107a2981baccff95e2fc2e38d08303e8ab59a1169cfc9bfbfa2294c6df065456056a0d0106f66d6fe48300222758fd6fd286a1ac9060d1a295e19f931a8d3ad2c47eb131bea267fe942d460fda96fd4bf663148cd90fbb1b670dd97aae70394248b75cfbb98f71e8c69f50381e0558884d5d9aa75147923b55386c66f75f63024b698eeb0ff994bfdb610eea1b7c75e87bdb54843071bc64fbaf93e5dc214e875bd95bd30f167b69df1de819a34cc71a3a0465f5c1d1b7e5b98de6017ff3e3c059536f974471fe62e0f224eba8f96352a8ee51befbf4c31c88ad0fc8ff4e9d9da174a455a1c30fd61ac977145d3677a08167d508fae207f9458a9b19d4ceec2be30506e2d70cc0362c2bcdb0f73d63fa5e79f9b2901bc870ac8b2a264d50e1862ea177eb587bcd16ceb7d66f96f198cadec3f644af4d3cbe478bc1665818401f89107053d1750047fb7cfc47938bec2cd006db9c176ce337e41160077e353f87ab319e5b9df92282916ef99334c067f6ca20c3d7cbc12b95180b7bba762993a4dbdf4242032da8865988183738d279918906c3357701d74e5d8f5142315ae8f6d0f93537abc3545118e953f983317657a9d8b86e4305ea49e10f80ea07dc7ea7321b32c",
|
||||
"publicKey": "0xb231b19de641f678d250623b2b76099ab4bbd67aac19dcf42ded946831e3366d2a20af0fd9e841197e7e64d7639da4518b76c353db480087e21d55b470f24a180d6d6c8265bf3895e2e4e4e54b8ca9334d62b22feeeed8e77e54bfbc8fae6b62",
|
||||
"name": "0x75b2ac401efd21e60e84a69288da6fff28c7badaae885e417f35055a4e10cb514855f68a0ae18bf42861426c9fc34af13df2f2d04dc68933af78bf3fc396953f301b95f6d6af54ec9fc871c292096e45b91e836063f128c2d1469adbee49bc9b7d62985a858801e4df2cb77eb41ee7b50a8a4e5afb5b585f9034a2808f81bd95b9a3fbdd2579331023f1816a1ecbe7a31e386721a72e3d0ff6087326fba8442dfd22d1182c85906d796e697231c2d7d4a888ae256c79a9019974a4c729d981f3e554f48895e27fe8f45da46bc48c35cc74ae5a31dfea8baa1334fa7f106cdc4ec54452f39c823fa0af97769217cc16c78eb7d0c494c26d2f286f09a507bd04cb15963270bffefb28258176d9e10b7aaad76cdd86e0fe49437eb83c1c0650cb5920e32dc54f3a21a70308b7312b47ce57ef72c2c19eba5027612128b747e80b88c912d7fc10177e67beda0ed5bb8fdfc268bfa5a5c700da953c56bcc79b9186da99ee19a6fa954f44bdcbc7c7f4d208fb750bad587d5513fbaccd511b9b6e0cd798120de87b9c0c410b3b85c75a8a0f469d9973a1ec4c86982cf4fe1a2be21a9206aaabb1ad2fafa628d5156d2ec99ee30fc0ddb9dca6a4cd3a7987227315ceeaa832909853cabaf33c976b59cf5ed9643781d92ab769c0d0aa3bcef40b41b4b3e6fc5a00c9dfbf794047d9cfb97d9d669d00520b6492760a08dba65b0fd7e6d0"
|
||||
}
|
||||
"merkleRoot": "0xc066dd7e405de5a795ce1e765209cfaa6de6c74829c607d1a2fe53107107a298"
|
||||
},
|
||||
"expiry": "1691545330",
|
||||
"nonce": "0xd4ebeadc44641c0a271153f6366f24ebb5e3aa64f9ee5e62794babc2e75950a1"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import std/random
|
||||
import std/strutils
|
||||
import std/sequtils
|
||||
import std/times
|
||||
import std/typetraits
|
||||
|
@ -45,14 +44,7 @@ proc example*(_: type StorageRequest): StorageRequest =
|
|||
),
|
||||
content: StorageContent(
|
||||
cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob",
|
||||
erasure: StorageErasure(
|
||||
totalChunks: 12,
|
||||
),
|
||||
por: StoragePoR(
|
||||
u: @(array[480, byte].example),
|
||||
publicKey: @(array[96, byte].example),
|
||||
name: @(array[512, byte].example)
|
||||
)
|
||||
merkleRoot: array[32, byte].example
|
||||
),
|
||||
expiry: (getTime() + initDuration(hours=1)).toUnix.u256,
|
||||
nonce: Nonce.example
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 14e453ac3150e6c9ca277e605d5df9389ac7eea7
|
||||
Subproject commit b625f0d519abc9b84cf759868779daa56ceb28c8
|
Loading…
Reference in New Issue