Skip to content

Commit

Permalink
Rosetta Implementation - pt2 FIX (Stage 3.2 of Node API Overhaul) (#3321
Browse files Browse the repository at this point in the history
)

* [rosetta] Fix decimal precision on staking transactions

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [rosetta] Add GenesisFundsOperation & PreStakingEraBlockRewardsOperation

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [rosetta] Add special case transaction ID & refactor to use

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [hmy] Fix block signer mask creation

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [staking] Update docs for block reward

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [rosetta] Rename PreStakingEraBlockRewardOperation

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [rosetta] Add pre-staking block reward txs & refactor special cases

* Add getBlockSigner info
* Rename vars named block to blk for pkg imports
* Add unit tests for block reward formatting

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [rosetta] Fix lint

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [rosetta] Add new line to rosetta start msg

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [go.mod] Correct go mod

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [rosetta] Make pre-staking block rewards calc same as AccumulateRewardsAndCountSigs

* Change committee to signers for blockSignerInfo

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [rosetta] Add sanity check for pre-staking block reward amount

* Correct network chain for sync status

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>

* [rosetta] Improve unpackSpecialCaseTransactionIdentifier unit test

Signed-off-by: Daniel Van Der Maden <dvandermaden0@berkeley.edu>
  • Loading branch information
Daniel-VDM authored Aug 28, 2020
1 parent 2272237 commit 67e4c97
Show file tree
Hide file tree
Showing 9 changed files with 489 additions and 81 deletions.
17 changes: 6 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@ require (
github.com/golang/mock v1.4.0
github.com/golang/protobuf v1.4.0
github.com/golangci/golangci-lint v1.22.2
github.com/gorilla/handlers v1.4.0 // indirect
github.com/gorilla/mux v1.7.4
github.com/gorilla/websocket v1.4.2
github.com/gorilla/websocket v1.4.2 // indirect
github.com/harmony-ek/gencodec v0.0.0-20190215044613-e6740dbdd846
github.com/harmony-one/abool v1.0.1
github.com/harmony-one/bls v0.0.6
github.com/harmony-one/taggedrlp v0.1.4
github.com/harmony-one/vdf v0.0.0-20190924175951-620379da8849
github.com/hashicorp/golang-lru v0.5.4
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365 // indirect
github.com/ipfs/go-ds-badger v0.2.4
github.com/jackpal/gateway v1.0.6 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/karalabe/hid v1.0.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
Expand All @@ -41,16 +39,15 @@ require (
github.com/libp2p/go-libp2p-core v0.6.1
github.com/libp2p/go-libp2p-crypto v0.1.0
github.com/libp2p/go-libp2p-discovery v0.5.0
github.com/libp2p/go-libp2p-host v0.1.0
github.com/libp2p/go-libp2p-host v0.1.0 // indirect
github.com/libp2p/go-libp2p-kad-dht v0.8.3
github.com/libp2p/go-libp2p-net v0.1.0
github.com/libp2p/go-libp2p-peer v0.2.0
github.com/libp2p/go-libp2p-peerstore v0.2.6
github.com/libp2p/go-libp2p-net v0.1.0 // indirect
github.com/libp2p/go-libp2p-peer v0.2.0 // indirect
github.com/libp2p/go-libp2p-peerstore v0.2.6 // indirect
github.com/libp2p/go-libp2p-pubsub v0.3.3
github.com/multiformats/go-multiaddr v0.2.2
github.com/multiformats/go-multiaddr-net v0.1.5
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/otiai10/copy v1.2.0
github.com/pborman/uuid v1.2.0
github.com/pelletier/go-toml v1.2.0
github.com/pkg/errors v0.9.1
Expand All @@ -65,8 +62,6 @@ require (
github.com/spf13/viper v1.6.1
github.com/stretchr/testify v1.6.1
github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d
github.com/uber/jaeger-client-go v2.20.1+incompatible // indirect
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
golang.org/x/lint v0.0.0-20200302205851-738671d3881b
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
Expand Down
10 changes: 7 additions & 3 deletions hmy/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ func (hmy *Harmony) GetBlockSigners(
return nil, nil, err
}
pubKeys := make([]internal_bls.PublicKeyWrapper, len(committee.Slots))
for _, validator := range committee.Slots {
wrapper := internal_bls.PublicKeyWrapper{Bytes: validator.BLSPublicKey}
if wrapper.Object, err = bls.BytesToBLSPublicKey(wrapper.Bytes[:]); err != nil {
for i, validator := range committee.Slots {
key, err := bls.BytesToBLSPublicKey(validator.BLSPublicKey[:])
if err != nil {
return nil, nil, err
}
pubKeys[i] = internal_bls.PublicKeyWrapper{
Bytes: validator.BLSPublicKey,
Object: key,
}
}
mask, err := internal_bls.NewMask(pubKeys, nil)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions rosetta/common/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ const (

// ContractCreationOperation ..
ContractCreationOperation = "ContractCreation"

// GenesisFundsOperation ..
GenesisFundsOperation = "Genesis"

// PreStakingEraBlockRewardOperation ..
PreStakingEraBlockRewardOperation = "PreStakingBlockReward"
)

var (
Expand All @@ -26,6 +32,8 @@ var (
TransferOperation,
CrossShardTransferOperation,
ContractCreationOperation,
GenesisFundsOperation,
PreStakingEraBlockRewardOperation,
}

// StakingOperationTypes ..
Expand Down
2 changes: 2 additions & 0 deletions rosetta/common/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func TestPlainOperationTypes(t *testing.T) {
TransferOperation,
CrossShardTransferOperation,
ContractCreationOperation,
GenesisFundsOperation,
PreStakingEraBlockRewardOperation,
}
sort.Strings(referenceOperationTypes)
sort.Strings(plainOperationTypes)
Expand Down
2 changes: 1 addition & 1 deletion rosetta/rosetta.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func StartServers(hmy *hmy.Harmony, config nodeconfig.RosettaServerConfig) error
return err
}
go newHTTPServer(router).Serve(listener)
fmt.Printf("Started Rosetta server at: %v", endpoint)
fmt.Printf("Started Rosetta server at: %v\n", endpoint)
return nil
}

Expand Down
Loading

0 comments on commit 67e4c97

Please sign in to comment.