From 6645cc3062d95aef892bcbe75d765ea915086c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Santos=20Reis?= Date: Fri, 19 Jan 2024 17:34:41 +0000 Subject: [PATCH 1/9] Return sync_status.synced value on /network/status --- src/app/rosetta/lib/network.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/rosetta/lib/network.ml b/src/app/rosetta/lib/network.ml index 90ab3e39ae2..37911e5cb12 100644 --- a/src/app/rosetta/lib/network.ml +++ b/src/app/rosetta/lib/network.ml @@ -75,6 +75,14 @@ let sync_status_to_string = function | `SYNCED -> "Synced" +let is_synced = function + | `SYNCED -> true + | `BOOTSTRAP + | `CATCHUP + | `CONNECTING + | `LISTENING + | `OFFLINE -> false + module Get_version = [%graphql {| @@ -239,7 +247,7 @@ module Status = struct Some ((latest_node_block.protocolState).consensusState).blockHeight ; target_index= None ; stage= Some (sync_status_to_string res.syncStatus) - ; synced = None + ; synced = (Some (is_synced res.syncStatus)) } } end From a87cfb6935fd6d68d56712da1c086a2c1a0a964f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Santos=20Reis?= Date: Fri, 19 Jan 2024 21:19:17 +0000 Subject: [PATCH 2/9] Improve Rosetta DSL logic. Update rosetta-cli config and README --- src/app/rosetta/rosetta-cli-config/README.md | 6 +- .../rosetta/rosetta-cli-config/config.json | 6 +- .../mina-no-delegation-test.ros | 104 +++-- .../mina-with-return-funds.ros | 368 ++++++++++++++++++ src/app/rosetta/rosetta-cli-config/mina.ros | 199 +++++++--- 5 files changed, 591 insertions(+), 92 deletions(-) create mode 100644 src/app/rosetta/rosetta-cli-config/mina-with-return-funds.ros diff --git a/src/app/rosetta/rosetta-cli-config/README.md b/src/app/rosetta/rosetta-cli-config/README.md index 70dce29d121..d82f4963949 100644 --- a/src/app/rosetta/rosetta-cli-config/README.md +++ b/src/app/rosetta/rosetta-cli-config/README.md @@ -116,12 +116,12 @@ is specified in the `config.json`, in `data` section (see the example mentioned above). For example an end condition: `"index": 50` will make `rosetta-cli to check first 50 blocks. -**IMPORTANT** as of version 0.8.2 of `rosetta-sdk-go`, rosetta-cli +**IMPORTANT** as of version 0.8.3 of `rosetta-sdk-go`, rosetta-cli is unable to run the `mina.ros` file, which will only work with [Mina Foundation's fork](https://github.com/MinaProtocol/rosetta-sdk-go/tree/pallas_signer_stake_delegation). Therefore, whenever it is required to run the Construction API -tests against v.0.8.2 of `rosetta-sdk-go`, `mina-no-delegation-tests.ros` +tests against v.0.8.3 of `rosetta-sdk-go`, `mina-no-delegation-tests.ros` config should be used for that instead of `mina.ros`, which is used -in the CI. `mina-no-delegation-tests.ros` should be deleted once +in the CI. In alternative, one can also use [our `rosetta-cli` fork](https://github.com/MinaProtocol/rosetta-cli) which is built against our fork of `rosetta-sdk-go`. `mina-no-delegation-tests.ros` should be deleted once [PR #464](https://github.com/coinbase/rosetta-sdk-go/pull/464) to `rosetta-sdk-go` is merged. diff --git a/src/app/rosetta/rosetta-cli-config/config.json b/src/app/rosetta/rosetta-cli-config/config.json index cbf9cacdf10..38e80425747 100644 --- a/src/app/rosetta/rosetta-cli-config/config.json +++ b/src/app/rosetta/rosetta-cli-config/config.json @@ -5,7 +5,7 @@ }, "online_url": "http://localhost:PLACEHOLDER_ROSETTA_ONLINE_PORT", "data_directory": "", - "http_timeout": 10, + "http_timeout": 300, "max_retries": 5, "retry_elapsed_time": 0, "max_online_connections": 120, @@ -47,8 +47,8 @@ "initial_balance_fetch_disabled": false, "end_conditions": { "create_account": 10, - "transfer_payment": 20, - "transfer_delegation": 5 + "payment": 20, + "delegation": 5 } }, "data": { diff --git a/src/app/rosetta/rosetta-cli-config/mina-no-delegation-test.ros b/src/app/rosetta/rosetta-cli-config/mina-no-delegation-test.ros index 5dbc7df5a1c..c1e9d616f48 100644 --- a/src/app/rosetta/rosetta-cli-config/mina-no-delegation-test.ros +++ b/src/app/rosetta/rosetta-cli-config/mina-no-delegation-test.ros @@ -1,11 +1,10 @@ -// This is the version of the Construction API tests does not test -// stake delegation, which cannot be tested with rosetta-sdk-go as -// of v. 0.8.2. - // Workflow used to create new accounts create_account(1){ create{ - network = {"network":"debug", "blockchain":"mina"}; + network = { + "network":"berkeley-ITN", + "blockchain":"mina" + }; key = generate_key({"curve_type": "pallas"}); account = derive({ "network_identifier": {{network}}, @@ -21,31 +20,32 @@ create_account(1){ } // Workflow used to generate payment transactions -transfer(10){ - transfer{ - transfer.network = {"network":"debug", "blockchain":"mina"}; - currency = {"symbol":"MINA", "decimals":9}; +payment(10){ + payment_dry_run{ + payment_dry_run.network = { + "network":"berkeley-ITN", + "blockchain":"mina" + }; + + currency = { + "symbol":"MINA", + "decimals":9 + }; + + max_fee = "4000000000"; // no less than 1 MINA + 1 MINA (account creation fee) + max_recipient_value = "100000000000"; // 100 MINA + min_required_value = {{max_recipient_value}} + {{max_fee}}; + sender = find_balance({ "minimum_balance":{ - "value": "20000000000", + "value": {{min_required_value}}, "currency": {{currency}} } }); - // The fee must be at least the creation fee of the account if it - // did not exist before the transaction - max_fee = "4000000000"; - min_fee = "2000000000"; - - // We limit the amount to genereate multiple transactions with the - // same prefunded account - available_amount = "6000000000"; + recipient_amount = random_number({"minimum": "1", "maximum": {{max_recipient_value}}}); + print_message({"recipient_amount":{{recipient_amount}}}); - // Find recipient and construct operations - recipient_amount = random_number({"minimum": {{max_fee}}, "maximum": {{available_amount}}}); - sender_amount = 0 - {{recipient_amount}}; - fee = random_number({"minimum": {{min_fee}}, "maximum": {{max_fee}}}); - minus_fee = 0 - {{fee}}; recipient = find_balance({ "not_account_identifier":[{{sender.account_identifier}}], "minimum_balance":{ @@ -55,21 +55,68 @@ transfer(10){ "create_limit": 100, "create_probability": 50 }); - transfer.confirmation_depth = "1"; + + sender_amount = 0 - {{recipient_amount}}; + sender_fee = 0 - {{max_fee}}; // The valid_until field must be provided explicitely until the // default value is fixed // See https://github.com/coinbase/rosetta-sdk-go/pull/457 - transfer.preprocess_metadata={"valid_until": "4294967295"}; + payment_dry_run.preprocess_metadata={"valid_until": "4294967295"}; + payment_dry_run.confirmation_depth = "1"; + payment_dry_run.dry_run = true; + payment_dry_run.operations = [ + { + "operation_identifier":{"index":0}, + "type":"fee_payment", + "account":{{sender.account_identifier}}, + "amount":{ + "value": {{sender_fee}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":1}, + "type":"payment_source_dec", + "account":{{sender.account_identifier}}, + "amount":{ + "value":{{sender_amount}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":2}, + "related_operations":[{"index":1}], + "type": "payment_receiver_inc", + "account":{{recipient.account_identifier}}, + "amount":{ + "value":{{recipient_amount}}, + "currency":{{currency}} + } + } + ]; + + print_message("done payment dry run"); + }, + payment{ + suggested_fee = find_currency_amount({ + "currency":{{currency}}, + "amounts":{{payment_dry_run.suggested_fee}} + }); + print_message({"suggested_fee":{{suggested_fee.value}}}); + + sender_fee = 0 - {{suggested_fee.value}}; - // Operations for a payment transaction - transfer.operations = [ + payment.preprocess_metadata={"valid_until": "4294967295"}; + payment.network = {{payment_dry_run.network}}; + payment.confirmation_depth = {{payment_dry_run.confirmation_depth}}; + payment.operations = [ { "operation_identifier":{"index":0}, "type":"fee_payment", "account":{{sender.account_identifier}}, "amount":{ - "value": {{minus_fee}}, + "value": {{sender_fee}}, "currency":{{currency}} } }, @@ -84,6 +131,7 @@ transfer(10){ }, { "operation_identifier":{"index":2}, + "related_operations":[{"index":1}], "type": "payment_receiver_inc", "account":{{recipient.account_identifier}}, "amount":{ diff --git a/src/app/rosetta/rosetta-cli-config/mina-with-return-funds.ros b/src/app/rosetta/rosetta-cli-config/mina-with-return-funds.ros new file mode 100644 index 00000000000..61637781cc6 --- /dev/null +++ b/src/app/rosetta/rosetta-cli-config/mina-with-return-funds.ros @@ -0,0 +1,368 @@ +// Workflow used to create new accounts +create_account(1){ + create{ + network = { + "network":"berkeley-ITN", + "blockchain":"mina" + }; + key = generate_key({"curve_type": "pallas"}); + account = derive({ + "network_identifier": {{network}}, + "public_key": {{key.public_key}} + }); + + // If the account is not saved, the key will be lost! + save_account({ + "account_identifier": {{account.account_identifier}}, + "keypair": {{key}} + }); + } +} + +// Workflow used to generate payment transactions +payment(10){ + payment_dry_run{ + payment_dry_run.network = { + "network":"berkeley-ITN", + "blockchain":"mina" + }; + + currency = { + "symbol":"MINA", + "decimals":9 + }; + + max_fee = "4000000000"; // no less than 1 MINA + 1 MINA (account creation fee) + max_recipient_value = "100000000000"; // 100 MINA + min_required_value = {{max_recipient_value}} + {{max_fee}}; + + sender = find_balance({ + "minimum_balance":{ + "value": {{min_required_value}}, + "currency": {{currency}} + } + }); + + recipient_amount = random_number({"minimum": "1", "maximum": {{max_recipient_value}}}); + print_message({"recipient_amount":{{recipient_amount}}}); + + recipient = find_balance({ + "not_account_identifier":[{{sender.account_identifier}}], + "minimum_balance":{ + "value": "0", + "currency": {{currency}} + }, + "create_limit": 100, + "create_probability": 50 + }); + + sender_amount = 0 - {{recipient_amount}}; + sender_fee = 0 - {{max_fee}}; + + // The valid_until field must be provided explicitely until the + // default value is fixed + // See https://github.com/coinbase/rosetta-sdk-go/pull/457 + payment_dry_run.preprocess_metadata={"valid_until": "4294967295"}; + payment_dry_run.confirmation_depth = "1"; + payment_dry_run.dry_run = true; + payment_dry_run.operations = [ + { + "operation_identifier":{"index":0}, + "type":"fee_payment", + "account":{{sender.account_identifier}}, + "amount":{ + "value": {{sender_fee}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":1}, + "type":"payment_source_dec", + "account":{{sender.account_identifier}}, + "amount":{ + "value":{{sender_amount}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":2}, + "related_operations":[{"index":1}], + "type": "payment_receiver_inc", + "account":{{recipient.account_identifier}}, + "amount":{ + "value":{{recipient_amount}}, + "currency":{{currency}} + } + } + ]; + + print_message("done payment dry run"); + }, + payment{ + suggested_fee = find_currency_amount({ + "currency":{{currency}}, + "amounts":{{payment_dry_run.suggested_fee}} + }); + print_message({"suggested_fee":{{suggested_fee.value}}}); + + sender_fee = 0 - {{suggested_fee.value}}; + + payment.preprocess_metadata={"valid_until": "4294967295"}; + payment.network = {{payment_dry_run.network}}; + payment.confirmation_depth = {{payment_dry_run.confirmation_depth}}; + payment.operations = [ + { + "operation_identifier":{"index":0}, + "type":"fee_payment", + "account":{{sender.account_identifier}}, + "amount":{ + "value": {{sender_fee}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":1}, + "type":"payment_source_dec", + "account":{{sender.account_identifier}}, + "amount":{ + "value":{{sender_amount}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":2}, + "related_operations":[{"index":1}], + "type": "payment_receiver_inc", + "account":{{recipient.account_identifier}}, + "amount":{ + "value":{{recipient_amount}}, + "currency":{{currency}} + } + } + ]; + } +} + +// Workflow used to generate delegation transactions +delegation(10){ + delegation_dry_run{ + delegation_dry_run.network = { + "network":"berkeley-ITN", + "blockchain":"mina" + }; + + currency = { + "symbol":"MINA", + "decimals":9 + }; + + max_fee = "2000000000"; + + sender = find_balance({ + "minimum_balance":{ + "value": {{max_fee}}, + "currency": {{currency}} + } + }); + + recipient = find_balance({ + "not_account_identifier":[ + {{sender.account_identifier}} + ], + "minimum_balance":{ + "value": "1", + "currency": {{currency}} + } + }); + + sender_fee = 0 - {{max_fee}}; + + delegation_dry_run.preprocess_metadata={"valid_until": "4294967295"}; + delegation_dry_run.confirmation_depth = "1"; + delegation_dry_run.dry_run = true; + delegation_dry_run.operations = [ + { + "operation_identifier":{"index":0}, + "type":"fee_payment", + "account":{{sender.account_identifier}}, + "amount":{ + "value": {{sender_fee}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":1}, + "type":"delegate_change", + "account":{{sender.account_identifier}}, + "metadata": { + "delegate_change_target": {{recipient.account_identifier.address}} + } + } + ]; + + print_message("done delegation dry run"); + }, + delegation{ + suggested_fee = find_currency_amount({ + "currency":{{currency}}, + "amounts":{{delegation_dry_run.suggested_fee}} + }); + print_message({"suggested_fee":{{suggested_fee.value}}}); + sender_fee = 0 - {{suggested_fee.value}}; + + delegation.preprocess_metadata={"valid_until": "4294967295"}; + delegation.network = {{delegation_dry_run.network}}; + delegation.confirmation_depth = {{delegation_dry_run.confirmation_depth}}; + delegation.operations = [ + { + "operation_identifier":{"index":0}, + "type":"fee_payment", + "account":{{sender.account_identifier}}, + "amount":{ + "value": {{sender_fee}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":1}, + "type":"delegate_change", + "account":{{sender.account_identifier}}, + "metadata": { + "delegate_change_target": {{recipient.account_identifier.address}} + } + } + ]; + } +} + +// Workflow used to create new accounts +return_funds(10){ + payment_dry_run{ + payment_dry_run.network = { + "network":"berkeley-ITN", + "blockchain":"mina" + }; + + currency = { + "symbol":"MINA", + "decimals":9 + }; + + max_fee = "2000000000"; + min_value = {{max_fee}} + 2; + + // We load the recipient address from an ENV. + // The reason we read from ENV variable is that the recipient address here + // is the initial sender's address from transfer workflow which is not + // accessible by this workflow. + // When setting the ENV variable make sure to set it so that it has double + // quotes around, otherwise it will give a parsing issue + // Set it using export RECIPIENT=\"\" + // Eventually we would want it to be automatically set by transfer workflow + recipient_address = load_env("RECIPIENT"); + token_id = load_env("TOKEN_ID"); + recipient_account_identifier = { + "address": {{recipient_address}}, + "metadata": { + "token_id": {{token_id}} + } + }; + + sender = find_balance({ + "not_account_identifier":[{{recipient_account_identifier}}], + "minimum_balance":{ + "value": {{min_value}}, + "currency": {{currency}} + } + }); + + // We send the maximum amount available to the recipient. Don't worry + // we will modify this after the dry run to make sure we don't overpay. + recipient_amount = {{sender.balance.value}} - {{max_fee}}; + print_message({ + "recipient_amount":{{recipient_amount}} + }); + + sender_amount = 0 - {{recipient_amount}}; + sender_fee = 0 - {{max_fee}}; + + payment_dry_run.preprocess_metadata={"valid_until": "4294967295"}; + payment_dry_run.confirmation_depth = "1"; + payment_dry_run.dry_run = true; + payment_dry_run.operations = [ + { + "operation_identifier":{"index":0}, + "type":"fee_payment", + "account":{{sender.account_identifier}}, + "amount":{ + "value": {{sender_fee}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":1}, + "type":"payment_source_dec", + "account":{{sender.account_identifier}}, + "amount":{ + "value":{{sender_amount}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":2}, + "related_operations":[{"index":1}], + "type": "payment_receiver_inc", + "account":{{recipient_account_identifier}}, + "amount":{ + "value":{{recipient_amount}}, + "currency":{{currency}} + } + } + ]; + }, + payment{ + suggested_fee = find_currency_amount({ + "currency":{{currency}}, + "amounts":{{payment_dry_run.suggested_fee}} + }); + + sender_fee = 0 - {{suggested_fee.value}}; + recipient_amount = {{sender.balance.value}} - {{suggested_fee.value}}; + assert({{recipient_amount}}); + sender_amount = 0 - {{recipient_amount}}; + + payment.preprocess_metadata={"valid_until": "4294967295"}; + payment.network = {{payment_dry_run.network}}; + payment.confirmation_depth = {{payment_dry_run.confirmation_depth}}; + payment.operations = [ + { + "operation_identifier":{"index":0}, + "type":"fee_payment", + "account":{{sender.account_identifier}}, + "amount":{ + "value": {{sender_fee}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":1}, + "type":"payment_source_dec", + "account":{{sender.account_identifier}}, + "amount":{ + "value":{{sender_amount}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":2}, + "related_operations":[{"index":1}], + "type": "payment_receiver_inc", + "account":{{recipient_account_identifier}}, + "amount":{ + "value":{{recipient_amount}}, + "currency":{{currency}} + } + } + ]; + } +} diff --git a/src/app/rosetta/rosetta-cli-config/mina.ros b/src/app/rosetta/rosetta-cli-config/mina.ros index d015832f107..7cbb6571f9d 100644 --- a/src/app/rosetta/rosetta-cli-config/mina.ros +++ b/src/app/rosetta/rosetta-cli-config/mina.ros @@ -1,7 +1,10 @@ // Workflow used to create new accounts create_account(1){ create{ - network = {"network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina"}; + network = { + "network":"berkeley-ITN", + "blockchain":"mina" + }; key = generate_key({"curve_type": "pallas"}); account = derive({ "network_identifier": {{network}}, @@ -17,31 +20,32 @@ create_account(1){ } // Workflow used to generate payment transactions -transfer_payment(10){ - transfer{ - transfer.network = {"network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina"}; - currency = {"symbol":"MINA", "decimals":9}; +payment(10){ + payment_dry_run{ + payment_dry_run.network = { + "network":"berkeley-ITN", + "blockchain":"mina" + }; + + currency = { + "symbol":"MINA", + "decimals":9 + }; + + max_fee = "4000000000"; // no less than 1 MINA + 1 MINA (account creation fee) + max_recipient_value = "100000000000"; // 100 MINA + min_required_value = {{max_recipient_value}} + {{max_fee}}; + sender = find_balance({ "minimum_balance":{ - "value": "20000000000", + "value": {{min_required_value}}, "currency": {{currency}} } }); - // The fee must be at least the creation fee of the account if it - // did not exist before the transaction - max_fee = "4000000000"; - min_fee = "2000000000"; - - // We limit the amount to genereate multiple transactions with the - // same prefunded account - available_amount = "6000000000"; + recipient_amount = random_number({"minimum": "1", "maximum": {{max_recipient_value}}}); + print_message({"recipient_amount":{{recipient_amount}}}); - // Find recipient and construct operations - recipient_amount = random_number({"minimum": {{max_fee}}, "maximum": {{available_amount}}}); - sender_amount = 0 - {{recipient_amount}}; - fee = random_number({"minimum": {{min_fee}}, "maximum": {{max_fee}}}); - minus_fee = 0 - {{fee}}; recipient = find_balance({ "not_account_identifier":[{{sender.account_identifier}}], "minimum_balance":{ @@ -51,21 +55,68 @@ transfer_payment(10){ "create_limit": 100, "create_probability": 50 }); - transfer.confirmation_depth = "1"; + + sender_amount = 0 - {{recipient_amount}}; + sender_fee = 0 - {{max_fee}}; // The valid_until field must be provided explicitely until the // default value is fixed // See https://github.com/coinbase/rosetta-sdk-go/pull/457 - transfer.preprocess_metadata={"valid_until": "4294967295"}; + payment_dry_run.preprocess_metadata={"valid_until": "4294967295"}; + payment_dry_run.confirmation_depth = "1"; + payment_dry_run.dry_run = true; + payment_dry_run.operations = [ + { + "operation_identifier":{"index":0}, + "type":"fee_payment", + "account":{{sender.account_identifier}}, + "amount":{ + "value": {{sender_fee}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":1}, + "type":"payment_source_dec", + "account":{{sender.account_identifier}}, + "amount":{ + "value":{{sender_amount}}, + "currency":{{currency}} + } + }, + { + "operation_identifier":{"index":2}, + "related_operations":[{"index":1}], + "type": "payment_receiver_inc", + "account":{{recipient.account_identifier}}, + "amount":{ + "value":{{recipient_amount}}, + "currency":{{currency}} + } + } + ]; - // Operations for a payment transaction - transfer.operations = [ + print_message("done payment dry run"); + }, + payment{ + suggested_fee = find_currency_amount({ + "currency":{{currency}}, + "amounts":{{payment_dry_run.suggested_fee}} + }); + print_message({"suggested_fee":{{suggested_fee.value}}}); + + sender_fee = 0 - {{suggested_fee.value}}; + + payment.preprocess_metadata={"valid_until": "4294967295"}; + payment.network = {{payment_dry_run.network}}; + payment.confirmation_depth = {{payment_dry_run.confirmation_depth}}; + payment.operations = [ { "operation_identifier":{"index":0}, "type":"fee_payment", "account":{{sender.account_identifier}}, "amount":{ - "value": {{minus_fee}}, + "value": {{sender_fee}}, "currency":{{currency}} } }, @@ -80,6 +131,7 @@ transfer_payment(10){ }, { "operation_identifier":{"index":2}, + "related_operations":[{"index":1}], "type": "payment_receiver_inc", "account":{{recipient.account_identifier}}, "amount":{ @@ -92,62 +144,93 @@ transfer_payment(10){ } // Workflow used to generate delegation transactions -transfer_delegation(10){ - transfer{ - transfer.network = {"network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina"}; - currency = {"symbol":"MINA", "decimals":9}; +delegation(10){ + delegation_dry_run{ + delegation_dry_run.network = { + "network":"berkeley-ITN", + "blockchain":"mina" + }; + + currency = { + "symbol":"MINA", + "decimals":9 + }; + + max_fee = "2000000000"; + sender = find_balance({ "minimum_balance":{ - "value": "20000000000", + "value": {{max_fee}}, "currency": {{currency}} } }); - // Set the recipient_amount as some value <= sender.balance-max_fee - // creation fee of the account if it did not exist before the transaction - max_fee = "4000000000"; - min_fee = "2000000000"; - - // We limit the amount to genereate multiple transactions with the - // same prefunded account - available_amount = "6000000000"; - - recipient_amount = random_number({"minimum": {{max_fee}}, "maximum": {{available_amount}}}); - print_message({"recipient_amount":{{recipient_amount}}}); - - // Find recipient and construct operations - sender_amount = 0 - {{recipient_amount}}; - fee = random_number({"minimum": {{min_fee}}, "maximum": {{max_fee}}}); - minus_fee = 0 - {{fee}}; recipient = find_balance({ - "not_account_identifier":[{{sender.account_identifier}}], + "not_account_identifier":[ + {{sender.account_identifier}} + ], "minimum_balance":{ - "value": "0", + "value": "1", "currency": {{currency}} + } + }); + + sender_fee = 0 - {{max_fee}}; + + delegation_dry_run.preprocess_metadata={"valid_until": "4294967295"}; + delegation_dry_run.confirmation_depth = "1"; + delegation_dry_run.dry_run = true; + delegation_dry_run.operations = [ + { + "operation_identifier":{"index":0}, + "type":"fee_payment", + "account":{{sender.account_identifier}}, + "amount":{ + "value": {{sender_fee}}, + "currency":{{currency}} + } }, - "create_limit": 100, - "create_probability": 50 + { + "operation_identifier":{"index":1}, + "type":"delegate_change", + "account":{{sender.account_identifier}}, + "metadata": { + "delegate_change_target": {{recipient.account_identifier.address}} + } + } + ]; + + print_message("done delegation dry run"); + }, + delegation{ + suggested_fee = find_currency_amount({ + "currency":{{currency}}, + "amounts":{{delegation_dry_run.suggested_fee}} }); - transfer.confirmation_depth = "1"; - transfer.preprocess_metadata={"valid_until": "4294967295"}; - transfer.operations = [ + print_message({"suggested_fee":{{suggested_fee.value}}}); + sender_fee = 0 - {{suggested_fee.value}}; + + delegation.preprocess_metadata={"valid_until": "4294967295"}; + delegation.network = {{delegation_dry_run.network}}; + delegation.confirmation_depth = {{delegation_dry_run.confirmation_depth}}; + delegation.operations = [ { "operation_identifier":{"index":0}, "type":"fee_payment", "account":{{sender.account_identifier}}, "amount":{ - "value": {{minus_fee}}, + "value": {{sender_fee}}, "currency":{{currency}} } }, { "operation_identifier":{"index":1}, - "type":"delegate_change", + "type":"delegate_change", "account":{{sender.account_identifier}}, - "metadata":{ - "delegate_change_target": "PLACEHOLDER_PREFUNDED_ADDRESS" - } + "metadata": { + "delegate_change_target": {{recipient.account_identifier.address}} + } } ]; } -} \ No newline at end of file +} From 1f926501e421ba4b857baa879f8390b9db064d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Santos=20Reis?= Date: Tue, 23 Jan 2024 14:40:18 +0000 Subject: [PATCH 3/9] Fix account creation fee fetching --- src/app/rosetta/lib/block.ml | 38 ++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/app/rosetta/lib/block.ml b/src/app/rosetta/lib/block.ml index 964e49293ed..2d825e375a4 100644 --- a/src/app/rosetta/lib/block.ml +++ b/src/app/rosetta/lib/block.ml @@ -842,12 +842,21 @@ module Sql = struct AND ai_receiver.id = ac.account_identifier_id AND buc.status = 'applied' AND buc.sequence_no = - (SELECT MIN(buc2.sequence_no) - FROM blocks_user_commands buc2 - INNER JOIN user_commands uc2 - ON buc2.user_command_id = uc2.id - AND uc2.receiver_id = u.receiver_iD - AND buc2.block_id = buc.block_id) + (SELECT LEAST( + (SELECT min(bic2.sequence_no) + FROM blocks_internal_commands bic2 + INNER JOIN internal_commands ic2 + ON bic2.internal_command_id = ic2.id + WHERE ic2.receiver_id = u.receiver_id + AND bic2.block_id = buc.block_id + AND bic2.status = 'applied'), + (SELECT min(buc2.sequence_no) + FROM blocks_user_commands buc2 + INNER JOIN user_commands uc2 + ON buc2.user_command_id = uc2.id + WHERE uc2.receiver_id = u.receiver_id + AND buc2.block_id = buc.block_id + AND buc2.status = 'applied'))) INNER JOIN tokens t ON t.id = ai_receiver.token_id WHERE buc.block_id = ? @@ -897,6 +906,23 @@ module Sql = struct ON ai.public_key_id = receiver_id LEFT JOIN accounts_created ac ON ac.account_identifier_id = ai.id + AND ac.block_id = bic.block_id + AND bic.sequence_no = + (SELECT LEAST( + (SELECT min(bic2.sequence_no) + FROM blocks_internal_commands bic2 + INNER JOIN internal_commands ic2 + ON bic2.internal_command_id = ic2.id + WHERE ic2.receiver_id = i.receiver_id + AND bic2.block_id = bic.block_id + AND bic2.status = 'applied'), + (SELECT min(buc2.sequence_no) + FROM blocks_user_commands buc2 + INNER JOIN user_commands uc2 + ON buc2.user_command_id = uc2.id + WHERE uc2.receiver_id = i.receiver_id + AND buc2.block_id = bic.block_id + AND buc2.status = 'applied'))) INNER JOIN tokens t ON t.id = ai.token_id WHERE bic.block_id = ? From 4f781445448f2e9f999db9c437d0d26a84cce3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Santos=20Reis?= Date: Wed, 24 Jan 2024 10:17:19 +0000 Subject: [PATCH 4/9] Set placeholder value for network name --- .../rosetta-cli-config/mina-no-delegation-test.ros | 4 ++-- .../rosetta/rosetta-cli-config/mina-with-return-funds.ros | 8 ++++---- src/app/rosetta/rosetta-cli-config/mina.ros | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/rosetta/rosetta-cli-config/mina-no-delegation-test.ros b/src/app/rosetta/rosetta-cli-config/mina-no-delegation-test.ros index c1e9d616f48..b058f5d1b1f 100644 --- a/src/app/rosetta/rosetta-cli-config/mina-no-delegation-test.ros +++ b/src/app/rosetta/rosetta-cli-config/mina-no-delegation-test.ros @@ -2,7 +2,7 @@ create_account(1){ create{ network = { - "network":"berkeley-ITN", + "network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina" }; key = generate_key({"curve_type": "pallas"}); @@ -23,7 +23,7 @@ create_account(1){ payment(10){ payment_dry_run{ payment_dry_run.network = { - "network":"berkeley-ITN", + "network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina" }; diff --git a/src/app/rosetta/rosetta-cli-config/mina-with-return-funds.ros b/src/app/rosetta/rosetta-cli-config/mina-with-return-funds.ros index 61637781cc6..862f2879154 100644 --- a/src/app/rosetta/rosetta-cli-config/mina-with-return-funds.ros +++ b/src/app/rosetta/rosetta-cli-config/mina-with-return-funds.ros @@ -2,7 +2,7 @@ create_account(1){ create{ network = { - "network":"berkeley-ITN", + "network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina" }; key = generate_key({"curve_type": "pallas"}); @@ -23,7 +23,7 @@ create_account(1){ payment(10){ payment_dry_run{ payment_dry_run.network = { - "network":"berkeley-ITN", + "network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina" }; @@ -147,7 +147,7 @@ payment(10){ delegation(10){ delegation_dry_run{ delegation_dry_run.network = { - "network":"berkeley-ITN", + "network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina" }; @@ -239,7 +239,7 @@ delegation(10){ return_funds(10){ payment_dry_run{ payment_dry_run.network = { - "network":"berkeley-ITN", + "network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina" }; diff --git a/src/app/rosetta/rosetta-cli-config/mina.ros b/src/app/rosetta/rosetta-cli-config/mina.ros index 7cbb6571f9d..35371930461 100644 --- a/src/app/rosetta/rosetta-cli-config/mina.ros +++ b/src/app/rosetta/rosetta-cli-config/mina.ros @@ -2,7 +2,7 @@ create_account(1){ create{ network = { - "network":"berkeley-ITN", + "network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina" }; key = generate_key({"curve_type": "pallas"}); @@ -23,7 +23,7 @@ create_account(1){ payment(10){ payment_dry_run{ payment_dry_run.network = { - "network":"berkeley-ITN", + "network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina" }; @@ -147,7 +147,7 @@ payment(10){ delegation(10){ delegation_dry_run{ delegation_dry_run.network = { - "network":"berkeley-ITN", + "network":"PLACEHOLDER_NETWORK_NAME", "blockchain":"mina" }; From c7a9ca58c3edd5f86b55988561d4939f96ea3435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Santos=20Reis?= Date: Wed, 24 Jan 2024 11:42:59 +0000 Subject: [PATCH 5/9] Fix unit tests --- src/app/rosetta/lib/network.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/rosetta/lib/network.ml b/src/app/rosetta/lib/network.ml index 37911e5cb12..a78c136ea39 100644 --- a/src/app/rosetta/lib/network.ml +++ b/src/app/rosetta/lib/network.ml @@ -328,7 +328,7 @@ module Status = struct { Sync_status.current_index= Some (Int64.of_int_exn 4) ; target_index= None ; stage= Some "Synced" - ; synced = None + ; synced = Some true } } ) let oldest_block_is_different_env : 'gql Env.Mock.t = @@ -364,7 +364,7 @@ module Status = struct { Sync_status.current_index= Some (Int64.of_int_exn 4) ; target_index= None ; stage= Some "Synced" - ; synced = None + ; synced = Some true } } ) end ) end From 1f07034af9a0f21ed9a130549bbeba125f92c2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Santos=20Reis?= Date: Wed, 24 Jan 2024 11:57:45 +0000 Subject: [PATCH 6/9] Fix wrong script version for fast rosetta intg test --- buildkite/src/Jobs/Test/RosettaIntegrationTests.dhall | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildkite/src/Jobs/Test/RosettaIntegrationTests.dhall b/buildkite/src/Jobs/Test/RosettaIntegrationTests.dhall index be26298998a..85575ec60b1 100644 --- a/buildkite/src/Jobs/Test/RosettaIntegrationTests.dhall +++ b/buildkite/src/Jobs/Test/RosettaIntegrationTests.dhall @@ -40,7 +40,7 @@ Pipeline.build Command.Config::{ commands = [ Cmd.run ("export MINA_DEB_CODENAME=bullseye && source ./buildkite/scripts/export-git-env-vars.sh && echo \\\${MINA_DOCKER_TAG}"), - Cmd.runInDocker Cmd.Docker::{image="gcr.io/o1labs-192920/mina-rosetta:\\\${MINA_DOCKER_TAG}", entrypoint=" --entrypoint buildkite/scripts/rosetta-integration-tests-full.sh"} "bash" + Cmd.runInDocker Cmd.Docker::{image="gcr.io/o1labs-192920/mina-rosetta:\\\${MINA_DOCKER_TAG}", entrypoint=" --entrypoint buildkite/scripts/rosetta-integration-tests-fast.sh"} "bash" ], label = "Rosetta integration tests Bullseye" , key = "rosetta-integration-tests-bullseye" @@ -48,4 +48,4 @@ Pipeline.build , depends_on = [ { name = "MinaArtifactBullseye", key = "rosetta-bullseye-docker-image" } ] } ] - } \ No newline at end of file + } From 71ca60ca9de2c16d57b6461c2a97d986a2ea82fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Santos=20Reis?= Date: Wed, 24 Jan 2024 11:58:12 +0000 Subject: [PATCH 7/9] Change rosetta-cli confguration end conditions --- src/app/rosetta/rosetta-cli-config/config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/rosetta/rosetta-cli-config/config.json b/src/app/rosetta/rosetta-cli-config/config.json index 38e80425747..707288b8fbf 100644 --- a/src/app/rosetta/rosetta-cli-config/config.json +++ b/src/app/rosetta/rosetta-cli-config/config.json @@ -75,7 +75,8 @@ "initial_balance_fetch_disabled": false, "end_conditions": { "reconciliation_coverage": { - "tip": true + "index": 50, + "coverage": 1.0 } } }, From 1ac2bbd35a9130eccdc559e50ae7a8fc93d86d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Santos=20Reis?= Date: Wed, 24 Jan 2024 12:23:04 +0000 Subject: [PATCH 8/9] Revert "Fix wrong script version for fast rosetta intg test" This is included in a different PR. This reverts commit 1f07034af9a0f21ed9a130549bbeba125f92c2bf. --- buildkite/src/Jobs/Test/RosettaIntegrationTests.dhall | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildkite/src/Jobs/Test/RosettaIntegrationTests.dhall b/buildkite/src/Jobs/Test/RosettaIntegrationTests.dhall index 85575ec60b1..be26298998a 100644 --- a/buildkite/src/Jobs/Test/RosettaIntegrationTests.dhall +++ b/buildkite/src/Jobs/Test/RosettaIntegrationTests.dhall @@ -40,7 +40,7 @@ Pipeline.build Command.Config::{ commands = [ Cmd.run ("export MINA_DEB_CODENAME=bullseye && source ./buildkite/scripts/export-git-env-vars.sh && echo \\\${MINA_DOCKER_TAG}"), - Cmd.runInDocker Cmd.Docker::{image="gcr.io/o1labs-192920/mina-rosetta:\\\${MINA_DOCKER_TAG}", entrypoint=" --entrypoint buildkite/scripts/rosetta-integration-tests-fast.sh"} "bash" + Cmd.runInDocker Cmd.Docker::{image="gcr.io/o1labs-192920/mina-rosetta:\\\${MINA_DOCKER_TAG}", entrypoint=" --entrypoint buildkite/scripts/rosetta-integration-tests-full.sh"} "bash" ], label = "Rosetta integration tests Bullseye" , key = "rosetta-integration-tests-bullseye" @@ -48,4 +48,4 @@ Pipeline.build , depends_on = [ { name = "MinaArtifactBullseye", key = "rosetta-bullseye-docker-image" } ] } ] - } + } \ No newline at end of file From 94f0743b55bb9e56c7a75e270f93562fab4211ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Santos=20Reis?= Date: Wed, 24 Jan 2024 13:00:00 +0000 Subject: [PATCH 9/9] Update reconciliation coverage end condition --- src/app/rosetta/rosetta-cli-config/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/rosetta/rosetta-cli-config/config.json b/src/app/rosetta/rosetta-cli-config/config.json index 707288b8fbf..d5df1faf921 100644 --- a/src/app/rosetta/rosetta-cli-config/config.json +++ b/src/app/rosetta/rosetta-cli-config/config.json @@ -75,7 +75,7 @@ "initial_balance_fetch_disabled": false, "end_conditions": { "reconciliation_coverage": { - "index": 50, + "tip": true, "coverage": 1.0 } }