Skip to content

Commit b60cc8c

Browse files
asimm241zone117x
authored andcommitted
chore: miscellaneous changes to finalize rosetta implementation after running check-construction
1 parent 45cca5f commit b60cc8c

18 files changed

+1060
-49
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3.7'
2+
services:
3+
rosetta-cli:
4+
build:
5+
context: ./rosetta-cli-config
6+
dockerfile: docker/Dockerfile
7+
command: /bin/rosetta-cli --configuration-file /app/rosetta-config-docker.json check:construction

docs/api/rosetta/rosetta-construction-preprocess-response.schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"$ref": "./../../entities/rosetta/rosetta-construction-options.schema.json"
1111
},
1212
"required_public_keys": {
13-
"$ref": "./../../entities/rosetta/rosetta-account.schema.json"
13+
"type": "array",
14+
"items": {
15+
"$ref": "./../../entities/rosetta/rosetta-account.schema.json"
16+
}
1417
}
1518
}
1619
}

docs/entities/transactions/transaction-status.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"title": "TransactionStatus",
44
"description": "Status of the transaction",
55
"type": "string",
6-
"enum": ["success", "pending", "abort_by_response", "abort_by_post_condition"]
6+
"enum": ["success", "pending", "abort_by_response", "abort_by_post_condition", ""]
77
}

docs/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ export interface RosettaConstructionPreprocessRequest {
476476
*/
477477
export interface RosettaConstructionPreprocessResponse {
478478
options?: RosettaOptions;
479-
required_public_keys?: RosettaAccount;
479+
required_public_keys?: RosettaAccount[];
480480
}
481481

482482
/**
@@ -2056,7 +2056,7 @@ export interface CoinbaseTransaction {
20562056
/**
20572057
* Status of the transaction
20582058
*/
2059-
export type TransactionStatus = "success" | "pending" | "abort_by_response" | "abort_by_post_condition";
2059+
export type TransactionStatus = "success" | "pending" | "abort_by_response" | "abort_by_post_condition" | "";
20602060

20612061
/**
20622062
* String literal of all Stacks 2.0 transaction types

jest.config.rosetta-cli.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
rootDir: 'src',
5+
testMatch: ['<rootDir>/tests-rosetta-cli/validate-rosetta-construction.ts'],
6+
testPathIgnorePatterns: [
7+
'<rootDir>/tests-rosetta-cli/setup.ts',
8+
'<rootDir>/tests-rosetta-cli/teardown.ts',
9+
],
10+
collectCoverageFrom: ['<rootDir>/**/*.ts'],
11+
coveragePathIgnorePatterns: ['<rootDir>/tests'],
12+
coverageDirectory: '../coverage',
13+
globalSetup: '<rootDir>/tests-rosetta-cli/setup.ts',
14+
globalTeardown: '<rootDir>/tests-rosetta-cli/teardown.ts',
15+
testTimeout: 180000,
16+
transformIgnorePatterns: ['node_modules/(?!(@blockstack/stacks-transactions)/)'],
17+
};

