MinaProtocol / mina

Mina is a cryptocurrency protocol with a constant size blockchain, improving scaling while maintaining decentralization and security.
https://minaprotocol.com
Apache License 2.0
1.99k stars 529 forks source link

Fix tooling to generate a test ledger #15898

Closed georgeee closed 3 days ago

georgeee commented 2 months ago

Update some scripts and runtime_genesis_ledger to be able to generate a runtime configuration for a custom testnet cluster.

Explain how you tested your changes:

Checklist:

georgeee commented 3 weeks ago

!ci-build-me

dkijania commented 3 weeks ago

Hey @georgeee. Thanks for fixing runtime_ledger_generator. I was trying to use it for my randomly generated ledger which looks like this:

{

    "ledger": {
    "accounts":[{"pk":"B62qrA2eWb592uRLtH5ohzQnx7WTLYp2jGirCw5M7Fb9gTf1RrvTPqX","sk":"EKDxCqQGa39sTxtecX4gRmw8MzpG3JB8ooL8uDNqE75sj2uegkuz","balance":"1000"},{"pk":"B62qpkCEM5N5ddVsYNbFtwWV4bsT9AwuUJXoehFhHUbYYvZ6j3fXt93","sk":"EKEhAjWjbtAyppEPYUMYaEBuLv2gfgbAMvX2uTbtS2AyMpEmMtGU","balance":"1000"},{"pk":"B62qp5sdhH48MurWgtHNkXUTphEmUfcKVmZFspYAqxcKZ7YxaPF1pyF","sk":"EKDsKYn9FHx541TcemCx1Y1r2E6K9fZpbXPrfkW6m3X9nrS18RHk","balance":"0"}],"num_accounts":3
    }
}

then i fired command:

$ _build/default/src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe --config-file ./genesis_ledger.config --genesis-dir genesis --hash-output-file hash.config --ignore-missing
(monitor.ml.Error (Failure "Wrong ledger supplied")
 ("Raised at Stdlib.failwith in file \"stdlib.ml\", line 29, characters 17-33"
  "Called from Dune__exe__Runtime_genesis_ledger.load_config_exn.(fun) in file \"src/app/runtime_genesis_ledger/runtime_genesis_ledger.ml\", line 117, characters 4-31"
  "Called from Async_kernel__Deferred1.M.map.(fun) in file \"src/deferred1.ml\", line 17, characters 40-45"
  "Called from Async_kernel__Job_queue.run_job in file \"src/job_queue.ml\" (inlined), line 128, characters 2-5"
  "Called from Async_kernel__Job_queue.run_jobs in file \"src/job_queue.ml\", line 169, characters 6-47"))

Do we expect such ledger to be correct input ?

georgeee commented 3 weeks ago

@dkijania ,"num_accounts":3 must be removed to make the ledger json valid

dkijania commented 3 weeks ago

Hey, I'm one step ahead but still failing:

DUNE_PROFILE=devnet dune exec src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe -- --config-file genesis_ledger.config --genesis-dir dir --hash-output-file ledger.hash --ignore-missing

then:

DUNE_PROFILE=devnet dune exec src/app/cli/src/mina.exe -- ledger test-apply --privkey-path keys/node-b-key --ledger-path dir --num-txs 1 --tracing

Output:

Init root jxHzqPEKtkAB9yo1YXcyoSJMisy7x5g9fzuJa1c95VoEqKhyNhJ
Error: (Option.value_exn src/app/cli/src/init/test_ledger_application.ml:95:32)

Is it something about ledger hash being different than in ledger.hash file:

{"ledger":{"s3_data_hash":"1b5e6e62a56075d7a06e76140700ba4a78ee97e817e2e2b10ba6c5ac7e74de36","hash":"jwGvhoN51m8rYayLS6GitcJFRvZ1ggGPFayEkuj23NCigicvGRB"},"epoch_data":{"staking":{"s3_data_hash":"48c929c630a63000d99373d858900fd1c95385869b966c1eeb0dedcc0842051c","hash":"jwGvhoN51m8rYayLS6GitcJFRvZ1ggGPFayEkuj23NCigicvGRB"},"next":{"s3_data_hash":"2522e1e34a4a74e902b1079f021b107b15b86177ac309d3605f1e26d4e110f12","hash":"jwGvhoN51m8rYayLS6GitcJFRvZ1ggGPFayEkuj23NCigicvGRB"}}}

?

georgeee commented 3 weeks ago

@dkijania looks like the sec ret key specified by --privkey-path keys/node-b-key is not in the ledger. Could you check if it's true?

dkijania commented 3 weeks ago

Yes, I checked since tool which dumps keys is also dumping public key.. could it be that signature is differently constructed?

dkijania commented 2 weeks ago

Let's use my example:

Key:

node-a-key.pub.txt node-a-key.txt

ledger:

genesis_ledger.config.txt

my commands (build with DUNE_PROFILE=devnet):

_build/default/src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe --config-file ./genesis_ledger.config --genesis-dir genesis --hash-output-file hash.config --ignore-missing

 _build/default/src/app/cli/src/mina.exe ledger test-apply --ledger-path genesis --privkey-path node-a-key.txt --num-txs 10
Enter password: 
Again to confirm: 
Init root jxHzqPEKtkAB9yo1YXcyoSJMisy7x5g9fzuJa1c95VoEqKhyNhJ
Error: (Option.value_exn src/app/cli/src/init/test_ledger_application.ml:95:32)
dkijania commented 3 days ago

I tested ii locally and it looks good

georgeee commented 3 days ago

!ci-build-me