Skip to content

Commit

Permalink
fix code validation size in mining
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmanzanera committed Sep 17, 2024
1 parent 83206bb commit 488517b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/archethic/mining/pending_transaction_validation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,16 @@ defmodule Archethic.Mining.PendingTransactionValidation do
end

defp validate_code_size(code) do
if TransactionData.code_size_valid?(code),
do: :ok,
else: {:error, "Invalid transaction, code exceed max size"}
valid_size? =
case Jason.decode(code) do
{:ok, %{"bytecode" => bytecode}} ->
TransactionData.code_size_valid?(Base.decode16!(bytecode, case: :mixed))

_ ->
TransactionData.code_size_valid?(code)
end

if valid_size?, do: :ok, else: {:error, "Invalid transaction, code exceed max size"}
end

defp parse_contract(code) do
Expand Down

0 comments on commit 488517b

Please sign in to comment.