1
1
import {
2
- Fr ,
3
2
KernelCircuitPublicInputs ,
4
3
MAX_NEW_CONTRACTS_PER_TX ,
5
4
MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX ,
6
- PartialAddress ,
7
- Point ,
8
5
Proof ,
9
6
PublicCallRequest ,
10
- PublicKey ,
11
7
} from '@aztec/circuits.js' ;
12
8
import { serializeToBuffer } from '@aztec/circuits.js/utils' ;
13
9
import { arrayNonEmptyLength } from '@aztec/foundation/collection' ;
14
- import { BufferReader , Tuple , numToUInt32BE } from '@aztec/foundation/serialize' ;
10
+ import { BufferReader , Tuple } from '@aztec/foundation/serialize' ;
15
11
16
- import { EncodedContractFunction } from '../contract_data.js' ;
12
+ import { ExtendedContractData } from '../contract_data.js' ;
17
13
import { TxL2Logs } from '../logs/tx_l2_logs.js' ;
18
14
import { TxHash } from './tx_hash.js' ;
19
15
@@ -38,19 +34,16 @@ export class Tx {
38
34
* Unencrypted logs generated by the tx.
39
35
*/
40
36
public readonly unencryptedLogs : TxL2Logs ,
41
- /**
42
- * New public functions made available by this tx.
43
- */
44
- public readonly newContractPublicFunctions : EncodedContractFunction [ ] ,
45
37
/**
46
38
* Enqueued public functions from the private circuit to be run by the sequencer.
47
39
* Preimages of the public call stack entries from the private kernel circuit output.
48
40
*/
49
41
public readonly enqueuedPublicFunctionCalls : PublicCallRequest [ ] ,
50
- /** Partial addresses of new contracts. */
51
- public readonly partialAddresses : Tuple < PartialAddress , typeof MAX_NEW_CONTRACTS_PER_TX > ,
52
- /** Public keys of new contracts. */
53
- public readonly publicKeys : Tuple < PublicKey , typeof MAX_NEW_CONTRACTS_PER_TX > ,
42
+ /**
43
+ * Contracts deployed in this tx.
44
+ * Note: Portal address is always set to zero in the tx's new contracts.
45
+ */
46
+ public readonly newContracts : Tuple < ExtendedContractData , typeof MAX_NEW_CONTRACTS_PER_TX > ,
54
47
) {
55
48
if ( this . unencryptedLogs . functionLogs . length < this . encryptedLogs . functionLogs . length ) {
56
49
// This check is present because each private function invocation creates encrypted FunctionL2Logs object and
@@ -84,10 +77,8 @@ export class Tx {
84
77
reader . readObject ( Proof ) ,
85
78
reader . readObject ( TxL2Logs ) ,
86
79
reader . readObject ( TxL2Logs ) ,
87
- reader . readArray ( reader . readNumber ( ) , EncodedContractFunction ) ,
88
80
reader . readArray ( MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX , PublicCallRequest ) ,
89
- reader . readArray ( MAX_NEW_CONTRACTS_PER_TX , Fr ) ,
90
- reader . readArray ( MAX_NEW_CONTRACTS_PER_TX , Point ) ,
81
+ reader . readArray ( MAX_NEW_CONTRACTS_PER_TX , ExtendedContractData ) ,
91
82
) ;
92
83
}
93
84
@@ -101,12 +92,8 @@ export class Tx {
101
92
this . proof ,
102
93
this . encryptedLogs ,
103
94
this . unencryptedLogs ,
104
- // number of new contract public functions is not constant so we need to include it in the serialization
105
- numToUInt32BE ( this . newContractPublicFunctions . length ) ,
106
- this . newContractPublicFunctions ,
107
95
this . enqueuedPublicFunctionCalls ,
108
- this . partialAddresses ,
109
- this . publicKeys ,
96
+ this . newContracts ,
110
97
] ) ;
111
98
}
112
99
@@ -120,10 +107,8 @@ export class Tx {
120
107
encryptedLogs : this . encryptedLogs . toBuffer ( ) . toString ( 'hex' ) ,
121
108
unencryptedLogs : this . unencryptedLogs . toBuffer ( ) . toString ( 'hex' ) ,
122
109
proof : this . proof . toBuffer ( ) . toString ( 'hex' ) ,
123
- newContractPublicFunctions : this . newContractPublicFunctions . map ( f => f . toBuffer ( ) . toString ( 'hex' ) ) ?? [ ] ,
124
110
enqueuedPublicFunctions : this . enqueuedPublicFunctionCalls . map ( f => f . toBuffer ( ) . toString ( 'hex' ) ) ?? [ ] ,
125
- partialAddresses : this . partialAddresses . map ( f => f . toBuffer ( ) . toString ( 'hex' ) ) ,
126
- publicKeys : this . publicKeys . map ( f => f . toBuffer ( ) . toString ( 'hex' ) ) ,
111
+ newContracts : this . newContracts . map ( c => c . toBuffer ( ) . toString ( 'hex' ) ) ,
127
112
} ;
128
113
}
129
114
@@ -137,23 +122,17 @@ export class Tx {
137
122
const encryptedLogs = TxL2Logs . fromBuffer ( Buffer . from ( obj . encryptedLogs , 'hex' ) ) ;
138
123
const unencryptedLogs = TxL2Logs . fromBuffer ( Buffer . from ( obj . unencryptedLogs , 'hex' ) ) ;
139
124
const proof = Buffer . from ( obj . proof , 'hex' ) ;
140
- const newContractPublicFunctions = obj . newContractPublicFunctions
141
- ? obj . newContractPublicFunctions . map ( ( x : string ) => EncodedContractFunction . fromBuffer ( Buffer . from ( x , 'hex' ) ) )
142
- : [ ] ;
143
125
const enqueuedPublicFunctions = obj . enqueuedPublicFunctions
144
126
? obj . enqueuedPublicFunctions . map ( ( x : string ) => PublicCallRequest . fromBuffer ( Buffer . from ( x , 'hex' ) ) )
145
127
: [ ] ;
146
- const partialAddresses = obj . partialAddresses . map ( ( x : string ) => Fr . fromBuffer ( Buffer . from ( x , 'hex' ) ) ) ;
147
- const publicKeys = obj . publicKeys . map ( ( x : string ) => Point . fromBuffer ( Buffer . from ( x , 'hex' ) ) ) ;
128
+ const newContracts = obj . newContracts . map ( ( x : string ) => ExtendedContractData . fromBuffer ( Buffer . from ( x , 'hex' ) ) ) ;
148
129
return new Tx (
149
130
publicInputs ,
150
131
Proof . fromBuffer ( proof ) ,
151
132
encryptedLogs ,
152
133
unencryptedLogs ,
153
- newContractPublicFunctions ,
154
134
enqueuedPublicFunctions ,
155
- partialAddresses ,
156
- publicKeys ,
135
+ newContracts ,
157
136
) ;
158
137
}
159
138
@@ -187,29 +166,13 @@ export class Tx {
187
166
const proof = Proof . fromBuffer ( tx . proof . toBuffer ( ) ) ;
188
167
const encryptedLogs = TxL2Logs . fromBuffer ( tx . encryptedLogs . toBuffer ( ) ) ;
189
168
const unencryptedLogs = TxL2Logs . fromBuffer ( tx . unencryptedLogs . toBuffer ( ) ) ;
190
- const publicFunctions = tx . newContractPublicFunctions . map ( x => {
191
- return EncodedContractFunction . fromBuffer ( x . toBuffer ( ) ) ;
192
- } ) ;
193
169
const enqueuedPublicFunctions = tx . enqueuedPublicFunctionCalls . map ( x => {
194
170
return PublicCallRequest . fromBuffer ( x . toBuffer ( ) ) ;
195
171
} ) ;
196
- const partialAddresses = tx . partialAddresses . map ( x => Fr . fromBuffer ( x . toBuffer ( ) ) ) as Tuple <
197
- PartialAddress ,
198
- typeof MAX_NEW_CONTRACTS_PER_TX
199
- > ;
200
- const publicKeys = tx . publicKeys . map ( x => Point . fromBuffer ( x . toBuffer ( ) ) ) as Tuple <
201
- PublicKey ,
172
+ const newContracts = tx . newContracts . map ( c => ExtendedContractData . fromBuffer ( c . toBuffer ( ) ) ) as Tuple <
173
+ ExtendedContractData ,
202
174
typeof MAX_NEW_CONTRACTS_PER_TX
203
175
> ;
204
- return new Tx (
205
- publicInputs ,
206
- proof ,
207
- encryptedLogs ,
208
- unencryptedLogs ,
209
- publicFunctions ,
210
- enqueuedPublicFunctions ,
211
- partialAddresses ,
212
- publicKeys ,
213
- ) ;
176
+ return new Tx ( publicInputs , proof , encryptedLogs , unencryptedLogs , enqueuedPublicFunctions , newContracts ) ;
214
177
}
215
178
}
0 commit comments