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

Using a config file #75

Closed
wants to merge 33 commits into from
Closed

Using a config file #75

wants to merge 33 commits into from

Conversation

ryukzak
Copy link
Contributor

@ryukzak ryukzak commented Mar 11, 2022

Serialization, deserialization, and config description for PABConfig. If nothing is presented -- use default values.

Configuration description:

Prelude BotPlutusInterface.Config> putStrLn docPABConfig
Top-level configuration file fields:
    cliLocation: `local` or destination text
        calling the cli through ssh when set to destination (default:
        local)
    chainIndexUrl: url text
         (default: "http://localhost:9083")
    networkId: `mainnet` or 32-bit unsigned integral number
         (default: 42)
    slotConfig: SlotConfig configuration
         (see default in example)
    scriptFileDir: path text
        Directory name of the script and data files (default:
        "./result-scripts")
    signingKeyFileDir: path text
        Directory name of the signing key files (default: "./signing-keys")
    txFileDir: path text
        Directory name of the transaction files (default: "./txs")
    protocolParamsFile: filepath text
        Protocol params file location relative to the cardano-cli working
        directory (needed for the cli) in JSON format.  (default:
        "./protocol.json")
    dryRun: `true` or `false`
        Dry run mode will build the tx, but skip the submit step (default:
        true)
    logLevel: `error` or `warn` or `notice` or `info` or `debug`
         (default: info)
    ownPubKeyHash: PubKeyHash text
         (default: "")
    tipPollingInterval: non-negative integral number
         (default: 10000000)
    port: port non-negative integral number
         (default: 9080)
    enableTxEndpoint: `true` or `false`
         (default: false)

SlotConfig configuration
    length: REQUIRED integral number
        Length (number of milliseconds) of one slot
    zeroTime: REQUIRED integral number
        Beginning of slot 0 (in milliseconds)

Default configuration:

cliLocation:   local
chainIndexUrl: "http://localhost:9083"
networkId:     42
slotConfig:
  length:   1000
  zeroTime: 1596059091000
