@@ -10,6 +10,7 @@ import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
10
10
import io .iohk .ethereum .ObjectGenerators
11
11
import io .iohk .ethereum .crypto .ECDSASignature
12
12
import io .iohk .ethereum .network .p2p .messages .BaseETH6XMessages .SignedTransactions
13
+ import io .iohk .ethereum .rlp .RLPList
13
14
import io .iohk .ethereum .security .SecureRandomBuilder
14
15
import io .iohk .ethereum .utils .Config
15
16
import io .iohk .ethereum .utils .Hex
@@ -27,7 +28,7 @@ class TransactionSpec
27
28
forAll(signedTxGen(secureRandom, None )) { (originalSignedTransaction : SignedTransaction ) =>
28
29
// encode it
29
30
import SignedTransactions .SignedTransactionEnc
30
- val encodedSignedTransaction = originalSignedTransaction.toBytes
31
+ val encodedSignedTransaction : Array [ Byte ] = originalSignedTransaction.toBytes
31
32
32
33
// decode it
33
34
import SignedTransactions .SignedTransactionDec
@@ -37,6 +38,40 @@ class TransactionSpec
37
38
}
38
39
}
39
40
41
+ " rlp encoding then decoding transactions sequence" should " give back the initial transactions sequence" in {
42
+
43
+ forAll(signedTxSeqGen(2 , secureRandom, None )) { (originalSignedTransactionSeq : Seq [SignedTransaction ]) =>
44
+ // encode it
45
+ import SignedTransactions .SignedTransactionsEnc
46
+
47
+ // SignedTransactionsEnc is the Sequence version of SignedTransactionEnc
48
+ // the SignedTransactionsEnc.toBytes calls
49
+ // -> SignedTransactionsEnc.toRLPEncodable which maps over
50
+ // -> SignedTransactionEnc.toRLPEncodable (single signed transaction encoder)
51
+ // without going through the SignedTransactionEnc.toByte, which is the actual part where the 01 prefix is inserted
52
+ val encodedSignedTransactionSeq : Array [Byte ] = SignedTransactions (originalSignedTransactionSeq).toBytes
53
+
54
+ // decode it
55
+ import SignedTransactions .SignedTransactionsDec
56
+ // likewise, the SignedTransactionsDec.toSignedTransactions maps over
57
+ // -> SignedTransactionRlpEncodableDec.toSignedTransaction (single signed transaction)
58
+ // while ignoring the SignedTransactionDec(Array[Byte]), which is responsible to parse the prefix if available
59
+ val SignedTransactions (decodedSignedTransactionSeq) = encodedSignedTransactionSeq.toSignedTransactions
60
+
61
+ // The test is working because both encoding and decoding are skipping the prefix part,
62
+ // and the rlp encoded transaction is different enough to recognize a LegacyTransaction from a TX1
63
+
64
+ // I see two problems:
65
+ // - the encoding is not compatible with other clients
66
+ // - this is not working for receipt, where legacy and tx1 receipt payload are the same. As such we can't
67
+ // distinguish which one it is without the prefix
68
+
69
+ // The root cause seems to be that the prefix stuff is done on a byte[] level,
70
+ // whereas RLPList are working on RLPEncodable
71
+ decodedSignedTransactionSeq shouldEqual originalSignedTransactionSeq
72
+ }
73
+ }
74
+
40
75
" Transaction type 01" should " be correctly serialized to rlp" in {
41
76
42
77
// binary values have be taken directly from core-geth own tests
0 commit comments