Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sorobaninfo basic more consistent with underlying network settings #4216

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MonsieurNicolas
Copy link
Contributor

The default output of sorobaninfo (aka "basic") uses custom names that don't correspond to what is xdr (making it hard to know which setting is what, and also creates a maintenance burden) and is also missing information on ledger fee related settings.

This PR aims to simplify code and address both issues.

Old output:

{
   "fee_contract_events_size_1kb" : 10000,
   "fee_historical_1kb" : 16235,
   "fee_rate_per_instructions_increment" : 25,
   "fee_read_1kb" : 1786,
   "fee_read_ledger_entry" : 6250,
   "fee_transaction_size_1kb" : 1624,
   "fee_write_1kb" : 1000,
   "fee_write_ledger_entry" : 10000,
   "ledger" : {
      "max_instructions" : 100000000,
      "max_read_bytes" : 133120,
      "max_read_ledger_entries" : 40,
      "max_tx_count" : 100,
      "max_tx_size_bytes" : 71680,
      "max_write_bytes" : 66560,
      "max_write_ledger_entries" : 25
   },
   "max_contract_data_entry_size" : 65536,
   "max_contract_data_key_size" : 200,
   "max_contract_size" : 65536,
   "state_archival" : {
      "average_bucket_list_size" : 10285954422,
      "bucket_list_size_snapshot_period" : 30,
      "bucketlist_size_window_sample_size" : 30,
      "eviction_scan_size" : 100000,
      "max_entries_to_archive" : 1000,
      "max_entry_ttl" : 3110400,
      "min_persistent_ttl" : 2073600,
      "min_temporary_ttl" : 17280,
      "persistent_rent_rate_denominator" : 1402,
      "starting_eviction_scan_level" : 7,
      "temp_rent_rate_denominator" : 2804
   },
   "tx" : {
      "max_contract_events_size_bytes" : 8198,
      "max_instructions" : 100000000,
      "max_read_bytes" : 133120,
      "max_read_ledger_entries" : 40,
      "max_size_bytes" : 71680,
      "max_write_bytes" : 66560,
      "max_write_ledger_entries" : 25,
      "memory_limit" : 41943040
   }
}

New:

{
    "ConfigSettingsEntries": [
        {
            "configSettingID": 0,
            "contractMaxSizeBytes": 65536
        },
        {
            "configSettingID": 1,
            "contractCompute": {
                "ledgerMaxInstructions": 100000000,
                "txMaxInstructions": 100000000,
                "feeRatePerInstructionsIncrement": 25,
                "txMemoryLimit": 41943040
            }
        },
        {
            "configSettingID": 2,
            "contractLedgerCost": {
                "ledgerMaxReadLedgerEntries": 40,
                "ledgerMaxReadBytes": 133120,
                "ledgerMaxWriteLedgerEntries": 25,
                "ledgerMaxWriteBytes": 66560,
                "txMaxReadLedgerEntries": 40,
                "txMaxReadBytes": 133120,
                "txMaxWriteLedgerEntries": 25,
                "txMaxWriteBytes": 66560,
                "feeReadLedgerEntry": 6250,
                "feeWriteLedgerEntry": 10000,
                "feeRead1KB": 1786,
                "bucketListTargetSizeBytes": 13000000000,
                "writeFee1KBBucketListLow": -1234673,
                "writeFee1KBBucketListHigh": 115390,
                "bucketListWriteFeeGrowthFactor": 1000
            }
        },
        {
            "configSettingID": 3,
            "contractHistoricalData": {
                "feeHistorical1KB": 16235
            }
        },
        {
            "configSettingID": 4,
            "contractEvents": {
                "txMaxContractEventsSizeBytes": 8198,
                "feeContractEvents1KB": 10000
            }
        },
        {
            "configSettingID": 5,
            "contractBandwidth": {
                "ledgerMaxTxsSizeBytes": 71680,
                "txMaxSizeBytes": 71680,
                "feeTxSize1KB": 1624
            }
        },
        {
            "configSettingID": 8,
            "contractDataKeySizeBytes": 200
        },
        {
            "configSettingID": 9,
            "contractDataEntrySizeBytes": 65536
        },
        {
            "configSettingID": 10,
            "stateArchivalSettings": {
                "maxEntryTTL": 3110400,
                "minTemporaryTTL": 17280,
                "minPersistentTTL": 2073600,
                "persistentRentRateDenominator": 1402,
                "tempRentRateDenominator": 2804,
                "maxEntriesToArchive": 1000,
                "bucketListSizeWindowSampleSize": 30,
                "bucketListWindowSamplePeriod": 64,
                "evictionScanSize": 100000,
                "startingEvictionScanLevel": 7
            }
        },
        {
            "configSettingID": 11,
            "contractExecutionLanes": {
                "ledgerMaxTxCount": 100
            }
        }
    ]
}

It's a bit annoying that our default json marshaller does not use strings for enum values (unlike when using xdrpp/printer.h but that one is not json compliant), but as fields are already unique it does not seem to be much of a problem.

I think supercluster needs to be updated if we decide to merge this.

@MonsieurNicolas
Copy link
Contributor Author

It looks like the way to extract fields in F# would be done like this @SirTyson :

open FSharp.Data

type ConfigSettings = JsonProvider<"""{
    "ConfigSettingsEntries": [
        ...
    ]
}""">

let json = """{
    "ConfigSettingsEntries": [
        ...
    ]
}""" // Your JSON string goes here

let configSettings = ConfigSettings.Parse(json)

let ledgerMaxReadBytes =
    configSettings.ConfigSettingsEntries
    |> Seq.tryPick (fun entry ->
        match entry.TryGetProperty("contractLedgerCost") with
        | Some(ledgerCost) -> ledgerCost.TryGetProperty("ledgerMaxReadBytes")
        | None -> None
    )

match ledgerMaxReadBytes with
| Some(value) -> printfn "The ledgerMaxReadBytes is: %A" value
| None -> printfn "The field 'ledgerMaxReadBytes' was not found."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant