Start constructor migration

This commit is contained in:
Patrick O'Grady 2020-10-26 16:29:41 -07:00
parent 8000c85a66
commit 832ab7d346
No known key found for this signature in database
GPG key ID: 8DE11C985C0C8D85
4 changed files with 138 additions and 116 deletions

View file

@ -207,10 +207,9 @@ in recently processed blocks to save to disk.
## Testing with rosetta-cli
To validate `rosetta-bitcoin`, [install `rosetta-cli`](https://github.com/coinbase/rosetta-cli#install)
and run one of the following commands:
* `rosetta-cli check:data --configuration-file rosetta-cli-conf/bitcoin_testnet.json`
* `rosetta-cli check:construction --configuration-file rosetta-cli-conf/bitcoin_testnet.json`
* `rosetta-cli check:data --configuration-file rosetta-cli-conf/bitcoin_mainnet.json`
* `rosetta-cli check:construction --configuration-file rosetta-cli-conf/bitcoin_mainnet.json`
* `rosetta-cli check:data --configuration-file rosetta-cli-conf/testnet/config.json`
* `rosetta-cli check:construction --configuration-file rosetta-cli-conf/testnet/config.json`
* `rosetta-cli check:data --configuration-file rosetta-cli-conf/mainnet/config.json`
## Future Work
* Publish benchamrks for sync speed, storage usage, and load testing

View file

@ -1,87 +1,88 @@
{
"network": {
"blockchain": "Bitcoin",
"network": "Testnet3"
},
"data_directory": "bitcoin-testnet-data",
"http_timeout": 300,
"max_retries": 5,
"retry_elapsed_time": 0,
"max_online_connections": 0,
"max_sync_concurrency": 0,
"tip_delay": 1800,
"log_configuration": false,
"construction": {
"max_offline_connections": 0,
"stale_depth": 0,
"broadcast_limit": 0,
"ignore_broadcast_failures": false,
"clear_broadcasts": false,
"broadcast_behind_tip": false,
"block_broadcast_limit": 0,
"rebroadcast_all": false,
"workflows": [
{
"name": "request_funds",
"concurrency": 1,
"scenarios": [
{
"name": "find_account",
"actions": [
{
"input": "{\"symbol\":\"tBTC\", \"decimals\":8}",
"type": "set_variable",
"output_path": "currency"
},
{
"input": "{\"minimum_balance\":{\"value\": \"0\", \"currency\": {{currency}}}, \"create_limit\":1}",
"type": "find_balance",
"output_path": "random_account"
}
]
},
{
"name": "request",
"actions": [
{
"input": "{\"account_identifier\": {{random_account.account_identifier}}, \"minimum_balance\":{\"value\": \"1000000\", \"currency\": {{currency}}}}",
"type": "find_balance",
"output_path": "loaded_account"
}
]
}
]
},
{
"name": "create_account",
"concurrency": 1,
"scenarios": [
{
"name": "create_account",
"actions": [
{
"input": "{\"network\":\"Testnet3\", \"blockchain\":\"Bitcoin\"}",
"type": "set_variable",
"output_path": "network"
},
{
"input": "{\"curve_type\": \"secp256k1\"}",
"type": "generate_key",
"output_path": "key"
},
{
"input": "{\"network_identifier\": {{network}}, \"public_key\": {{key.public_key}}}",
"type": "derive",
"output_path": "account"
},
{
"input": "{\"account_identifier\": {{account.account_identifier}}, \"keypair\": {{key}}}",
"type": "save_account"
}
]
}
]
},
request_funds(1) {
find_account{
currency = {"symbol":"tBTC", "decimals":8};
random_account = find_balance({
"minimum_balance":{
"value": "0",
"currency": {{currency}}
},
"create_limit":1
});
},
// Create a separate scenario to request funds so that
// the address we are using to request funds does not
// get rolled back if funds do not yet exist.
request{
loaded_account = find_balance({
"account_identifier": {{random_account.account_identifier}},
"minimum_balance":{
"value": "1000000",
"currency": {{currency}}
}
});
}
}
create_account(1){
create{
network = {"network":"Testnet3", "blockchain":"Bitcoin"};
key = generate_key({"curve_type": "secp256k1"});
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}}
});
}
}
transfer(10){
transfer_dry_run{
transfer_dry_run.network = {"network":"Testnet3", "blockchain":"Bitcoin"};
currency = {"symbol":"tBTC", "decimals":8};
// We set the max_fee_amount to know how much buffer we should
// leave for fee payment when selecting a sender account.
dust_amount = "600";
max_fee_amount = "1200";
send_buffer = {{dust_amount}} + {{max_fee_amount}};
// reserved_amount is max_fee_amount + min_utxo size x 2
reserved_amount = "2400";
sender = find_balance({
"minimum_balance":{
"value": {{reserved_amount}},
"currency": {{currency}}
},
"require_coin": true
});
available_amount = {{sender.balance.value}} - {{send_buffer}};
recipient_amount = random_number({
"minimum": {{dust_amount}},
"maximum": {{available_amount}}
});
print_message({
"recipient_amount":{{recipient_amount}}
});
total_change_amount = {{sender.balance.value}} - {{recipient_amount}};
change_amount = {{total_change_amount}} - {{max_fee_amount}};
print_message({
"change_amount":{{change_amount}}
});
sender_amount = 0 - {{sender.balance.value}};
},
transfer{
},
}
{
"name": "transfer",
"concurrency": 10,
@ -350,31 +351,3 @@
}
]
}
],
"end_conditions": {
"create_account": 10,
"transfer": 10
}
},
"data": {
"active_reconciliation_concurrency": 0,
"inactive_reconciliation_concurrency": 0,
"inactive_reconciliation_frequency": 0,
"log_blocks": false,
"log_transactions": false,
"log_balance_changes": false,
"log_reconciliations": false,
"ignore_reconciliation_error": false,
"exempt_accounts": "",
"bootstrap_balances": "",
"interesting_accounts": "",
"reconciliation_disabled": false,
"inactive_discrepency_search_disabled": false,
"balance_tracking_disabled": false,
"coin_tracking_disabled": false,
"end_conditions": {
"reconciliation_coverage": 0.95
},
"results_output_file": ""
}
}