scriptFileDir:      "./result-scripts"
signingKeyFileDir:  "./signing-keys"
txFileDir:          "./txs"
protocolParamsFile: "./protocol.json"
dryRun:             true
logLevel:           info
ownPubKeyHash:      ""
tipPollingInterval: 10000000
port:               9080
enableTxEndpoint:   false
{
    "maxValueSize": 5000,
    "minUTxOValue": null,
    "minPoolCost": 340000000,
    "monetaryExpansion": 3.0e-3,
    "stakeAddressDeposit": 2000000,
    "txFeeFixed": 155381,
    "poolRetireMaxEpoch": 18,
    "stakePoolDeposit": 500000000,
    "maxBlockExecutionUnits": {
        "memory": 500000000000,
        "steps": 500000000000
    },
    "extraPraosEntropy": null,
    "stakePoolTargetNum": 150,
    "maxBlockHeaderSize": 1100,
    "maxCollateralInputs": 5,
    "txFeePerByte": 44,
    "treasuryCut": 0.2,
    "protocolVersion": {
        "minor": 0,
        "major": 5
    },
    "collateralPercentage": 1,
    "poolPledgeInfluence": 0.3,
    "costModels": {
        "PlutusScriptV1": {
            "cek_apply_cost-_ex_budget_cpu": 39000,
            "greater_than_eq_integer-memory-arguments": 1,
            "subtract_integer-memory-arguments-intercept": 1,
            "cek_lam_cost-_ex_budget_memory": 10,
            "lt_byte_string-memory-arguments": 1,
            "add_integer-cpu-arguments-slope": 1722,
            "quotient_integer-memory-arguments-intercept": 0,
            "quotient_integer-memory-arguments-slope": 1,
            "cek_const_cost-_ex_budget_cpu": 39000,
            "add_integer-cpu-arguments-intercept": 235735,
            "cek_delay_cost-_ex_budget_cpu": 39000,
            "verify_signature-cpu-arguments": 5082989,
            "concatenate-memory-arguments-slope": 1,
            "greater_than_integer-cpu-arguments-slope": 980,
            "multiply_integer-cpu-arguments-slope": 11464,
            "sha3-cpu-arguments-slope": 81356,
            "divide_integer-cpu-arguments-model_split_const_intercept": 330895,
            "gt_byte_string-memory-arguments": 1,
            "cek_delay_cost-_ex_budget_memory": 10,
            "subtract_integer-cpu-arguments-intercept": 251934,
            "divide_integer-memory-arguments-minimum": 1,
            "less_than_eq_integer-memory-arguments": 1,
            "cek_var_cost-_ex_budget_cpu": 39000,
            "cek_builtin_cost-_ex_budget_memory": 10,
            "sha2-cpu-arguments-slope": 28904,
            "less_than_eq_integer-cpu-arguments-intercept": 216015,
            "mod_integer-memory-arguments-intercept": 0,
            "lt_byte_string-cpu-arguments-slope": 227,
            "concatenate-cpu-arguments-intercept": 420084,
            "concatenate-cpu-arguments-slope": 515,
            "add_integer-memory-arguments-intercept": 1,
            "multiply_integer-memory-arguments-slope": 1,
            "less_than_integer-cpu-arguments-slope": 980,
            "mod_integer-cpu-arguments-model_split_const_slope": 427,
            "take_byte_string-memory-arguments": 20,
            "sha2-memory-arguments": 4,
            "cek_startup_cost-_ex_budget_cpu": 1000000,
            "cek_startup_cost-_ex_budget_memory": 0,
            "eq_byte_string-cpu-arguments-slope": 246,
            "less_than_integer-memory-arguments": 1,
            "divide_integer-memory-arguments-intercept": 0,
            "divide_integer-cpu-arguments-model_split_const_slope": 427,
            "subtract_integer-cpu-arguments-slope": 1194,
            "quotient_integer-cpu-arguments-model_split_const_intercept": 330895,
            "divide_integer-memory-arguments-slope": 1,
            "if_then_else-memory-arguments": 0,
            "eq_integer-cpu-arguments-slope": 867,
            "eq_integer-memory-arguments": 1,
            "less_than_integer-cpu-arguments-intercept": 187278,
            "cek_var_cost-_ex_budget_memory": 10,
            "if_then_else-cpu-arguments": 0,
            "cek_lam_cost-_ex_budget_cpu": 39000,
            "add_integer-memory-arguments-slope": 1,
            "sha3-memory-arguments": 4,
            "take_byte_string-cpu-arguments": 3420288,
            "lt_byte_string-cpu-arguments-intercept": 204537,
            "greater_than_eq_integer-cpu-arguments-intercept": 216015,
            "mod_integer-memory-arguments-slope": 1,
            "less_than_eq_integer-cpu-arguments-slope": 699,
            "sha2-cpu-arguments-intercept": 2267819,
            "mod_integer-memory-arguments-minimum": 1,
            "subtract_integer-memory-arguments-slope": 1,
            "eq_integer-cpu-arguments-intercept": 211716,
            "remainder_integer-memory-arguments-slope": 1,
            "eq_byte_string-memory-arguments": 1,
            "quotient_integer-cpu-arguments-model_split_const_slope": 427,
            "gt_byte_string-cpu-arguments-intercept": 204537,
            "drop_byte_string-memory-arguments": 2,
            "gt_byte_string-cpu-arguments-slope": 227,
            "cek_const_cost-_ex_budget_memory": 10,
            "sha3-cpu-arguments-intercept": 1260296,
            "remainder_integer-memory-arguments-intercept": 0,
            "greater_than_integer-memory-arguments": 1,
            "remainder_integer-cpu-arguments-model_split_const_intercept": 330895,
            "drop_byte_string-cpu-arguments": 3418326,
            "mod_integer-cpu-arguments-model_split_const_intercept": 330895,
            "cek_builtin_cost-_ex_budget_cpu": 39000,
            "multiply_integer-memory-arguments-intercept": 0,
            "greater_than_integer-cpu-arguments-intercept": 187278,
            "greater_than_eq_integer-cpu-arguments-slope": 699,
            "concatenate-memory-arguments-intercept": 0,
            "cek_force_cost-_ex_budget_cpu": 39000,
            "cek_apply_cost-_ex_budget_memory": 10,
            "remainder_integer-cpu-arguments-model_split_const_slope": 427,
            "verify_signature-memory-arguments": 1,
            "cek_force_cost-_ex_budget_memory": 10,
            "eq_byte_string-cpu-arguments-intercept": 188562,
            "multiply_integer-cpu-arguments-intercept": 78642
        }
    },
    "maxTxExecutionUnits": {
        "memory": 500000000000,
        "steps": 500000000000
    },
    "executionUnitPrices": {
        "priceSteps": 1,
        "priceMemory": 1
    },
    "decentralization": 0.6,
    "utxoCostPerWord": 1,
    "maxTxSize": 16384,
    "maxBlockBodySize": 65536
}

What left:

  • autogenerated help should be fixed
  • detail tests for not simple data
  • module restructuring

Future work:

  • The conflict between protocolParamsFile and protocolParams.
  • Extract BotPlutusInterface.Config.* in separated package.

@ryukzak
Copy link
Contributor Author

ryukzak commented Mar 16, 2022

Issue: the conflict between protocolParamsFile and protocolParams.

Current solution: ignoring. protocolParams maybe be overwritten by the data from protocolParamsFile manually in the external code.

The possible solution for another PR:

  1. Change protocolParamsFile from Text to Maybe Text. Defailt value: Nothing.
  2. Remove initialization of protocolParams outside of Config module.
  3. If protocolParams, protocolParamsFile
  • Nothing, Nothing -> use default protocolParams
  • Just, Nothing -> use protocolParams
  • Nothing, Just -> use data from protocolParamsFile
  • Just and Just -> get data from protocolParams, read data from protocolParamsFile, and warn in console if something overwrited.

@ryukzak ryukzak marked this pull request as ready for review March 16, 2022 12:16
Copy link
Contributor

@samuelWilliams99 samuelWilliams99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work here! Got a lot covered :)

Got quite a few imports here without explicit import lists/qualified - lets get those cleaned up

Also, just to be sure - if we have protocol params file defined, will the protocol params field be populated by reading the file?

@ryukzak
Copy link
Contributor Author

ryukzak commented Mar 21, 2022

In the current version - no, but I will fix it as I describe it here: #75 (comment)

After that, I would like to update examples to use a config file (only value format) and update readme.

@ryukzak ryukzak linked an issue Mar 28, 2022 that may be closed by this pull request
@ryukzak ryukzak mentioned this pull request Apr 8, 2022
@nazrhom
Copy link
Collaborator

nazrhom commented Jun 3, 2022

@ryukzak can we close this, is it superseded by #91 ?

@ryukzak ryukzak closed this Jun 3, 2022
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.

Using a config file
4 participants