Skip to content

Commit

Permalink
[rosetta] implement balance tracking and redo tx construction (#8729)
Browse files Browse the repository at this point in the history
Co-authored-by: Alessio Treglia <[email protected]>
Co-authored-by: Robert Zaremba <[email protected]>
  • Loading branch information
3 people authored Mar 11, 2021
1 parent 280ee4f commit 288f8dd
Show file tree
Hide file tree
Showing 23 changed files with 1,606 additions and 1,422 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

* [\#8559](https://github.com/cosmos/cosmos-sdk/pull/8559) Added Protobuf compatible secp256r1 ECDSA signatures.
* [\#8786](https://github.com/cosmos/cosmos-sdk/pull/8786) Enabled secp256r1 in x/auth.

* (rosetta) [\#8729](https://github.com/cosmos/cosmos-sdk/pull/8729) Data API fully supports balance tracking. Construction API can now construct any message supported by the application.

### Client Breaking Changes

Expand Down
2 changes: 1 addition & 1 deletion contrib/rosetta/configuration/bootstrap.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"account_identifier": {
"address":"cosmos158nkd0l9tyemv2crp579rmj8dg37qty8lzff88"
"address":"cosmos1ujtnemf6jmfm995j000qdry064n5lq854gfe3j"
},
"currency":{
"symbol":"stake",
Expand Down
2 changes: 1 addition & 1 deletion contrib/rosetta/configuration/data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sleep 10

# send transaction to deterministic address
echo sending transaction with addr $addr
simd tx bank send "$addr" cosmos1wjmt63j4fv9nqda92nsrp2jp2vsukcke4va3pt 100stake --yes --keyring-backend=test --broadcast-mode=block --chain-id=testing
simd tx bank send "$addr" cosmos19g9cm8ymzchq2qkcdv3zgqtwayj9asv3hjv5u5 100stake --yes --keyring-backend=test --broadcast-mode=block --chain-id=testing

sleep 10

Expand Down
2 changes: 1 addition & 1 deletion contrib/rosetta/configuration/rosetta.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"constructor_dsl_file": "transfer.ros",
"end_conditions": {
"create_account": 1,
"transfer": 3
"transfer": 1
}
},
"data": {
Expand Down
12 changes: 0 additions & 12 deletions contrib/rosetta/configuration/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@

set -e

addr="abcd"

send_tx() {
echo '12345678' | simd tx bank send $addr "$1" "$2"
}

detect_account() {
line=$1
}

wait_for_rosetta() {
timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' rosetta 8080
}
Expand All @@ -25,5 +15,3 @@ rosetta-cli check:data --configuration-file ./config/rosetta.json
echo "checking construction API"
rosetta-cli check:construction --configuration-file ./config/rosetta.json

echo "checking staking API"
rosetta-cli check:construction --configuration-file ./config/staking.json
30 changes: 0 additions & 30 deletions contrib/rosetta/configuration/staking.json

This file was deleted.

147 changes: 0 additions & 147 deletions contrib/rosetta/configuration/staking.ros

This file was deleted.

40 changes: 18 additions & 22 deletions contrib/rosetta/configuration/transfer.ros
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ request_funds(1){
loaded_account = find_balance({
"account_identifier": {{random_account.account_identifier}},
"minimum_balance":{
"value": "100",
"value": "50",
"currency": {{currency}}
}
});
Expand Down Expand Up @@ -57,6 +57,8 @@ transfer(3){
"currency": {{currency}}
}
});
acc_identifier = {{sender.account_identifier}};
sender_address = {{acc_identifier.address}};
// Set the recipient_amount as some value <= sender.balance-max_fee
max_fee = "0";
fee_amount = "1";
Expand All @@ -76,34 +78,28 @@ transfer(3){
"create_probability": 50
});
transfer.confirmation_depth = "1";
recipient_account_identifier = {{recipient.account_identifier}};
recipient_address = {{recipient_account_identifier.address}};
transfer.operations = [
{
"operation_identifier":{"index":0},
"type":"fee",
"account":{{sender.account_identifier}},
"amount":{
"value":{{fee_value}},
"currency":{{currency}}
}
},
{
"operation_identifier":{"index":1},
"type":"cosmos.bank.v1beta1.MsgSend",
"account":{{sender.account_identifier}},
"amount":{
"value":{{sender_amount}},
"currency":{{currency}}
}
},
{
"operation_identifier":{"index":2},
"type":"cosmos.bank.v1beta1.MsgSend",
"account":{{recipient.account_identifier}},
"amount":{
"value":{{recipient_amount}},
"currency":{{currency}}
"metadata": {
"amount": [
{
"amount": {{recipient_amount}},
"denom": {{currency.symbol}}
}
],
"from_address": {{sender_address}},
"to_address": {{recipient_address}}
}
}
];
transfer.preprocess_metadata = {
"gas_price": "1stake",
"gas_limit": 250000
};
}
}
Binary file modified contrib/rosetta/node/data.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.7.0
github.com/tendermint/btcd v0.1.1
github.com/tendermint/cosmos-rosetta-gateway v0.3.0-rc2
github.com/tendermint/cosmos-rosetta-gateway v0.3.0-rc2.0.20210304154332-87d6ca4410df
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15
github.com/tendermint/go-amino v0.16.0
github.com/tendermint/tendermint v0.34.8
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,8 @@ github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzH
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s=
github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U=
github.com/tendermint/cosmos-rosetta-gateway v0.3.0-rc2 h1:crekJuQ57yIBDuKd3/dMJ00ZvOHURuv9RGJSi2hWTW4=
github.com/tendermint/cosmos-rosetta-gateway v0.3.0-rc2/go.mod h1:gBPw8WV2Erm4UGHlBRiM3zaEBst4bsuihmMCNQdgP/s=
github.com/tendermint/cosmos-rosetta-gateway v0.3.0-rc2.0.20210304154332-87d6ca4410df h1:hoMLrOS4WyyMM+Y+iWdGu94o0zzp6Q43y7v89Q1/OIw=
github.com/tendermint/cosmos-rosetta-gateway v0.3.0-rc2.0.20210304154332-87d6ca4410df/go.mod h1:gBPw8WV2Erm4UGHlBRiM3zaEBst4bsuihmMCNQdgP/s=
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI=
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk=
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
Expand Down
Loading

0 comments on commit 288f8dd

Please sign in to comment.