-
Notifications
You must be signed in to change notification settings - Fork 547
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
[Part 1 of 2] Constants loader and Config loader #16186
Conversation
!ci-nightly-me |
!ci-nightly-me |
all important tests passing on nightlies |
16119d1
to
6d10813
Compare
src/app/cli/src/init/client.ml
Outdated
Runtime_config.Constants.compile_config conf | ||
in | ||
let fee = | ||
Option.value ~default:compile_config.default_transaction_fee fee |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit odd to me: we're adding a config file parameter just to extract a single number.
I reviewed usages of default_transaction_fee
in the codebase and it seems right to do the following:
- Remove
default_transaction_fee
from node config, compile config and everywhere else - For CLI flag defaults (only place where the values is used) just specify manual default
0.25
(this value is indevnet
andmainnet
, anddev
profile isn't really used for running CLI tools)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we could place 0.25
to unconfigurable constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specify manual default 0.25
I am noticing that in practice you can get away with a lot less: https://minascan.io/mainnet/txs/pending-txs
IMO the default fee should be based on what's in the mempool, and neither the old solution, my solution, nor suggested solutions stand out as amazing.
Can I suggest that we just leave it? Loading a config file is not a super high barrier at this point, and we can always use "sensible defaults" as part of the json parser.
Or we could place 0.25 to unconfigurable constants
These are eventually configurable anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the default fee should be based on what's in the mempool, and neither the old solution, my solution, nor suggested solutions stand out as amazing.
This is definitely for future.
Neither solution stands out as amazing, but hardcoding 0.25
as the default seems still better. It feels awkward to have a config file parameter to take only default fee for a command that has a fee argument as well. And no other command uses this default transaction fee value from the config.
So, I'm removing default transaction fee from all configs and hardcode the existing value.
ec99eb0
to
48603df
Compare
!ci-build-me |
!ci-nightly-me |
…onstants-loader-part-1
Value is only used in two CLI commands to supply the default value for transaction creation. Value is always 0.25 MINA (in lightnet, devnet, mainnet). It makes no sense to supply this value from config (fee can be set directly, so it was simply hardcoded to preserve existing behavior.
Remove default_transaction_fee from node config looks goood |
!ci-build-me |
!ci-nightly-me |
1 similar comment
!ci-nightly-me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK on the crypto side (not much crypto). The mappend/combine function is the most tricky one in my previous experience to get right. Eventually this should be tested by time, it's a bit hard to be fully convinced mentally that everything is OK when you do a merger of dozens of fields. Cool!
@@ -4,6 +4,10 @@ open Signature_lib | |||
open Mina_base | |||
open Mina_transaction | |||
|
|||
(* TODO consider a better way of setting a default transaction fee than | |||
a fixed compile-time value *) | |||
let default_transaction_fee = Currency.Fee.of_nanomina_int_exn 250000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this change was reviewed before by someone else (I see a previous discussion). Not crypto related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, @dkijania reviewed this one specifically
{ Genesis_constants.protocol = | ||
{ k = | ||
Option.value ~default:a.genesis_constants.protocol.k | ||
Option.(b.genesis >>= fun g -> g.k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offtop: doesn't ocaml have fmap
? Hmm... https://blog.janestreet.com/generic-mapping-and-folding-in-ocaml/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not fmap
though. fmap f x
is equivalent to x >>= return . f
, wherease here we don't have return
But yes, it's simply map
in OCaml parlance
|
||
let compile_config t = t.compile_config | ||
|
||
let combine (a : constants) (b : t) : constants = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will not block this PR because of the writing style, but couldn't this at least be left
and right
? conf_a
and conf_b
even? Our codebase has too much non-descriptive names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go for combine_constants
or mappend
to make it more precise that this is an associative overriding operation. It is associative, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here t
and constants
are different types, so no associativity.
As for name/docs: probably constants
and conf
would be better names, I'll make a short follow-up PR for the matter
|
||
let compile_config t = t.compile_config | ||
|
||
let combine (a : constants) (b : t) : constants = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, serious ocaml noob type of question: what is t
in the function type (b:t
)? I don't see any t
defined in scope, I assume it's also constants
... isn't it? Is it just an open polymorphic type of "anything that has fields that we access within combine
"?.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type t
is defined further above in the file, wasn't touched by the PR. Se line 1477
|
||
val compile_config : constants -> Mina_compile_config.t | ||
|
||
val magic_for_unit_tests : t -> constants |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can .... this have a documentation please? Or a more descriptive name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
This is quite unexpected, but This PR seemingly doesn't change anything that affects libp2p unit tests (only Go code and scripts could've affected that). So I'm not sure why does this happen. |
I was able to reproduce failure of I'll make a separate PR to alter timeouts in |
NOTE to reviewer
All of the important changes in this PR are in
runtime_config.ml
andgenesis_ledger_helper.ml
, start there. You will see that all other changes are switching an executable to use these newload
methods, and it always looks the same.Background
In previous work we removed all/as much direct access to
*_constants.Compiled.t
as possible throughout the codebase (with the exception being theFor_unit_tests
variant). We were able to push those all the way to the various executable entrypoints, but we were still using the compiled config directlyThe problem
Mina_cli_entrypoint
and a few other executables allow you to take a--config-file
parameter and apply the json config to the compile time constants. Most executables do not allow this.Most executables only requires the
constants
config, so we don't want to require the aboveconfig
type in places where no ledger is required. We need to separate these cases in the type system.The Solution
Runtime_config.Constants
module to manage theconstants
type above and manage loading and applying the json config file for these values.Genesis_ledger_helper.Config_loader
module to manage loading runtime config that is needed for theledger
.src/lib
andMina_cli_executable
uses these new loaders exclusively.--config-file
option to CLI contexts, or create this context it if it didn't exist before