package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"@promster/express": "^4.1.12",
9696
"@promster/server": "^4.2.13",
9797
"@promster/types": "^1.0.6",
98+
"@types/dockerode": "^2.5.34",
9899
"@types/express-list-endpoints": "^4.0.1",
99100
"@types/ws": "^7.2.5",
100101
"big-integer": "^1.6.48",
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"network": {
3+
"blockchain": "stacks",
4+
"network": "testnet"
5+
},
6+
"online_url": "http://host.docker.internal:3999/rosetta/v1",
7+
"data_directory": "",
8+
"http_timeout": 10,
9+
"sync_concurrency": 8,
10+
"transaction_concurrency": 16,
11+
"tip_delay": 5,
12+
"data": {
13+
"active_reconciliation_concurrency": 16,
14+
"inactive_reconciliation_concurrency": 4,
15+
"inactive_reconciliation_frequency": 250,
16+
"log_blocks": true,
17+
"log_transactions": true,
18+
"log_balance_changes": true,
19+
"log_reconciliations": false,
20+
"ignore_reconciliation_error": false,
21+
"exempt_accounts": "/app/exempt_accounts.json",
22+
"bootstrap_balances": "/app/bootstrap_balances.json",
23+
"interesting_accounts": "/app/interesting_accounts.json",
24+
"historical_balance_disabled": true,
25+
"reconciliation_disabled": false,
26+
"inactive_discrepency_search_disabled": false,
27+
"balance_tracking_disabled": false,
28+
"end_conditions": {
29+
"reconciliation_coverage": 0.95,
30+
"index": 100
31+
},
32+
"results_output_file": "./rosetta-output/rosetta-cli-output.json"
33+
},
34+
"construction": {
35+
"offline_url": "http://host.docker.internal:3999/rosetta/v1",
36+
"currency": {
37+
"symbol": "STX",
38+
"decimals": 18
39+
},
40+
"minimum_balance": "0",
41+
"maximum_fee": "10000000000000000",
42+
"curve_type": "secp256k1",
43+
"accounting_model": "account",
44+
"scenario": [
45+
{
46+
"operation_identifier": {
47+
"index": 0
48+
},
49+
"type": "NATIVE_TRANSFER",
50+
"status": "",
51+
"account": {
52+
"address": "{{ SENDER }}"
53+
},
54+
"amount": {
55+
"value": "{{ SENDER_VALUE }}",
56+
"currency": {
57+
"symbol": "STX",
58+
"decimals": 6
59+
}
60+
}
61+
},
62+
{
63+
"operation_identifier": {
64+
"index": 1
65+
},
66+
"related_operations": [
67+
{
68+
"index": 0
69+
}
70+
],
71+
"type": "NATIVE_TRANSFER",
72+
"status": "",
73+
"account": {
74+
"address": "{{ RECIPIENT }}"
75+
},
76+
"amount": {
77+
"value": "{{ RECIPIENT_VALUE }}",
78+
"currency": {
79+
"symbol": "STX",
80+
"decimals": 6
81+
}
82+
}
83+
}
84+
],
85+
"confirmation_depth": 5,
86+
"stale_depth": 30,
87+
"broadcast_limit": 3,
88+
"ignore_broadcast_failures": false,
89+
"change_scenario": null,
90+
"clear_broadcasts": false,
91+
"broadcast_behind_tip": false,
92+
"block_broadcast_limit": 5,
93+
"rebroadcast_all": false,
94+
"new_account_probability": 0.5,
95+
"max_addresses": 200
96+
}
97+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"network": {
3+
"blockchain": "stacks",
4+
"network": "testnet"
5+
},
6+
"online_url": "http://localhost:3999/rosetta/v1",
7+
"data_directory": "",
8+
"http_timeout": 300,
9+
"max_retries": 5,
10+
"retry_elapsed_time": 0,
11+
"max_online_connections": 0,
12+
"max_sync_concurrency": 0,
13+
"tip_delay": 60,
14+
"log_configuration": false,
15+
"construction": {
16+
"offline_url": "http://localhost:3999/rosetta/v1",
17+
"max_offline_connections": 0,
18+
"stale_depth": 0,
19+
"broadcast_limit": 0,
20+
"ignore_broadcast_failures": false,
21+
"clear_broadcasts": false,
22+
"broadcast_behind_tip": false,
23+
"block_broadcast_limit": 0,
24+
"rebroadcast_all": false,
25+
"constructor_dsl_file": "stacks.ros",
26+
"prefunded_accounts": [
27+
{"privkey": "cb3df38053d132895220b9ce471f6b676db5b9bf0b4adefb55f2118ece2478df",
28+
"account_identifier": {"address": "STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6"},
29+
"curve_type": "secp256k1",
30+
"currency": {"symbol": "STX", "decimals": 6}},
31+
{"privkey": "21d43d2ae0da1d9d04cfcaac7d397a33733881081f0b2cd038062cf0ccbb7526",
32+
"account_identifier": {"address": "ST11NJTTKGVT6D1HY4NJRVQWMQM7TVAR091EJ8P2Y"},
33+
"curve_type": "secp256k1",
34+
"currency": {"symbol": "STX", "decimals": 6}},
35+
{"privkey": "c71700b07d520a8c9731e4d0f095aa6efb91e16e25fb27ce2b72e7b698f8127a",
36+
"account_identifier": {"address": "ST1HB1T8WRNBYB0Y3T7WXZS38NKKPTBR3EG9EPJKR"},
37+
"curve_type": "secp256k1",
38+
"currency": {"symbol": "STX", "decimals": 6}},
39+
{"privkey": "e75dcb66f84287eaf347955e94fa04337298dbd95aa0dbb985771104ef1913db",
40+
"account_identifier": {"address": "STRYYQQ9M8KAF4NS7WNZQYY59X93XEKR31JP64CP"},
41+
"curve_type": "secp256k1",
42+
"currency": {"symbol": "STX", "decimals": 6}}],
43+
"end_conditions": {
44+
"create_account": 10,
45+
"transfer": 10
46+
}
47+
}
48+
}