View file

@ -0,0 +1,50 @@
{
"network": {
"blockchain": "Bitcoin",
"network": "Testnet3"
},
"data_directory": "bitcoin-testnet-data",
"http_timeout": 300,
"max_retries": 5,
"retry_elapsed_time": 0,
"max_online_connections": 0,
"max_sync_concurrency": 0,
"tip_delay": 1800,
"log_configuration": false,
"construction": {
"max_offline_connections": 0,
"stale_depth": 0,
"broadcast_limit": 0,
"ignore_broadcast_failures": false,
"clear_broadcasts": false,
"broadcast_behind_tip": false,
"block_broadcast_limit": 0,
"rebroadcast_all": false,
"constructor_dsl_file": "bitcoin.ros",
"end_conditions": {
"create_account": 10,
"transfer": 10
}
},
"data": {
"active_reconciliation_concurrency": 0,
"inactive_reconciliation_concurrency": 0,
"inactive_reconciliation_frequency": 0,
"log_blocks": false,
"log_transactions": false,
"log_balance_changes": false,
"log_reconciliations": false,
"ignore_reconciliation_error": false,
"exempt_accounts": "",
"bootstrap_balances": "",
"interesting_accounts": "",
"reconciliation_disabled": false,
"inactive_discrepency_search_disabled": false,
"balance_tracking_disabled": false,
"coin_tracking_disabled": false,
"end_conditions": {
"reconciliation_coverage": 0.95
},
"results_output_file": ""
}
}