Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rosetta] implement balance tracking and redo tx construction #8729

Merged
merged 39 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
702ea89
change(rosetta): data api block and tx parsing
fdymylja Mar 1, 2021
8f711a1
change(rosetta): finalize data API
fdymylja Mar 1, 2021
ab91ce3
add: converter
fdymylja Mar 3, 2021
b3bf68b
fix: casting error message
fdymylja Mar 3, 2021
593f26d
change: rework construction API to support every possible transaction…
fdymylja Mar 4, 2021
fbdeabc
change: make construction stateless
fdymylja Mar 4, 2021
232d83f
chore: cleanup api
fdymylja Mar 4, 2021
b43553e
chore: cleanup api
fdymylja Mar 4, 2021
e2b1a01
chore: reorder methods declaration
fdymylja Mar 5, 2021
5292379
add: signed tx tests
fdymylja Mar 5, 2021
976f2e2
add: ops and signers test
fdymylja Mar 5, 2021
a489652
fix: begin and endblock tx conversions
fdymylja Mar 5, 2021
18bd9e3
add: begin and endblock invalid tests
fdymylja Mar 5, 2021
a32c005
add: balance and signing components tests
fdymylja Mar 5, 2021
9ad9d28
change: remove staking tests
fdymylja Mar 5, 2021
52be187
Merge branch 'master' into frojdi/rosetta-balance-tracking
fdymylja Mar 5, 2021
7375263
chore: lint
fdymylja Mar 5, 2021
2246c6c
chore: lint
fdymylja Mar 5, 2021
4377a09
revert: makefile rosetta test
fdymylja Mar 5, 2021
a1f82bc
chore: lint again
fdymylja Mar 5, 2021
89de69c
chore: move tests to package based ones
fdymylja Mar 5, 2021
687aef2
chore: lint
fdymylja Mar 5, 2021
8a9a140
chore: lint
fdymylja Mar 5, 2021
bf428f4
chore: cleanup ci
fdymylja Mar 5, 2021
c7da349
Merge branch 'master' into frojdi/rosetta-balance-tracking
Mar 5, 2021
8af9112
Merge branch 'master' into frojdi/rosetta-balance-tracking
Mar 5, 2021
b3f5410
chore: address documentation changes
fdymylja Mar 5, 2021
0bb7b16
chore: address documentation changes
fdymylja Mar 5, 2021
daeb5f0
Merge branch 'master' into frojdi/rosetta-balance-tracking
fdymylja Mar 5, 2021
fe10978
Merge branch 'master' into frojdi/rosetta-balance-tracking
Mar 10, 2021
57e684a
Update docs server/rosetta/client_online.go
fdymylja Mar 11, 2021
0c3bad6
Update docs server/rosetta/client_online.go
fdymylja Mar 11, 2021
d6e1622
cleanup spacing server/rosetta/converter_test.go
fdymylja Mar 11, 2021
f28f18d
revert: baseapp.md
fdymylja Mar 11, 2021
2f7a5c8
add: docs for interface implementation
fdymylja Mar 11, 2021
9fda8a2
remove: converter_test.go utils anonymous type
fdymylja Mar 11, 2021
958fba5
change: set interface name constant
fdymylja Mar 11, 2021
6354cfa
chore: add CHANGELOG.md entry
fdymylja Mar 11, 2021
3e47bb4
Merge branch 'master' into frojdi/rosetta-balance-tracking
Mar 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: begin and endblock tx conversions
  • Loading branch information
fdymylja committed Mar 5, 2021
commit a489652724c8fcf227cc368516601d3b1a097ca2
6 changes: 4 additions & 2 deletions server/rosetta/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,16 @@ func AddOperationIndexes(msgOps []*rosettatypes.Operation, balanceOps []*rosetta
// for endblock operations, it also serves the purpose of representing
// part of the state changes happening at endblock level (balance ones)
func (c converter) EndBlockTxHash(hash []byte) string {
return fmt.Sprintf("%X%X", EndBlockHashStart, hash)
final := append([]byte{EndBlockHashStart}, hash...)
return fmt.Sprintf("%X", final)
}

// beginBlockTxHash produces a mock beginblock hash that rosetta can query
// for beginblock operations, it also serves the purpose of representing
// part of the state changes happening at beginblock level (balance ones)
func (c converter) BeginBlockTxHash(hash []byte) string {
return fmt.Sprintf("%X%X", BeginBlockHashStart, hash)
final := append([]byte{BeginBlockHashStart}, hash...)
return fmt.Sprintf("%X", final)
}

// HashToTxType takes the provided hash bytes from rosetta and discerns if they are
Expand Down
32 changes: 32 additions & 0 deletions server/rosetta/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,38 @@ func (s *ConverterTestSuite) TestOpsAndSigners() {
})
}

func (s *ConverterTestSuite) TestBeginEndBlockAndHashToTxType() {
const deliverTxHex = "5229A67AA008B5C5F1A0AEA77D4DEBE146297A30AAEF01777AF10FAD62DD36AB"

deliverTxBytes, err := hex.DecodeString(deliverTxHex)
s.Require().NoError(err)

endBlockTxHex := s.c.ToRosetta().EndBlockTxHash(deliverTxBytes)
beginBlockTxHex := s.c.ToRosetta().BeginBlockTxHash(deliverTxBytes)

txType, hash := s.c.ToSDK().HashToTxType(deliverTxBytes)

s.Require().Equal(DeliverTxTx, txType)
s.Require().Equal(deliverTxBytes, hash, "deliver tx hash should not change")

endBlockTxBytes, err := hex.DecodeString(endBlockTxHex)
s.Require().NoError(err)

txType, hash = s.c.ToSDK().HashToTxType(endBlockTxBytes)

s.Require().Equal(EndBlockTx, txType)
s.Require().Equal(deliverTxBytes, hash, "end block tx hash should be equal to a block hash")

beginBlockTxBytes, err := hex.DecodeString(beginBlockTxHex)
s.Require().NoError(err)

txType, hash = s.c.ToSDK().HashToTxType(beginBlockTxBytes)

s.Require().Equal(BeginBlockTx, txType)
s.Require().Equal(deliverTxBytes, hash, "begin block tx hash should be equal to a block hash")

}

func TestConverterTestSuite(t *testing.T) {
suite.Run(t, new(ConverterTestSuite))
}