diff --git a/eth.nimble b/eth.nimble index ea596ce2..6dd7248e 100644 --- a/eth.nimble +++ b/eth.nimble @@ -21,7 +21,8 @@ requires "nim >= 2.0.10", "unittest2", "results", "minilru", - "snappy" + "snappy", + "ssz_serialization" let nimc = getEnv("NIMC", "nim") # Which nim compiler to use let lang = getEnv("NIMLANG", "c") # Which backend (c/cpp/js) diff --git a/eth/common/receipts.nim b/eth/common/receipts.nim index 659f9c12..d10df1e8 100644 --- a/eth/common/receipts.nim +++ b/eth/common/receipts.nim @@ -9,18 +9,23 @@ import ./[addresses, base, hashes, transactions], - ../bloom + ../bloom, + ssz_serialization export addresses, base, hash, transactions +const + MAX_TOPICS_PER_LOG* = 4 + MAX_LOG_DATA_SIZE* = 1 shl 24 + type Topic* = Bytes32 # topic can be Hash32 or zero padded bytes array Log* = object - address*: Address - topics*: seq[Topic] - data*: seq[byte] + address*: Address + topics*: List[Topic, MAX_TOPICS_PER_LOG] + data*: ByteList[MAX_LOG_DATA_SIZE] # easily convertible between # ReceiptType and TxType diff --git a/eth/common/ssz_utils.nim b/eth/common/ssz_utils.nim new file mode 100644 index 00000000..66a792c1 --- /dev/null +++ b/eth/common/ssz_utils.nim @@ -0,0 +1,12 @@ +import ssz_serialization + +proc `==`*[T; N: static[int]](a, b: List[T, N]): bool = + if a.len != b.len: # compare length first + return false + for i in 0..