rosetta-cli-config/stacks.ros

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
request_funds(1){
2+
find_account{
3+
currency = {"symbol":"STX", "decimals":6};
4+
random_account = find_balance({
5+
"minimum_balance":{
6+
"value": "0",
7+
"currency": {{currency}}
8+
},
9+
"create_limit":1
10+
});
11+
},
12+
13+
// Create a separate scenario to request funds so that
14+
// the address we are using to request funds does not
15+
// get rolled back if funds do not yet exist.
16+
request{
17+
loaded_account = find_balance({
18+
"account_identifier": {{random_account.account_identifier}},
19+
"minimum_balance":{
20+
"value": "1000000000",
21+
"currency": {{currency}}
22+
}
23+
});
24+
}
25+
}
26+
27+
create_account(1){
28+
create{
29+
network = {"network":"testnet", "blockchain":"stacks"};
30+
key = generate_key({"curve_type": "secp256k1"});
31+
account = derive({
32+
"network_identifier": {{network}},
33+
"public_key": {{key.public_key}}
34+
});
35+
// If the account is not saved, the key will be lost!
36+
save_account({
37+
"account_identifier": {{account.account_identifier}},
38+
"keypair": {{key}}
39+
});
40+
print_message({"--- created": {{key}}});
41+
}
42+
}
43+
44+
transfer(10){
45+
transfer{
46+
transfer.network = {"network":"testnet", "blockchain":"stacks"};
47+
48+
currency = {"symbol":"STX", "decimals":6};
49+
sender = find_balance({
50+
"minimum_balance":{
51+
"value": "1000000000",
52+
"currency": {{currency}}
53+
}
54+
});
55+
56+
// Set the recipient_amount as some value <= sender.balance-max_fee
57+
max_fee = "1000";
58+
available_amount = "10000";
59+
recipient_amount = random_number({"minimum": "1", "maximum": {{available_amount}}});
60+
print_message({"recipient_amount":{{recipient_amount}}});
61+
62+
// Find recipient and construct operations
63+
sender_amount = 0 - {{recipient_amount}};
64+
recipient = find_balance({
65+
"not_account_identifier":[{{sender.account_identifier}}],
66+
"minimum_balance":{
67+
"value": "0",
68+
"currency": {{currency}}
69+
},
70+
"create_limit": 100,
71+
"create_probability": 50
72+
});
73+
print_message({"---- SENDING FROM": {{sender}}});
74+
print_message({"---- SENDING TO": {{recipient}}});
75+
transfer.confirmation_depth = "1";
76+
transfer.operations = [
77+
{
78+
"operation_identifier":{"index":0},
79+
"type":"fee",
80+
"status" : "pending",
81+
"account":{{sender.account_identifier}},
82+
"amount":{
83+
"value":"-180",
84+
"currency":{{currency}}
85+
}
86+
},
87+
{
88+
"operation_identifier":{"index":1},
89+
"type":"token_transfer",
90+
"status" : "pending",
91+
"account":{{sender.account_identifier}},
92+
"amount":{
93+
"value":{{sender_amount}},
94+
"currency":{{currency}}
95+
}
96+
},
97+
{
98+
"operation_identifier":{"index":2},
99+
"type":"token_transfer",
100+
"status" : "pending",
101+
"account":{{recipient.account_identifier}},
102+
"amount":{
103+
"value":{{recipient_amount}},
104+
"currency":{{currency}}
105+
}
106+
}
107+
];
108+
transfer.public_keys = [
109+
{
110+
"hex_bytes" : {{sender}},
111+
"curve_type" : "secp256k1"
112+
}
113+
];
114+
}
115+
}

0 commit comments

Comments
 (0)