From 43b0115bffb83eddec2d2ff9ea342d8b6e3ec348 Mon Sep 17 00:00:00 2001 From: Einer Zapata Date: Tue, 23 Jul 2024 11:53:02 -0500 Subject: [PATCH] Release v0.16 (#312) * Update XDR for Ledger entries (#308) * Update XDR for Ledger entries * Fix format * Update contract config setting (#309) * Update ContractCostType module * Update the StateArchivalSettings module * Fix format * Remove unused alias UInt64 * Add prerelase for v0.16.0 (#311) --- CHANGELOG.md | 5 + README.md | 2 +- .../config_setting/contract_cost_type.ex | 26 +- .../config_setting/state_archival_settings.ex | 24 +- .../contract_code_cost_inputs.ex | 249 ++++++++++++++++++ lib/xdr/ledger_entries/contract_code_entry.ex | 56 +--- .../ledger_entries/contract_code_entry_ext.ex | 74 ++++++ .../ledger_entries/contract_code_entry_v1.ex | 73 +++++ mix.exs | 2 +- .../contract_cost_type_test.exs | 50 +++- .../state_archival_settings_test.exs | 17 +- .../contract_code_cost_inputs_test.exs | 105 ++++++++ .../contract_code_entry_ext_test.exs | 134 ++++++++++ .../contract_code_entry_test.exs | 7 +- .../contract_code_entry_v1_test.exs | 80 ++++++ .../ledger_entries/ledger_entry_data_test.exs | 62 ++--- 16 files changed, 872 insertions(+), 94 deletions(-) create mode 100644 lib/xdr/ledger_entries/contract_code_cost_inputs.ex create mode 100644 lib/xdr/ledger_entries/contract_code_entry_ext.ex create mode 100644 lib/xdr/ledger_entries/contract_code_entry_v1.ex create mode 100644 test/xdr/ledger_entries/contract_code_cost_inputs_test.exs create mode 100644 test/xdr/ledger_entries/contract_code_entry_ext_test.exs create mode 100644 test/xdr/ledger_entries/contract_code_entry_v1_test.exs diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d3b0bb8..859273d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +# 0.16.0 (23.07.2024) + +* [Support stable Protocol 21 release](https://github.com/kommitters/stellar_base/issues/310). + + ## 0.15.1 (12.07.2024) * [Update soroban transaction meta type](https://github.com/kommitters/stellar_base/issues/302). diff --git a/README.md b/README.md index b7fffd44..cbc0a925 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ You should only use **`stellar_base`** if you are planning to build on top of it ```elixir def deps do [ - {:stellar_base, "~> 0.15.1"} + {:stellar_base, "~> 0.16.0"} ] end ``` diff --git a/lib/xdr/contract/config_setting/contract_cost_type.ex b/lib/xdr/contract/config_setting/contract_cost_type.ex index 5c84ba01..07e69895 100644 --- a/lib/xdr/contract/config_setting/contract_cost_type.ex +++ b/lib/xdr/contract/config_setting/contract_cost_type.ex @@ -26,14 +26,36 @@ defmodule StellarBase.XDR.ContractCostType do VmCachedInstantiation: 12, InvokeVmFunction: 13, ComputeKeccak256Hash: 14, - ComputeEcdsaSecp256k1Sig: 15, + DecodeEcdsaCurve256Sig: 15, RecoverEcdsaSecp256k1Key: 16, Int256AddSub: 17, Int256Mul: 18, Int256Div: 19, Int256Pow: 20, Int256Shift: 21, - ChaCha20DrawBytes: 22 + ChaCha20DrawBytes: 22, + ParseWasmInstructions: 23, + ParseWasmFunctions: 24, + ParseWasmGlobals: 25, + ParseWasmTableEntries: 26, + ParseWasmTypes: 27, + ParseWasmDataSegments: 28, + ParseWasmElemSegments: 29, + ParseWasmImports: 30, + ParseWasmExports: 31, + ParseWasmDataSegmentBytes: 32, + InstantiateWasmInstructions: 33, + InstantiateWasmFunctions: 34, + InstantiateWasmGlobals: 35, + InstantiateWasmTableEntries: 36, + InstantiateWasmTypes: 37, + InstantiateWasmDataSegments: 38, + InstantiateWasmElemSegments: 39, + InstantiateWasmImports: 40, + InstantiateWasmExports: 41, + InstantiateWasmDataSegmentBytes: 42, + Sec1DecodePointUncompressed: 43, + VerifyEcdsaSecp256r1Sig: 44 ] @enum_spec %XDR.Enum{declarations: @declarations, identifier: nil} diff --git a/lib/xdr/contract/config_setting/state_archival_settings.ex b/lib/xdr/contract/config_setting/state_archival_settings.ex index 067f3b10..ca3a19d8 100644 --- a/lib/xdr/contract/config_setting/state_archival_settings.ex +++ b/lib/xdr/contract/config_setting/state_archival_settings.ex @@ -12,8 +12,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do alias StellarBase.XDR.{ UInt32, - Int64, - UInt64 + Int64 } @struct_spec XDR.Struct.new( @@ -24,7 +23,8 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator: Int64, max_entries_to_archive: UInt32, bucket_list_size_window_sample_size: UInt32, - eviction_scan_size: UInt64, + bucket_list_window_sample_period: UInt32, + eviction_scan_size: UInt32, starting_eviction_scan_level: UInt32 ) @@ -35,7 +35,8 @@ defmodule StellarBase.XDR.StateArchivalSettings do @type temp_rent_rate_denominator_type :: Int64.t() @type max_entries_to_archive_type :: UInt32.t() @type bucket_list_size_window_sample_size_type :: UInt32.t() - @type eviction_scan_size_type :: UInt64.t() + @type bucket_list_window_sample_period_type :: UInt32.t() + @type eviction_scan_size_type :: UInt32.t() @type starting_eviction_scan_level_type :: UInt32.t() @type t :: %__MODULE__{ @@ -46,6 +47,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator: temp_rent_rate_denominator_type(), max_entries_to_archive: max_entries_to_archive_type(), bucket_list_size_window_sample_size: bucket_list_size_window_sample_size_type(), + bucket_list_window_sample_period: bucket_list_window_sample_period_type(), eviction_scan_size: eviction_scan_size_type(), starting_eviction_scan_level: starting_eviction_scan_level_type() } @@ -58,6 +60,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do :temp_rent_rate_denominator, :max_entries_to_archive, :bucket_list_size_window_sample_size, + :bucket_list_window_sample_period, :eviction_scan_size, :starting_eviction_scan_level ] @@ -70,6 +73,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator :: temp_rent_rate_denominator_type(), max_entries_to_archive :: max_entries_to_archive_type(), bucket_list_size_window_sample_size :: bucket_list_size_window_sample_size_type(), + bucket_list_window_sample_period :: bucket_list_window_sample_period_type(), eviction_scan_size :: eviction_scan_size_type(), starting_eviction_scan_level :: starting_eviction_scan_level_type() ) :: t() @@ -81,7 +85,8 @@ defmodule StellarBase.XDR.StateArchivalSettings do %Int64{} = temp_rent_rate_denominator, %UInt32{} = max_entries_to_archive, %UInt32{} = bucket_list_size_window_sample_size, - %UInt64{} = eviction_scan_size, + %UInt32{} = bucket_list_window_sample_period, + %UInt32{} = eviction_scan_size, %UInt32{} = starting_eviction_scan_level ), do: %__MODULE__{ @@ -92,6 +97,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size, starting_eviction_scan_level: starting_eviction_scan_level } @@ -105,6 +111,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size, starting_eviction_scan_level: starting_eviction_scan_level }) do @@ -116,6 +123,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size, starting_eviction_scan_level: starting_eviction_scan_level ] @@ -132,6 +140,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size, starting_eviction_scan_level: starting_eviction_scan_level }) do @@ -143,6 +152,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size, starting_eviction_scan_level: starting_eviction_scan_level ] @@ -165,6 +175,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size, starting_eviction_scan_level: starting_eviction_scan_level ] @@ -178,6 +189,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator, max_entries_to_archive, bucket_list_size_window_sample_size, + bucket_list_window_sample_period, eviction_scan_size, starting_eviction_scan_level ), rest}} @@ -200,6 +212,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size, starting_eviction_scan_level: starting_eviction_scan_level ] @@ -213,6 +226,7 @@ defmodule StellarBase.XDR.StateArchivalSettings do temp_rent_rate_denominator, max_entries_to_archive, bucket_list_size_window_sample_size, + bucket_list_window_sample_period, eviction_scan_size, starting_eviction_scan_level ), rest} diff --git a/lib/xdr/ledger_entries/contract_code_cost_inputs.ex b/lib/xdr/ledger_entries/contract_code_cost_inputs.ex new file mode 100644 index 00000000..571e7dbb --- /dev/null +++ b/lib/xdr/ledger_entries/contract_code_cost_inputs.ex @@ -0,0 +1,249 @@ +defmodule StellarBase.XDR.ContractCodeCostInputs do + @moduledoc """ + Automatically generated by xdrgen + DO NOT EDIT or your changes may be overwritten + + Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr + + Representation of Stellar `ContractCodeCostInputs` type. + """ + + @behaviour XDR.Declaration + + alias StellarBase.XDR.{ + ExtensionPoint, + UInt32 + } + + @struct_spec XDR.Struct.new( + ext: ExtensionPoint, + n_instructions: UInt32, + n_functions: UInt32, + n_globals: UInt32, + n_table_entries: UInt32, + n_types: UInt32, + n_data_segments: UInt32, + n_elem_segments: UInt32, + n_imports: UInt32, + n_exports: UInt32, + n_data_segment_bytes: UInt32 + ) + + @type ext_type :: ExtensionPoint.t() + @type n_instructions_type :: UInt32.t() + @type n_functions_type :: UInt32.t() + @type n_globals_type :: UInt32.t() + @type n_table_entries_type :: UInt32.t() + @type n_types_type :: UInt32.t() + @type n_data_segments_type :: UInt32.t() + @type n_elem_segments_type :: UInt32.t() + @type n_imports_type :: UInt32.t() + @type n_exports_type :: UInt32.t() + @type n_data_segment_bytes_type :: UInt32.t() + + @type t :: %__MODULE__{ + ext: ext_type(), + n_instructions: n_instructions_type(), + n_functions: n_functions_type(), + n_globals: n_globals_type(), + n_table_entries: n_table_entries_type(), + n_types: n_types_type(), + n_data_segments: n_data_segments_type(), + n_elem_segments: n_elem_segments_type(), + n_imports: n_imports_type(), + n_exports: n_exports_type(), + n_data_segment_bytes: n_data_segment_bytes_type() + } + + defstruct [ + :ext, + :n_instructions, + :n_functions, + :n_globals, + :n_table_entries, + :n_types, + :n_data_segments, + :n_elem_segments, + :n_imports, + :n_exports, + :n_data_segment_bytes + ] + + @spec new( + ext :: ext_type(), + n_instructions :: n_instructions_type(), + n_functions :: n_functions_type(), + n_globals :: n_globals_type(), + n_table_entries :: n_table_entries_type(), + n_types :: n_types_type(), + n_data_segments :: n_data_segments_type(), + n_elem_segments :: n_elem_segments_type(), + n_imports :: n_imports_type(), + n_exports :: n_exports_type(), + n_data_segment_bytes :: n_data_segment_bytes_type() + ) :: t() + def new( + %ExtensionPoint{} = ext, + %UInt32{} = n_instructions, + %UInt32{} = n_functions, + %UInt32{} = n_globals, + %UInt32{} = n_table_entries, + %UInt32{} = n_types, + %UInt32{} = n_data_segments, + %UInt32{} = n_elem_segments, + %UInt32{} = n_imports, + %UInt32{} = n_exports, + %UInt32{} = n_data_segment_bytes + ), + do: %__MODULE__{ + ext: ext, + n_instructions: n_instructions, + n_functions: n_functions, + n_globals: n_globals, + n_table_entries: n_table_entries, + n_types: n_types, + n_data_segments: n_data_segments, + n_elem_segments: n_elem_segments, + n_imports: n_imports, + n_exports: n_exports, + n_data_segment_bytes: n_data_segment_bytes + } + + @impl true + def encode_xdr(%__MODULE__{ + ext: ext, + n_instructions: n_instructions, + n_functions: n_functions, + n_globals: n_globals, + n_table_entries: n_table_entries, + n_types: n_types, + n_data_segments: n_data_segments, + n_elem_segments: n_elem_segments, + n_imports: n_imports, + n_exports: n_exports, + n_data_segment_bytes: n_data_segment_bytes + }) do + [ + ext: ext, + n_instructions: n_instructions, + n_functions: n_functions, + n_globals: n_globals, + n_table_entries: n_table_entries, + n_types: n_types, + n_data_segments: n_data_segments, + n_elem_segments: n_elem_segments, + n_imports: n_imports, + n_exports: n_exports, + n_data_segment_bytes: n_data_segment_bytes + ] + |> XDR.Struct.new() + |> XDR.Struct.encode_xdr() + end + + @impl true + def encode_xdr!(%__MODULE__{ + ext: ext, + n_instructions: n_instructions, + n_functions: n_functions, + n_globals: n_globals, + n_table_entries: n_table_entries, + n_types: n_types, + n_data_segments: n_data_segments, + n_elem_segments: n_elem_segments, + n_imports: n_imports, + n_exports: n_exports, + n_data_segment_bytes: n_data_segment_bytes + }) do + [ + ext: ext, + n_instructions: n_instructions, + n_functions: n_functions, + n_globals: n_globals, + n_table_entries: n_table_entries, + n_types: n_types, + n_data_segments: n_data_segments, + n_elem_segments: n_elem_segments, + n_imports: n_imports, + n_exports: n_exports, + n_data_segment_bytes: n_data_segment_bytes + ] + |> XDR.Struct.new() + |> XDR.Struct.encode_xdr!() + end + + @impl true + def decode_xdr(bytes, struct \\ @struct_spec) + + def decode_xdr(bytes, struct) do + case XDR.Struct.decode_xdr(bytes, struct) do + {:ok, + {%XDR.Struct{ + components: [ + ext: ext, + n_instructions: n_instructions, + n_functions: n_functions, + n_globals: n_globals, + n_table_entries: n_table_entries, + n_types: n_types, + n_data_segments: n_data_segments, + n_elem_segments: n_elem_segments, + n_imports: n_imports, + n_exports: n_exports, + n_data_segment_bytes: n_data_segment_bytes + ] + }, rest}} -> + {:ok, + {new( + ext, + n_instructions, + n_functions, + n_globals, + n_table_entries, + n_types, + n_data_segments, + n_elem_segments, + n_imports, + n_exports, + n_data_segment_bytes + ), rest}} + + error -> + error + end + end + + @impl true + def decode_xdr!(bytes, struct \\ @struct_spec) + + def decode_xdr!(bytes, struct) do + {%XDR.Struct{ + components: [ + ext: ext, + n_instructions: n_instructions, + n_functions: n_functions, + n_globals: n_globals, + n_table_entries: n_table_entries, + n_types: n_types, + n_data_segments: n_data_segments, + n_elem_segments: n_elem_segments, + n_imports: n_imports, + n_exports: n_exports, + n_data_segment_bytes: n_data_segment_bytes + ] + }, rest} = XDR.Struct.decode_xdr!(bytes, struct) + + {new( + ext, + n_instructions, + n_functions, + n_globals, + n_table_entries, + n_types, + n_data_segments, + n_elem_segments, + n_imports, + n_exports, + n_data_segment_bytes + ), rest} + end +end diff --git a/lib/xdr/ledger_entries/contract_code_entry.ex b/lib/xdr/ledger_entries/contract_code_entry.ex index f3137254..6b4d8cd8 100644 --- a/lib/xdr/ledger_entries/contract_code_entry.ex +++ b/lib/xdr/ledger_entries/contract_code_entry.ex @@ -11,62 +11,42 @@ defmodule StellarBase.XDR.ContractCodeEntry do @behaviour XDR.Declaration alias StellarBase.XDR.{ - ExtensionPoint, + ContractCodeEntryExt, Hash, VariableOpaque } @struct_spec XDR.Struct.new( - ext: ExtensionPoint, + ext: ContractCodeEntryExt, hash: Hash, code: VariableOpaque ) - @type ext_type :: ExtensionPoint.t() + @type ext_type :: ContractCodeEntryExt.t() @type hash_type :: Hash.t() @type code_type :: VariableOpaque.t() - @type t :: %__MODULE__{ - ext: ext_type(), - hash: hash_type(), - code: code_type() - } + @type t :: %__MODULE__{ext: ext_type(), hash: hash_type(), code: code_type()} defstruct [:ext, :hash, :code] - @spec new( - ext :: ext_type(), - hash :: hash_type(), - code :: code_type() - ) :: t() + @spec new(ext :: ext_type(), hash :: hash_type(), code :: code_type()) :: t() def new( - %ExtensionPoint{} = ext, + %ContractCodeEntryExt{} = ext, %Hash{} = hash, %VariableOpaque{} = code ), - do: %__MODULE__{ - ext: ext, - hash: hash, - code: code - } + do: %__MODULE__{ext: ext, hash: hash, code: code} @impl true - def encode_xdr(%__MODULE__{ - ext: ext, - hash: hash, - code: code - }) do + def encode_xdr(%__MODULE__{ext: ext, hash: hash, code: code}) do [ext: ext, hash: hash, code: code] |> XDR.Struct.new() |> XDR.Struct.encode_xdr() end @impl true - def encode_xdr!(%__MODULE__{ - ext: ext, - hash: hash, - code: code - }) do + def encode_xdr!(%__MODULE__{ext: ext, hash: hash, code: code}) do [ext: ext, hash: hash, code: code] |> XDR.Struct.new() |> XDR.Struct.encode_xdr!() @@ -77,14 +57,7 @@ defmodule StellarBase.XDR.ContractCodeEntry do def decode_xdr(bytes, struct) do case XDR.Struct.decode_xdr(bytes, struct) do - {:ok, - {%XDR.Struct{ - components: [ - ext: ext, - hash: hash, - code: code - ] - }, rest}} -> + {:ok, {%XDR.Struct{components: [ext: ext, hash: hash, code: code]}, rest}} -> {:ok, {new(ext, hash, code), rest}} error -> @@ -96,13 +69,8 @@ defmodule StellarBase.XDR.ContractCodeEntry do def decode_xdr!(bytes, struct \\ @struct_spec) def decode_xdr!(bytes, struct) do - {%XDR.Struct{ - components: [ - ext: ext, - hash: hash, - code: code - ] - }, rest} = XDR.Struct.decode_xdr!(bytes, struct) + {%XDR.Struct{components: [ext: ext, hash: hash, code: code]}, rest} = + XDR.Struct.decode_xdr!(bytes, struct) {new(ext, hash, code), rest} end diff --git a/lib/xdr/ledger_entries/contract_code_entry_ext.ex b/lib/xdr/ledger_entries/contract_code_entry_ext.ex new file mode 100644 index 00000000..a577f8a6 --- /dev/null +++ b/lib/xdr/ledger_entries/contract_code_entry_ext.ex @@ -0,0 +1,74 @@ +defmodule StellarBase.XDR.ContractCodeEntryExt do + @moduledoc """ + Automatically generated by xdrgen + DO NOT EDIT or your changes may be overwritten + + Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr + + Representation of Stellar `ContractCodeEntryExt` type. + """ + + @behaviour XDR.Declaration + + alias StellarBase.XDR.{ + Void, + ContractCodeEntryV1 + } + + @arms %{ + 0 => Void, + 1 => ContractCodeEntryV1 + } + + @type value :: + Void.t() + | ContractCodeEntryV1.t() + + @type t :: %__MODULE__{value: value(), type: integer()} + + defstruct [:value, :type] + + @spec new(value :: value(), type :: integer()) :: t() + def new(value, type), do: %__MODULE__{value: value, type: type} + + @impl true + def encode_xdr(%__MODULE__{value: value, type: type}) do + type + |> XDR.Int.new() + |> XDR.Union.new(@arms, value) + |> XDR.Union.encode_xdr() + end + + @impl true + def encode_xdr!(%__MODULE__{value: value, type: type}) do + type + |> XDR.Int.new() + |> XDR.Union.new(@arms, value) + |> XDR.Union.encode_xdr!() + end + + @impl true + def decode_xdr(bytes, spec \\ union_spec()) + + def decode_xdr(bytes, spec) do + case XDR.Union.decode_xdr(bytes, spec) do + {:ok, {{type, value}, rest}} -> {:ok, {new(value, type), rest}} + error -> error + end + end + + @impl true + def decode_xdr!(bytes, spec \\ union_spec()) + + def decode_xdr!(bytes, spec) do + {{type, value}, rest} = XDR.Union.decode_xdr!(bytes, spec) + {new(value, type), rest} + end + + @spec union_spec() :: XDR.Union.t() + defp union_spec do + 0 + |> XDR.Int.new() + |> XDR.Union.new(@arms) + end +end diff --git a/lib/xdr/ledger_entries/contract_code_entry_v1.ex b/lib/xdr/ledger_entries/contract_code_entry_v1.ex new file mode 100644 index 00000000..3f8a20fb --- /dev/null +++ b/lib/xdr/ledger_entries/contract_code_entry_v1.ex @@ -0,0 +1,73 @@ +defmodule StellarBase.XDR.ContractCodeEntryV1 do + @moduledoc """ + Automatically generated by xdrgen + DO NOT EDIT or your changes may be overwritten + + Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr + + Representation of Stellar `ContractCodeEntryV1` type. + """ + + @behaviour XDR.Declaration + + alias StellarBase.XDR.{ + ExtensionPoint, + ContractCodeCostInputs + } + + @struct_spec XDR.Struct.new( + ext: ExtensionPoint, + cost_inputs: ContractCodeCostInputs + ) + + @type ext_type :: ExtensionPoint.t() + @type cost_inputs_type :: ContractCodeCostInputs.t() + + @type t :: %__MODULE__{ext: ext_type(), cost_inputs: cost_inputs_type()} + + defstruct [:ext, :cost_inputs] + + @spec new(ext :: ext_type(), cost_inputs :: cost_inputs_type()) :: t() + def new( + %ExtensionPoint{} = ext, + %ContractCodeCostInputs{} = cost_inputs + ), + do: %__MODULE__{ext: ext, cost_inputs: cost_inputs} + + @impl true + def encode_xdr(%__MODULE__{ext: ext, cost_inputs: cost_inputs}) do + [ext: ext, cost_inputs: cost_inputs] + |> XDR.Struct.new() + |> XDR.Struct.encode_xdr() + end + + @impl true + def encode_xdr!(%__MODULE__{ext: ext, cost_inputs: cost_inputs}) do + [ext: ext, cost_inputs: cost_inputs] + |> XDR.Struct.new() + |> XDR.Struct.encode_xdr!() + end + + @impl true + def decode_xdr(bytes, struct \\ @struct_spec) + + def decode_xdr(bytes, struct) do + case XDR.Struct.decode_xdr(bytes, struct) do + {:ok, {%XDR.Struct{components: [ext: ext, cost_inputs: cost_inputs]}, rest}} -> + {:ok, {new(ext, cost_inputs), rest}} + + error -> + error + end + end + + @impl true + def decode_xdr!(bytes, struct \\ @struct_spec) + + def decode_xdr!(bytes, struct) do + {%XDR.Struct{components: [ext: ext, cost_inputs: cost_inputs]}, rest} = + XDR.Struct.decode_xdr!(bytes, struct) + + {new(ext, cost_inputs), rest} + end +end diff --git a/mix.exs b/mix.exs index 40da72fd..d7ea8d51 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule StellarBase.MixProject do use Mix.Project @github_url "https://github.com/kommitters/stellar_base" - @version "0.15.1" + @version "0.16.0" def project do [ diff --git a/test/xdr/contract/config_setting/contract_cost_type_test.exs b/test/xdr/contract/config_setting/contract_cost_type_test.exs index 4f5e4dc1..8163896e 100644 --- a/test/xdr/contract/config_setting/contract_cost_type_test.exs +++ b/test/xdr/contract/config_setting/contract_cost_type_test.exs @@ -19,14 +19,36 @@ defmodule StellarBase.XDR.ContractCostTypeTest do :VmCachedInstantiation, :InvokeVmFunction, :ComputeKeccak256Hash, - :ComputeEcdsaSecp256k1Sig, + :DecodeEcdsaCurve256Sig, :RecoverEcdsaSecp256k1Key, :Int256AddSub, :Int256Mul, :Int256Div, :Int256Pow, :Int256Shift, - :ChaCha20DrawBytes + :ChaCha20DrawBytes, + :ParseWasmInstructions, + :ParseWasmFunctions, + :ParseWasmGlobals, + :ParseWasmTableEntries, + :ParseWasmTypes, + :ParseWasmDataSegments, + :ParseWasmElemSegments, + :ParseWasmImports, + :ParseWasmExports, + :ParseWasmDataSegmentBytes, + :InstantiateWasmInstructions, + :InstantiateWasmFunctions, + :InstantiateWasmGlobals, + :InstantiateWasmTableEntries, + :InstantiateWasmTypes, + :InstantiateWasmDataSegments, + :InstantiateWasmElemSegments, + :InstantiateWasmImports, + :InstantiateWasmExports, + :InstantiateWasmDataSegmentBytes, + :Sec1DecodePointUncompressed, + :VerifyEcdsaSecp256r1Sig ] @binaries [ @@ -52,7 +74,29 @@ defmodule StellarBase.XDR.ContractCostTypeTest do <<0, 0, 0, 19>>, <<0, 0, 0, 20>>, <<0, 0, 0, 21>>, - <<0, 0, 0, 22>> + <<0, 0, 0, 22>>, + <<0, 0, 0, 23>>, + <<0, 0, 0, 24>>, + <<0, 0, 0, 25>>, + <<0, 0, 0, 26>>, + <<0, 0, 0, 27>>, + <<0, 0, 0, 28>>, + <<0, 0, 0, 29>>, + <<0, 0, 0, 30>>, + <<0, 0, 0, 31>>, + <<0, 0, 0, 32>>, + <<0, 0, 0, 33>>, + <<0, 0, 0, 34>>, + <<0, 0, 0, 35>>, + <<0, 0, 0, 36>>, + <<0, 0, 0, 37>>, + <<0, 0, 0, 38>>, + <<0, 0, 0, 39>>, + <<0, 0, 0, 40>>, + <<0, 0, 0, 41>>, + <<0, 0, 0, 42>>, + <<0, 0, 0, 43>>, + <<0, 0, 0, 44>> ] describe "ContractCostType" do diff --git a/test/xdr/contract/config_setting/state_archival_settings_test.exs b/test/xdr/contract/config_setting/state_archival_settings_test.exs index 83977a66..796c4879 100644 --- a/test/xdr/contract/config_setting/state_archival_settings_test.exs +++ b/test/xdr/contract/config_setting/state_archival_settings_test.exs @@ -4,8 +4,7 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do alias StellarBase.XDR.{ StateArchivalSettings, UInt32, - Int64, - UInt64 + Int64 } setup do @@ -17,11 +16,12 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do temp_rent_rate_denominator = Int64.new(200) max_entries_to_archive = UInt32.new(500) bucket_list_size_window_sample_size = UInt32.new(1000) - eviction_scan_size = UInt64.new(5000) + bucket_list_window_sample_period = UInt32.new(100) + eviction_scan_size = UInt32.new(5000) binary = <<0, 0, 0, 100, 0, 0, 0, 50, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, - 200, 0, 0, 1, 244, 0, 0, 3, 232, 0, 0, 0, 0, 0, 0, 19, 136, 0, 0, 0, 5>> + 200, 0, 0, 1, 244, 0, 0, 3, 232, 0, 0, 0, 100, 0, 0, 19, 136, 0, 0, 0, 5>> state_expiration_settings = StateArchivalSettings.new( @@ -32,6 +32,7 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do temp_rent_rate_denominator, max_entries_to_archive, bucket_list_size_window_sample_size, + bucket_list_window_sample_period, eviction_scan_size, starting_eviction_scan_level ) @@ -45,6 +46,7 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size, binary: binary, state_expiration_settings: state_expiration_settings @@ -60,6 +62,7 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size } do %StateArchivalSettings{ @@ -70,6 +73,7 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do temp_rent_rate_denominator: ^temp_rent_rate_denominator, max_entries_to_archive: ^max_entries_to_archive, bucket_list_size_window_sample_size: ^bucket_list_size_window_sample_size, + bucket_list_window_sample_period: ^bucket_list_window_sample_period, eviction_scan_size: ^eviction_scan_size, starting_eviction_scan_level: ^starting_eviction_scan_level } = @@ -81,6 +85,7 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do temp_rent_rate_denominator, max_entries_to_archive, bucket_list_size_window_sample_size, + bucket_list_window_sample_period, eviction_scan_size, starting_eviction_scan_level ) @@ -96,6 +101,7 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size } do {:ok, ^binary} = @@ -107,6 +113,7 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do temp_rent_rate_denominator, max_entries_to_archive, bucket_list_size_window_sample_size, + bucket_list_window_sample_period, eviction_scan_size, starting_eviction_scan_level ) @@ -123,6 +130,7 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do temp_rent_rate_denominator: temp_rent_rate_denominator, max_entries_to_archive: max_entries_to_archive, bucket_list_size_window_sample_size: bucket_list_size_window_sample_size, + bucket_list_window_sample_period: bucket_list_window_sample_period, eviction_scan_size: eviction_scan_size } do ^binary = @@ -134,6 +142,7 @@ defmodule StellarBase.XDR.StateArchivalSettingsTest do temp_rent_rate_denominator, max_entries_to_archive, bucket_list_size_window_sample_size, + bucket_list_window_sample_period, eviction_scan_size, starting_eviction_scan_level ) diff --git a/test/xdr/ledger_entries/contract_code_cost_inputs_test.exs b/test/xdr/ledger_entries/contract_code_cost_inputs_test.exs new file mode 100644 index 00000000..3d4f1731 --- /dev/null +++ b/test/xdr/ledger_entries/contract_code_cost_inputs_test.exs @@ -0,0 +1,105 @@ +defmodule StellarBase.XDR.ContractCodeCostInputsTest do + use ExUnit.Case + alias StellarBase.XDR.{ContractCodeCostInputs, ExtensionPoint, UInt32, Void} + + describe "ContractCodeCostInputs" do + setup do + general_number = UInt32.new(1) + ext = ExtensionPoint.new(Void.new(), 0) + + cost_inputs = + ContractCodeCostInputs.new( + ext, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number + ) + + %{ + ext: ext, + n_instructions_type: general_number, + n_functions_type: general_number, + n_globals_type: general_number, + n_table_entries_type: general_number, + n_types_type: general_number, + n_data_segments_type: general_number, + n_elem_segments_type: general_number, + n_imports_type: general_number, + n_exports_type: general_number, + n_data_segment_bytes_type: general_number, + cost_inputs: cost_inputs, + binary: + <<0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1>> + } + end + + test "new/11", %{ + ext: ext, + n_instructions_type: n_instructions_type, + n_functions_type: n_functions_type, + n_globals_type: n_globals_type, + n_table_entries_type: n_table_entries_type, + n_types_type: n_types_type, + n_data_segments_type: n_data_segments_type, + n_elem_segments_type: n_elem_segments_type, + n_imports_type: n_imports_type, + n_exports_type: n_exports_type, + n_data_segment_bytes_type: n_data_segment_bytes_type + } do + %ContractCodeCostInputs{ + ext: ^ext, + n_instructions: ^n_instructions_type, + n_functions: ^n_functions_type, + n_globals: ^n_globals_type, + n_table_entries: ^n_table_entries_type, + n_types: ^n_types_type, + n_data_segments: ^n_data_segments_type, + n_elem_segments: ^n_elem_segments_type, + n_imports: ^n_imports_type, + n_exports: ^n_exports_type, + n_data_segment_bytes: ^n_data_segment_bytes_type + } = + ContractCodeCostInputs.new( + ext, + n_instructions_type, + n_functions_type, + n_globals_type, + n_table_entries_type, + n_types_type, + n_data_segments_type, + n_elem_segments_type, + n_imports_type, + n_exports_type, + n_data_segment_bytes_type + ) + end + + test "encode_xdr/1", %{cost_inputs: cost_inputs, binary: binary} do + {:ok, ^binary} = ContractCodeCostInputs.encode_xdr(cost_inputs) + end + + test "encode_xdr!/1", %{cost_inputs: cost_inputs, binary: binary} do + ^binary = ContractCodeCostInputs.encode_xdr!(cost_inputs) + end + + test "decode_xdr/2", %{cost_inputs: cost_inputs, binary: binary} do + {:ok, {^cost_inputs, ""}} = ContractCodeCostInputs.decode_xdr(binary) + end + + test "decode_xdr/2 with an invalid binary" do + {:error, :not_binary} = ContractCodeCostInputs.decode_xdr(123) + end + + test "decode_xdr!/2", %{cost_inputs: cost_inputs, binary: binary} do + {^cost_inputs, ""} = ContractCodeCostInputs.decode_xdr!(binary) + end + end +end diff --git a/test/xdr/ledger_entries/contract_code_entry_ext_test.exs b/test/xdr/ledger_entries/contract_code_entry_ext_test.exs new file mode 100644 index 00000000..b450e96a --- /dev/null +++ b/test/xdr/ledger_entries/contract_code_entry_ext_test.exs @@ -0,0 +1,134 @@ +defmodule StellarBase.XDR.ContractCodeEntryExtTest do + use ExUnit.Case + + alias StellarBase.XDR.{ + ContractCodeCostInputs, + ContractCodeEntryExt, + ContractCodeEntryV1, + ExtensionPoint, + UInt32, + Void + } + + describe "ContractCodeEntryExt with Void" do + setup do + value = Void.new() + type = 0 + contract_code_entry_ext = ContractCodeEntryExt.new(value, type) + + %{ + value: value, + type: type, + contract_code_entry_ext: contract_code_entry_ext, + binary: <<0, 0, 0, 0>> + } + end + + test "new/2", %{ + value: value, + type: type + } do + %ContractCodeEntryExt{ + value: ^value, + type: ^type + } = ContractCodeEntryExt.new(value, type) + end + + test "encode_xdr/1", %{contract_code_entry_ext: contract_code_entry_ext, binary: binary} do + {:ok, ^binary} = ContractCodeEntryExt.encode_xdr(contract_code_entry_ext) + end + + test "encode_xdr!/1", %{ + contract_code_entry_ext: contract_code_entry_ext, + binary: binary + } do + ^binary = ContractCodeEntryExt.encode_xdr!(contract_code_entry_ext) + end + + test "decode_xdr/2", %{contract_code_entry_ext: contract_code_entry_ext, binary: binary} do + {:ok, {^contract_code_entry_ext, ""}} = ContractCodeEntryExt.decode_xdr(binary) + end + + test "decode_xdr/2 with an invalid binary" do + {:error, :not_binary} = ContractCodeEntryExt.decode_xdr(123) + end + + test "decode_xdr!/2", %{ + contract_code_entry_ext: contract_code_entry_ext, + binary: binary + } do + {^contract_code_entry_ext, ""} = ContractCodeEntryExt.decode_xdr!(binary) + end + end + + describe "ContractCodeEntryExt with ContractCodeEntryV1" do + setup do + general_number = UInt32.new(1) + ext = ExtensionPoint.new(Void.new(), 0) + + constract_code_cost_inputs = + ContractCodeCostInputs.new( + ext, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number + ) + + value = ContractCodeEntryV1.new(ext, constract_code_cost_inputs) + type = 1 + contract_code_entry_ext = ContractCodeEntryExt.new(value, type) + + %{ + value: value, + type: type, + contract_code_entry_ext: contract_code_entry_ext, + binary: + <<0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1>> + } + end + + test "new/2", %{ + value: value, + type: type + } do + %ContractCodeEntryExt{ + value: ^value, + type: ^type + } = ContractCodeEntryExt.new(value, type) + end + + test "encode_xdr/1", %{contract_code_entry_ext: contract_code_entry_ext, binary: binary} do + {:ok, ^binary} = ContractCodeEntryExt.encode_xdr(contract_code_entry_ext) + end + + test "encode_xdr!/1", %{ + contract_code_entry_ext: contract_code_entry_ext, + binary: binary + } do + ^binary = ContractCodeEntryExt.encode_xdr!(contract_code_entry_ext) + end + + test "decode_xdr/2", %{contract_code_entry_ext: contract_code_entry_ext, binary: binary} do + {:ok, {^contract_code_entry_ext, ""}} = ContractCodeEntryExt.decode_xdr(binary) + end + + test "decode_xdr/2 with an invalid binary" do + {:error, :not_binary} = ContractCodeEntryExt.decode_xdr(123) + end + + test "decode_xdr!/2", %{ + contract_code_entry_ext: contract_code_entry_ext, + binary: binary + } do + {^contract_code_entry_ext, ""} = ContractCodeEntryExt.decode_xdr!(binary) + end + end +end diff --git a/test/xdr/ledger_entries/contract_code_entry_test.exs b/test/xdr/ledger_entries/contract_code_entry_test.exs index dba59dae..76a6d913 100644 --- a/test/xdr/ledger_entries/contract_code_entry_test.exs +++ b/test/xdr/ledger_entries/contract_code_entry_test.exs @@ -3,7 +3,7 @@ defmodule StellarBase.XDR.ContractCodeEntryTest do alias StellarBase.XDR.{ ContractCodeEntry, - ExtensionPoint, + ContractCodeEntryExt, Hash, VariableOpaque, Void @@ -11,8 +11,9 @@ defmodule StellarBase.XDR.ContractCodeEntryTest do describe "ContractCodeEntry" do setup do - ext = ExtensionPoint.new(Void.new(), 0) + ext = ContractCodeEntryExt.new(Void.new(), 0) hash = Hash.new("GCIZ3GSM5XL7OUS4UP64THMDZ7CZ3ZWN") + code = VariableOpaque.new("GCIZ3GSM5") %{ @@ -27,7 +28,7 @@ defmodule StellarBase.XDR.ContractCodeEntryTest do } end - test "new/1", %{ + test "new/3", %{ ext: ext, hash: hash, code: code diff --git a/test/xdr/ledger_entries/contract_code_entry_v1_test.exs b/test/xdr/ledger_entries/contract_code_entry_v1_test.exs new file mode 100644 index 00000000..805f5737 --- /dev/null +++ b/test/xdr/ledger_entries/contract_code_entry_v1_test.exs @@ -0,0 +1,80 @@ +defmodule StellarBase.XDR.ContractCodeEntryV1Test do + use ExUnit.Case + + alias StellarBase.XDR.{ + ContractCodeCostInputs, + ContractCodeEntryV1, + ExtensionPoint, + UInt32, + Void + } + + describe "ContractCodeEntryV1" do + setup do + general_number = UInt32.new(1) + ext = ExtensionPoint.new(Void.new(), 0) + + cost_inputs = + ContractCodeCostInputs.new( + ext, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number, + general_number + ) + + contra_code_entry_v1 = ContractCodeEntryV1.new(ext, cost_inputs) + + %{ + ext: ext, + cost_inputs: cost_inputs, + contra_code_entry_v1: contra_code_entry_v1, + binary: + <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1>> + } + end + + test "new/2", %{ + ext: ext, + cost_inputs: cost_inputs + } do + %ContractCodeEntryV1{ + ext: ^ext, + cost_inputs: ^cost_inputs + } = ContractCodeEntryV1.new(ext, cost_inputs) + end + + test "encode_xdr/1", %{contra_code_entry_v1: contra_code_entry_v1, binary: binary} do + {:ok, ^binary} = ContractCodeEntryV1.encode_xdr(contra_code_entry_v1) + end + + test "encode_xdr!/1", %{ + contra_code_entry_v1: contra_code_entry_v1, + binary: binary + } do + ^binary = ContractCodeEntryV1.encode_xdr!(contra_code_entry_v1) + end + + test "decode_xdr/2", %{contra_code_entry_v1: contra_code_entry_v1, binary: binary} do + {:ok, {^contra_code_entry_v1, ""}} = ContractCodeEntryV1.decode_xdr(binary) + end + + test "decode_xdr/2 with an invalid binary" do + {:error, :not_binary} = ContractCodeEntryV1.decode_xdr(123) + end + + test "decode_xdr!/2", %{ + contra_code_entry_v1: contra_code_entry_v1, + binary: binary + } do + {^contra_code_entry_v1, ""} = ContractCodeEntryV1.decode_xdr!(binary) + end + end +end diff --git a/test/xdr/ledger_entries/ledger_entry_data_test.exs b/test/xdr/ledger_entries/ledger_entry_data_test.exs index 558e30f5..a543e007 100644 --- a/test/xdr/ledger_entries/ledger_entry_data_test.exs +++ b/test/xdr/ledger_entries/ledger_entry_data_test.exs @@ -4,47 +4,46 @@ defmodule StellarBase.XDR.LedgerEntryDataTest do import StellarBase.Test.Utils alias StellarBase.XDR.{ + AccountEntry, + AccountEntryExt, + AlphaNum4, AssetCode4, AssetType, - AlphaNum4, - ContractCodeEntry, ContractCodeEntry, + ContractCodeEntryExt, ContractDataDurability, - TrustLineAsset, + ContractDataEntry, + DataEntry, + DataValue, + ExtensionPoint, + Ext, + Hash, + Int32, Int64, - LedgerEntryType, LedgerEntryData, - UInt256, + LedgerEntryType, + OfferEntry, OptionalAccountID, - SignerKeyType, - UInt32, - SignerKey, - Signer, - SequenceNumber, - String32, - Thresholds, - Signers, - AccountEntryExt, - AccountEntry, - TrustLineEntryExt, - TrustLineEntry, Price, - Void, - Int32, - OfferEntry, - String64, - DataValue, - DataEntry, - ExtensionPoint, - Hash, - VariableOpaque, - ContractCodeEntry, SCAddress, SCAddressType, SCVal, SCValType, - ContractDataEntry, - Ext + SequenceNumber, + Signer, + SignerKey, + SignerKeyType, + Signers, + String32, + String64, + Thresholds, + TrustLineAsset, + TrustLineEntry, + TrustLineEntryExt, + UInt256, + UInt32, + VariableOpaque, + Void } alias StellarBase.StrKey @@ -120,12 +119,13 @@ defmodule StellarBase.XDR.LedgerEntryDataTest do ## ContractCodeEntry - extension_point = ExtensionPoint.new(Void.new(), 0) + extension_contract_code_entry = ContractCodeEntryExt.new(Void.new(), 0) hash = Hash.new("GCIZ3GSM5XL7OUS4UP64THMDZ7CZ3ZWN") code = VariableOpaque.new("GCIZ3GSM5") ## ContractDataEntry + extension_point = ExtensionPoint.new(Void.new(), 0) address = Hash.new("CAWIIZPXNRY7X3FKFO4CWJT5DQOSEXQK") durability = ContractDataDurability.new() @@ -205,7 +205,7 @@ defmodule StellarBase.XDR.LedgerEntryDataTest do }, %{ type: LedgerEntryType.new(:CONTRACT_CODE), - ledger_entry_data: ContractCodeEntry.new(extension_point, hash, code), + ledger_entry_data: ContractCodeEntry.new(extension_contract_code_entry, hash, code), binary: <<0, 0, 0, 7, 0, 0, 0, 0, 71, 67, 73, 90, 51, 71, 83, 77, 53, 88, 76, 55, 79, 85, 83, 52, 85, 80, 54, 52, 84, 72, 77, 68, 90, 55, 67, 90, 51, 90, 87, 78, 0, 0, 0, 9, 71,