@@ -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,
@@ -114,9 +125,8 @@ class VMClient(externalVmConfig: VmConfig.ExternalConfig, messageHandler: Messag
114125 Nil ,
115126 resultMsg.gasRefund,
116127 if (resultMsg.error) Some (OutOfGas ) else None ,
117- // FIXME handle accessed addresses and storage in extVM
118- Set .empty,
119- Set .empty
128+ accessedResultTuple._1,
129+ accessedResultTuple._2
120130 )
121131 }
122132
@@ -155,6 +165,23 @@ class VMClient(externalVmConfig: VmConfig.ExternalConfig, messageHandler: Messag
155165 case _ => Config .Empty
156166 }
157167
168+ val txType =
169+ if (ctx.warmAddresses.isEmpty && ctx.warmStorage.isEmpty) msg.CallContext .TxType .LEGACY
170+ else msg.CallContext .TxType .ACCESSLIST
171+
172+ val extraData = txType match {
173+ case msg.CallContext .TxType .LEGACY => msg.CallContext .ExtraData .Empty
174+ case msg.CallContext .TxType .ACCESSLIST =>
175+ msg.CallContext .ExtraData .AccessList (
176+ msg
177+ .AccessListData ()
178+ .withAddresses(ctx.warmAddresses.toSeq.map(_.bytes))
179+ .withStorageLocations(
180+ ctx.warmStorage.toSeq.map(x => msg.StorageEntry (address = x._1, storageLocation = x._2))
181+ )
182+ )
183+ }
184+
158185 msg.CallContext (
159186 callerAddr = ctx.callerAddr,
160187 recipientAddr = ctx.recipientAddr.map(_.bytes).getOrElse(ByteString .empty): ByteString ,
@@ -163,7 +190,9 @@ class VMClient(externalVmConfig: VmConfig.ExternalConfig, messageHandler: Messag
163190 gasPrice = ctx.gasPrice,
164191 gasProvided = ctx.startGas,
165192 blockHeader = Some (blockHeader),
166- config = config
193+ config = config,
194+ txType = txType,
195+ extraData = extraData
167196 )
168197 }
169198
@@ -178,6 +207,7 @@ class VMClient(externalVmConfig: VmConfig.ExternalConfig, messageHandler: Messag
178207 constantinopleBlockNumber = blockchainConfig.constantinopleBlockNumber,
179208 petersburgBlockNumber = blockchainConfig.petersburgBlockNumber,
180209 istanbulBlockNumber = blockchainConfig.istanbulBlockNumber,
210+ berlinBlockNumber = blockchainConfig.berlinBlockNumber,
181211 maxCodeSize = blockchainConfig.maxCodeSize.map(bigintToGByteString).getOrElse(ByteString ()),
182212 accountStartNonce = blockchainConfig.accountStartNonce,
183213 chainId = ByteString (blockchainConfig.chainId)
0 commit comments