Skip to content

Commit

Permalink
Support stable Protocol 20 release (#296)
Browse files Browse the repository at this point in the history
* Support stellar contract config settings

Co-authored-by: norn <[email protected]>

* Support stellar contract

Co-authored-by: norn <[email protected]>

* Support stellar ledger entries
and update file names

Co-authored-by: norn <[email protected]>

* Support stellar transaction

Co-authored-by: norn <[email protected]>

* Review with xdrgen

---------

Co-authored-by: norn <[email protected]>
Co-authored-by: Kelium Jojoa Urrutia <[email protected]>
  • Loading branch information
3 people authored Oct 26, 2023
1 parent ec256f5 commit 849841e
Show file tree
Hide file tree
Showing 38 changed files with 609 additions and 613 deletions.
6 changes: 3 additions & 3 deletions lib/xdr/contract/config_setting/config_setting_entry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule StellarBase.XDR.ConfigSettingEntry do
ConfigSettingContractEventsV0,
ConfigSettingContractBandwidthV0,
ContractCostParams,
StateExpirationSettings,
StateArchivalSettings,
ConfigSettingContractExecutionLanesV0,
UInt64List,
EvictionIterator
Expand All @@ -36,7 +36,7 @@ defmodule StellarBase.XDR.ConfigSettingEntry do
CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES: ContractCostParams,
CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES: UInt32,
CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: UInt32,
CONFIG_SETTING_STATE_EXPIRATION: StateExpirationSettings,
CONFIG_SETTING_STATE_ARCHIVAL: StateArchivalSettings,
CONFIG_SETTING_CONTRACT_EXECUTION_LANES: ConfigSettingContractExecutionLanesV0,
CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: UInt64List,
CONFIG_SETTING_EVICTION_ITERATOR: EvictionIterator
Expand All @@ -50,7 +50,7 @@ defmodule StellarBase.XDR.ConfigSettingEntry do
| ConfigSettingContractEventsV0.t()
| ConfigSettingContractBandwidthV0.t()
| ContractCostParams.t()
| StateExpirationSettings.t()
| StateArchivalSettings.t()
| ConfigSettingContractExecutionLanesV0.t()
| UInt64List.t()
| EvictionIterator.t()
Expand Down
2 changes: 1 addition & 1 deletion lib/xdr/contract/config_setting/config_setting_id.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule StellarBase.XDR.ConfigSettingID do
CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES: 7,
CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES: 8,
CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: 9,
CONFIG_SETTING_STATE_EXPIRATION: 10,
CONFIG_SETTING_STATE_ARCHIVAL: 10,
CONFIG_SETTING_CONTRACT_EXECUTION_LANES: 11,
CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: 12,
CONFIG_SETTING_EVICTION_ITERATOR: 13
Expand Down
49 changes: 22 additions & 27 deletions lib/xdr/contract/config_setting/contract_cost_type.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,28 @@ defmodule StellarBase.XDR.ContractCostType do

@declarations [
WasmInsnExec: 0,
WasmMemAlloc: 1,
HostMemAlloc: 2,
HostMemCpy: 3,
HostMemCmp: 4,
DispatchHostFunction: 5,
VisitObject: 6,
ValSer: 7,
ValDeser: 8,
ComputeSha256Hash: 9,
ComputeEd25519PubKey: 10,
MapEntry: 11,
VecEntry: 12,
VerifyEd25519Sig: 13,
VmMemRead: 14,
VmMemWrite: 15,
VmInstantiation: 16,
VmCachedInstantiation: 17,
InvokeVmFunction: 18,
ComputeKeccak256Hash: 19,
ComputeEcdsaSecp256k1Key: 20,
ComputeEcdsaSecp256k1Sig: 21,
RecoverEcdsaSecp256k1Key: 22,
Int256AddSub: 23,
Int256Mul: 24,
Int256Div: 25,
Int256Pow: 26,
Int256Shift: 27
MemAlloc: 1,
MemCpy: 2,
MemCmp: 3,
DispatchHostFunction: 4,
VisitObject: 5,
ValSer: 6,
ValDeser: 7,
ComputeSha256Hash: 8,
ComputeEd25519PubKey: 9,
VerifyEd25519Sig: 10,
VmInstantiation: 11,
VmCachedInstantiation: 12,
InvokeVmFunction: 13,
ComputeKeccak256Hash: 14,
ComputeEcdsaSecp256k1Sig: 15,
RecoverEcdsaSecp256k1Key: 16,
Int256AddSub: 17,
Int256Mul: 18,
Int256Div: 19,
Int256Pow: 20,
Int256Shift: 21,
ChaCha20DrawBytes: 22
]

@enum_spec %XDR.Enum{declarations: @declarations, identifier: nil}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
defmodule StellarBase.XDR.StateExpirationSettings do
defmodule StellarBase.XDR.StateArchivalSettings 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 `StateExpirationSettings` type.
Representation of Stellar `StateArchivalSettings` type.
"""

@behaviour XDR.Declaration
Expand All @@ -17,104 +17,104 @@ defmodule StellarBase.XDR.StateExpirationSettings do
}

@struct_spec XDR.Struct.new(
max_entry_expiration: UInt32,
min_temp_entry_expiration: UInt32,
min_persistent_entry_expiration: UInt32,
max_entry_ttl: UInt32,
min_temporary_ttl: UInt32,
min_persistent_ttl: UInt32,
persistent_rent_rate_denominator: Int64,
temp_rent_rate_denominator: Int64,
max_entries_to_expire: UInt32,
max_entries_to_archive: UInt32,
bucket_list_size_window_sample_size: UInt32,
eviction_scan_size: UInt64,
starting_eviction_scan_level: UInt32
)

@type max_entry_expiration_type :: UInt32.t()
@type min_temp_entry_expiration_type :: UInt32.t()
@type min_persistent_entry_expiration_type :: UInt32.t()
@type max_entry_ttl_type :: UInt32.t()
@type min_temporary_ttl_type :: UInt32.t()
@type min_persistent_ttl_type :: UInt32.t()
@type persistent_rent_rate_denominator_type :: Int64.t()
@type temp_rent_rate_denominator_type :: Int64.t()
@type max_entries_to_expire_type :: UInt32.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 starting_eviction_scan_level_type :: UInt32.t()

@type t :: %__MODULE__{
max_entry_expiration: max_entry_expiration_type(),
min_temp_entry_expiration: min_temp_entry_expiration_type(),
min_persistent_entry_expiration: min_persistent_entry_expiration_type(),
max_entry_ttl: max_entry_ttl_type(),
min_temporary_ttl: min_temporary_ttl_type(),
min_persistent_ttl: min_persistent_ttl_type(),
persistent_rent_rate_denominator: persistent_rent_rate_denominator_type(),
temp_rent_rate_denominator: temp_rent_rate_denominator_type(),
max_entries_to_expire: max_entries_to_expire_type(),
max_entries_to_archive: max_entries_to_archive_type(),
bucket_list_size_window_sample_size: bucket_list_size_window_sample_size_type(),
eviction_scan_size: eviction_scan_size_type(),
starting_eviction_scan_level: starting_eviction_scan_level_type()
}

defstruct [
:max_entry_expiration,
:min_temp_entry_expiration,
:min_persistent_entry_expiration,
:max_entry_ttl,
:min_temporary_ttl,
:min_persistent_ttl,
:persistent_rent_rate_denominator,
:temp_rent_rate_denominator,
:max_entries_to_expire,
:max_entries_to_archive,
:bucket_list_size_window_sample_size,
:eviction_scan_size,
:starting_eviction_scan_level
]

@spec new(
max_entry_expiration :: max_entry_expiration_type(),
min_temp_entry_expiration :: min_temp_entry_expiration_type(),
min_persistent_entry_expiration :: min_persistent_entry_expiration_type(),
max_entry_ttl :: max_entry_ttl_type(),
min_temporary_ttl :: min_temporary_ttl_type(),
min_persistent_ttl :: min_persistent_ttl_type(),
persistent_rent_rate_denominator :: persistent_rent_rate_denominator_type(),
temp_rent_rate_denominator :: temp_rent_rate_denominator_type(),
max_entries_to_expire :: max_entries_to_expire_type(),
max_entries_to_archive :: max_entries_to_archive_type(),
bucket_list_size_window_sample_size :: bucket_list_size_window_sample_size_type(),
eviction_scan_size :: eviction_scan_size_type(),
starting_eviction_scan_level :: starting_eviction_scan_level_type()
) :: t()
def new(
%UInt32{} = max_entry_expiration,
%UInt32{} = min_temp_entry_expiration,
%UInt32{} = min_persistent_entry_expiration,
%UInt32{} = max_entry_ttl,
%UInt32{} = min_temporary_ttl,
%UInt32{} = min_persistent_ttl,
%Int64{} = persistent_rent_rate_denominator,
%Int64{} = temp_rent_rate_denominator,
%UInt32{} = max_entries_to_expire,
%UInt32{} = max_entries_to_archive,
%UInt32{} = bucket_list_size_window_sample_size,
%UInt64{} = eviction_scan_size,
%UInt32{} = starting_eviction_scan_level
),
do: %__MODULE__{
max_entry_expiration: max_entry_expiration,
min_temp_entry_expiration: min_temp_entry_expiration,
min_persistent_entry_expiration: min_persistent_entry_expiration,
max_entry_ttl: max_entry_ttl,
min_temporary_ttl: min_temporary_ttl,
min_persistent_ttl: min_persistent_ttl,
persistent_rent_rate_denominator: persistent_rent_rate_denominator,
temp_rent_rate_denominator: temp_rent_rate_denominator,
max_entries_to_expire: max_entries_to_expire,
max_entries_to_archive: max_entries_to_archive,
bucket_list_size_window_sample_size: bucket_list_size_window_sample_size,
eviction_scan_size: eviction_scan_size,
starting_eviction_scan_level: starting_eviction_scan_level
}

@impl true
def encode_xdr(%__MODULE__{
max_entry_expiration: max_entry_expiration,
min_temp_entry_expiration: min_temp_entry_expiration,
min_persistent_entry_expiration: min_persistent_entry_expiration,
max_entry_ttl: max_entry_ttl,
min_temporary_ttl: min_temporary_ttl,
min_persistent_ttl: min_persistent_ttl,
persistent_rent_rate_denominator: persistent_rent_rate_denominator,
temp_rent_rate_denominator: temp_rent_rate_denominator,
max_entries_to_expire: max_entries_to_expire,
max_entries_to_archive: max_entries_to_archive,
bucket_list_size_window_sample_size: bucket_list_size_window_sample_size,
eviction_scan_size: eviction_scan_size,
starting_eviction_scan_level: starting_eviction_scan_level
}) do
[
max_entry_expiration: max_entry_expiration,
min_temp_entry_expiration: min_temp_entry_expiration,
min_persistent_entry_expiration: min_persistent_entry_expiration,
max_entry_ttl: max_entry_ttl,
min_temporary_ttl: min_temporary_ttl,
min_persistent_ttl: min_persistent_ttl,
persistent_rent_rate_denominator: persistent_rent_rate_denominator,
temp_rent_rate_denominator: temp_rent_rate_denominator,
max_entries_to_expire: max_entries_to_expire,
max_entries_to_archive: max_entries_to_archive,
bucket_list_size_window_sample_size: bucket_list_size_window_sample_size,
eviction_scan_size: eviction_scan_size,
starting_eviction_scan_level: starting_eviction_scan_level
Expand All @@ -125,23 +125,23 @@ defmodule StellarBase.XDR.StateExpirationSettings do

@impl true
def encode_xdr!(%__MODULE__{
max_entry_expiration: max_entry_expiration,
min_temp_entry_expiration: min_temp_entry_expiration,
min_persistent_entry_expiration: min_persistent_entry_expiration,
max_entry_ttl: max_entry_ttl,
min_temporary_ttl: min_temporary_ttl,
min_persistent_ttl: min_persistent_ttl,
persistent_rent_rate_denominator: persistent_rent_rate_denominator,
temp_rent_rate_denominator: temp_rent_rate_denominator,
max_entries_to_expire: max_entries_to_expire,
max_entries_to_archive: max_entries_to_archive,
bucket_list_size_window_sample_size: bucket_list_size_window_sample_size,
eviction_scan_size: eviction_scan_size,
starting_eviction_scan_level: starting_eviction_scan_level
}) do
[
max_entry_expiration: max_entry_expiration,
min_temp_entry_expiration: min_temp_entry_expiration,
min_persistent_entry_expiration: min_persistent_entry_expiration,
max_entry_ttl: max_entry_ttl,
min_temporary_ttl: min_temporary_ttl,
min_persistent_ttl: min_persistent_ttl,
persistent_rent_rate_denominator: persistent_rent_rate_denominator,
temp_rent_rate_denominator: temp_rent_rate_denominator,
max_entries_to_expire: max_entries_to_expire,
max_entries_to_archive: max_entries_to_archive,
bucket_list_size_window_sample_size: bucket_list_size_window_sample_size,
eviction_scan_size: eviction_scan_size,
starting_eviction_scan_level: starting_eviction_scan_level
Expand All @@ -158,25 +158,25 @@ defmodule StellarBase.XDR.StateExpirationSettings do
{:ok,
{%XDR.Struct{
components: [
max_entry_expiration: max_entry_expiration,
min_temp_entry_expiration: min_temp_entry_expiration,
min_persistent_entry_expiration: min_persistent_entry_expiration,
max_entry_ttl: max_entry_ttl,
min_temporary_ttl: min_temporary_ttl,
min_persistent_ttl: min_persistent_ttl,
persistent_rent_rate_denominator: persistent_rent_rate_denominator,
temp_rent_rate_denominator: temp_rent_rate_denominator,
max_entries_to_expire: max_entries_to_expire,
max_entries_to_archive: max_entries_to_archive,
bucket_list_size_window_sample_size: bucket_list_size_window_sample_size,
eviction_scan_size: eviction_scan_size,
starting_eviction_scan_level: starting_eviction_scan_level
]
}, rest}} ->
{:ok,
{new(
max_entry_expiration,
min_temp_entry_expiration,
min_persistent_entry_expiration,
max_entry_ttl,
min_temporary_ttl,
min_persistent_ttl,
persistent_rent_rate_denominator,
temp_rent_rate_denominator,
max_entries_to_expire,
max_entries_to_archive,
bucket_list_size_window_sample_size,
eviction_scan_size,
starting_eviction_scan_level
Expand All @@ -193,25 +193,25 @@ defmodule StellarBase.XDR.StateExpirationSettings do
def decode_xdr!(bytes, struct) do
{%XDR.Struct{
components: [
max_entry_expiration: max_entry_expiration,
min_temp_entry_expiration: min_temp_entry_expiration,
min_persistent_entry_expiration: min_persistent_entry_expiration,
max_entry_ttl: max_entry_ttl,
min_temporary_ttl: min_temporary_ttl,
min_persistent_ttl: min_persistent_ttl,
persistent_rent_rate_denominator: persistent_rent_rate_denominator,
temp_rent_rate_denominator: temp_rent_rate_denominator,
max_entries_to_expire: max_entries_to_expire,
max_entries_to_archive: max_entries_to_archive,
bucket_list_size_window_sample_size: bucket_list_size_window_sample_size,
eviction_scan_size: eviction_scan_size,
starting_eviction_scan_level: starting_eviction_scan_level
]
}, rest} = XDR.Struct.decode_xdr!(bytes, struct)

{new(
max_entry_expiration,
min_temp_entry_expiration,
min_persistent_entry_expiration,
max_entry_ttl,
min_temporary_ttl,
min_persistent_ttl,
persistent_rent_rate_denominator,
temp_rent_rate_denominator,
max_entries_to_expire,
max_entries_to_archive,
bucket_list_size_window_sample_size,
eviction_scan_size,
starting_eviction_scan_level
Expand Down
2 changes: 1 addition & 1 deletion lib/xdr/contract/contract_executable.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule StellarBase.XDR.ContractExecutable do

@arms [
CONTRACT_EXECUTABLE_WASM: Hash,
CONTRACT_EXECUTABLE_TOKEN: Void
CONTRACT_EXECUTABLE_STELLAR_ASSET: Void
]

@type value ::
Expand Down
2 changes: 1 addition & 1 deletion lib/xdr/contract/contract_executable_type.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule StellarBase.XDR.ContractExecutableType do

@declarations [
CONTRACT_EXECUTABLE_WASM: 0,
CONTRACT_EXECUTABLE_TOKEN: 1
CONTRACT_EXECUTABLE_STELLAR_ASSET: 1
]

@enum_spec %XDR.Enum{declarations: @declarations, identifier: nil}
Expand Down
Loading

0 comments on commit 849841e

Please sign in to comment.