Skip to content

Commit a0716b1

Browse files
committed
statetest: Properly load blob transactions
Handle JSON representation of blob transactions. Also compute excess_data_gas for the current block.
1 parent 38a109e commit a0716b1

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/statetest/statetest_loader.cpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,20 @@ state::BlockInfo from_json<state::BlockInfo>(const json::json& j)
181181
}
182182
}
183183

184+
uint64_t excess_data_gas = 0;
185+
if (const auto it = j.find("parentExcessDataGas"); it != j.end())
186+
{
187+
const auto parent_excess_data_gas = from_json<uint64_t>(*it);
188+
const auto parent_data_gas_used = from_json<uint64_t>(j.at("parentDataGasUsed"));
189+
static constexpr uint64_t TARGET_DATA_GAS_PER_BLOCK = 0x60000;
190+
excess_data_gas =
191+
std::max(parent_excess_data_gas + parent_data_gas_used, TARGET_DATA_GAS_PER_BLOCK) -
192+
TARGET_DATA_GAS_PER_BLOCK;
193+
}
194+
184195
return {from_json<int64_t>(j.at("currentNumber")), from_json<int64_t>(j.at("currentTimestamp")),
185196
from_json<int64_t>(j.at("currentGasLimit")),
186-
from_json<evmc::address>(j.at("currentCoinbase")), difficulty, base_fee,
197+
from_json<evmc::address>(j.at("currentCoinbase")), difficulty, base_fee, excess_data_gas,
187198
std::move(withdrawals)};
188199
}
189200

@@ -271,6 +282,13 @@ static void from_json_tx_common(const json::json& j, state::Transaction& o)
271282
o.max_gas_price = from_json<intx::uint256>(j.at("maxFeePerGas"));
272283
o.max_priority_gas_price = from_json<intx::uint256>(j.at("maxPriorityFeePerGas"));
273284
}
285+
286+
if (const auto it = j.find("blobVersionedHashes"); it != j.end())
287+
{
288+
o.type = state::Transaction::Type::blob;
289+
for (const auto& hash : *it)
290+
o.blob_hashes.push_back(from_json<bytes32>(hash));
291+
}
274292
}
275293

276294
template <>

0 commit comments

Comments
 (0)