@@ -105,6 +105,17 @@ class VMClient(externalVmConfig: VmConfig.ExternalConfig, messageHandler: Messag
105105 resultMsg : msg.CallResult
106106 ): ProgramResult [W , S ] = {
107107 val updatedWorld = applyAccountChanges[W , S ](world, resultMsg)
108+
109+ val accessedResultTuple = resultMsg.accessList
110+ .map { accessList =>
111+ val addresses : Set [Address ] = accessList.addresses.map(a => a : Address ).toSet
112+ val locations : Set [(Address , BigInt )] = accessList.storageLocations.map { loc =>
113+ (loc.address: Address , loc.storageLocation: BigInt )
114+ }.toSet
115+ (addresses, locations)
116+ }
117+ .getOrElse((Set .empty[Address ], Set .empty[(Address , BigInt )]))
118+
108119 ProgramResult (
109120 resultMsg.returnData,
110121 resultMsg.gasRemaining,
@@ -115,8 +126,8 @@ class VMClient(externalVmConfig: VmConfig.ExternalConfig, messageHandler: Messag
115126 resultMsg.gasRefund,
116127 if (resultMsg.error) Some (OutOfGas ) else None ,
117128 // FIXME handle accessed addresses and storage in extVM
118- Set .empty ,
119- Set .empty
129+ accessedResultTuple._1 ,
130+ accessedResultTuple._2
120131 )
121132 }
122133
@@ -155,6 +166,23 @@ class VMClient(externalVmConfig: VmConfig.ExternalConfig, messageHandler: Messag
155166 case _ => Config .Empty
156167 }
157168
169+ val txType =
170+ if (ctx.warmAddresses.isEmpty && ctx.warmStorage.isEmpty) msg.CallContext .TxType .LEGACY
171+ else msg.CallContext .TxType .ACCESSLIST
172+
173+ val extraData = txType match {
174+ case msg.CallContext .TxType .LEGACY => msg.CallContext .ExtraData .Empty
175+ case msg.CallContext .TxType .ACCESSLIST =>
176+ msg.CallContext .ExtraData .AccessList (
177+ msg
178+ .AccessListData ()
179+ .withAddresses(ctx.warmAddresses.toSeq.map(_.bytes))
180+ .withStorageLocations(
181+ ctx.warmStorage.toSeq.map(x => msg.StorageEntry (address = x._1, storageLocation = x._2))
182+ )
183+ )
184+ }
185+
158186 msg.CallContext (
159187 callerAddr = ctx.callerAddr,
160188 recipientAddr = ctx.recipientAddr.map(_.bytes).getOrElse(ByteString .empty): ByteString ,
@@ -163,7 +191,9 @@ class VMClient(externalVmConfig: VmConfig.ExternalConfig, messageHandler: Messag
163191 gasPrice = ctx.gasPrice,
164192 gasProvided = ctx.startGas,
165193 blockHeader = Some (blockHeader),
166- config = config
194+ config = config,
195+ txType = txType,
196+ extraData = extraData
167197 )
168198 }
169199
@@ -178,6 +208,7 @@ class VMClient(externalVmConfig: VmConfig.ExternalConfig, messageHandler: Messag
178208 constantinopleBlockNumber = blockchainConfig.constantinopleBlockNumber,
179209 petersburgBlockNumber = blockchainConfig.petersburgBlockNumber,
180210 istanbulBlockNumber = blockchainConfig.istanbulBlockNumber,
211+ berlinBlockNumber = blockchainConfig.berlinBlockNumber,
181212 maxCodeSize = blockchainConfig.maxCodeSize.map(bigintToGByteString).getOrElse(ByteString ()),
182213 accountStartNonce = blockchainConfig.accountStartNonce,
183214 chainId = ByteString (blockchainConfig.chainId)
0 commit comments