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

Bump oasis-core version to 20.9 #36

Merged
merged 4 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env gmake

OASIS_RELEASE := 20.8.2
OASIS_RELEASE := 20.9
ROSETTA_CLI_RELEASE := 0.4.0

OASIS_GO ?= go
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ FROM golang:1.14-alpine AS build
# Install prerequisites.
RUN rm -f /var/cache/apk/*; apk --no-cache add bash git make gcc g++ libressl-dev libseccomp-dev linux-headers

ARG CORE_BRANCH="v20.8.2"
ARG CORE_BRANCH="v20.9"
ARG GATEWAY_BRANCH="master"

# Fetch and build oasis-core.
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/coinbase/rosetta-sdk-go v0.3.3
github.com/dgraph-io/badger v1.6.1
github.com/oasisprotocol/ed25519 v0.0.0-20200528083105-55566edd6df0
github.com/oasisprotocol/oasis-core/go v0.0.0-20200702171459-20d1a2dc6b66
github.com/oasisprotocol/oasis-core/go v0.20.9
github.com/vmihailenco/msgpack/v5 v5.0.0-beta.1
google.golang.org/grpc v1.29.1
google.golang.org/grpc v1.31.0
)
7 changes: 3 additions & 4 deletions oasis-client/oasis-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type OasisClient interface {
GetAccount(ctx context.Context, height int64, owner staking.Address) (*staking.Account, error)

// GetStakingEvents returns Oasis staking events at given height.
GetStakingEvents(ctx context.Context, height int64) ([]staking.Event, error)
GetStakingEvents(ctx context.Context, height int64) ([]*staking.Event, error)

// SubmitTx submits the given JSON-encoded transaction to the node.
SubmitTx(ctx context.Context, txRaw string) error
Expand Down Expand Up @@ -205,7 +205,7 @@ func (oc *grpcOasisClient) GetAccount(ctx context.Context, height int64, owner s
})
}

func (oc *grpcOasisClient) GetStakingEvents(ctx context.Context, height int64) ([]staking.Event, error) {
func (oc *grpcOasisClient) GetStakingEvents(ctx context.Context, height int64) ([]*staking.Event, error) {
conn, err := oc.connect(ctx)
if err != nil {
return nil, err
Expand All @@ -218,8 +218,7 @@ func (oc *grpcOasisClient) GetStakingEvents(ctx context.Context, height int64) (
// Change empty hashes to block hashes, as they belong to block events.
var gotBlkHash bool
var blkHash []byte
for i := range evts {
e := &evts[i]
for _, e := range evts {
if e.TxHash.IsEmpty() {
if !gotBlkHash {
// First time, need to fetch the block hash.
Expand Down
18 changes: 9 additions & 9 deletions services/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,24 @@ func (s *blockAPIService) Block(

switch {
case evt.Transfer != nil:
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(evt.Transfer.From), nil, "-"+evt.Transfer.Tokens.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(evt.Transfer.To), nil, evt.Transfer.Tokens.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(evt.Transfer.From), nil, "-"+evt.Transfer.Amount.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(evt.Transfer.To), nil, evt.Transfer.Amount.String())
case evt.Burn != nil:
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpBurn, StringFromAddress(evt.Burn.Owner), nil, "-"+evt.Burn.Tokens.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpBurn, StringFromAddress(evt.Burn.Owner), nil, "-"+evt.Burn.Amount.String())
case evt.Escrow != nil:
ee := evt.Escrow
switch {
case ee.Add != nil:
// Owner's general account -> escrow account.
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(ee.Add.Owner), nil, "-"+ee.Add.Tokens.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(ee.Add.Escrow), &types.SubAccountIdentifier{Address: SubAccountEscrow}, ee.Add.Tokens.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(ee.Add.Owner), nil, "-"+ee.Add.Amount.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(ee.Add.Escrow), &types.SubAccountIdentifier{Address: SubAccountEscrow}, ee.Add.Amount.String())
case ee.Take != nil:
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(ee.Take.Owner), &types.SubAccountIdentifier{Address: SubAccountEscrow}, "-"+ee.Take.Tokens.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(staking.CommonPoolAddress), nil, ee.Take.Tokens.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(ee.Take.Owner), &types.SubAccountIdentifier{Address: SubAccountEscrow}, "-"+ee.Take.Amount.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(staking.CommonPoolAddress), nil, ee.Take.Amount.String())
case ee.Reclaim != nil:
// Escrow account -> owner's general account.
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(ee.Reclaim.Escrow), &types.SubAccountIdentifier{Address: SubAccountEscrow}, "-"+ee.Reclaim.Tokens.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(ee.Reclaim.Owner), nil, ee.Reclaim.Tokens.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(ee.Reclaim.Escrow), &types.SubAccountIdentifier{Address: SubAccountEscrow}, "-"+ee.Reclaim.Amount.String())
txns[txidx].Operations = appendOp(txns[txidx].Operations, OpTransfer, StringFromAddress(ee.Reclaim.Owner), nil, ee.Reclaim.Amount.String())
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions services/construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func (s *constructionAPIService) ConstructionParse(
Address: from,
},
Amount: &types.Amount{
Value: "-" + body.Tokens.String(),
Value: "-" + body.Amount.String(),
Currency: OasisCurrency,
},
},
Expand All @@ -419,7 +419,7 @@ func (s *constructionAPIService) ConstructionParse(
Address: StringFromAddress(body.To),
},
Amount: &types.Amount{
Value: body.Tokens.String(),
Value: body.Amount.String(),
Currency: OasisCurrency,
},
},
Expand All @@ -443,7 +443,7 @@ func (s *constructionAPIService) ConstructionParse(
Address: from,
},
Amount: &types.Amount{
Value: "-" + body.Tokens.String(),
Value: "-" + body.Amount.String(),
Currency: OasisCurrency,
},
},
Expand All @@ -467,7 +467,7 @@ func (s *constructionAPIService) ConstructionParse(
Address: from,
},
Amount: &types.Amount{
Value: "-" + body.Tokens.String(),
Value: "-" + body.Amount.String(),
Currency: OasisCurrency,
},
},
Expand All @@ -483,7 +483,7 @@ func (s *constructionAPIService) ConstructionParse(
},
},
Amount: &types.Amount{
Value: body.Tokens.String(),
Value: body.Amount.String(),
Currency: OasisCurrency,
},
},
Expand Down Expand Up @@ -730,7 +730,7 @@ func (s *constructionAPIService) ConstructionPayloads(

body = cbor.Marshal(staking.Transfer{
To: to,
Tokens: *amount,
Amount: *amount,
})
case len(remainingOps) == 1 &&
remainingOps[0].Type == OpBurn &&
Expand All @@ -757,7 +757,7 @@ func (s *constructionAPIService) ConstructionPayloads(
}

body = cbor.Marshal(staking.Burn{
Tokens: *amount,
Amount: *amount,
})
case len(remainingOps) == 2 &&
remainingOps[0].Type == OpTransfer &&
Expand Down Expand Up @@ -812,7 +812,7 @@ func (s *constructionAPIService) ConstructionPayloads(

body = cbor.Marshal(staking.Escrow{
Account: escrowAccount,
Tokens: *amount,
Amount: *amount,
})
// TODO: Devise a way to support reclaim escrow.
default:
Expand Down
6 changes: 3 additions & 3 deletions tests/construction-txtypes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func main() {
Method: api.MethodTransfer,
Body: cbor.Marshal(api.Transfer{
To: dstAddr,
Tokens: *quantity.NewFromUint64(1000),
Amount: *quantity.NewFromUint64(1000),
}),
}
opsBurn := []*types.Operation{
Expand All @@ -120,7 +120,7 @@ func main() {
Fee: fee100,
Method: api.MethodBurn,
Body: cbor.Marshal(api.Burn{
Tokens: *quantity.NewFromUint64(1000),
Amount: *quantity.NewFromUint64(1000),
}),
}
opsAddEscrow := []*types.Operation{
Expand Down Expand Up @@ -162,7 +162,7 @@ func main() {
Method: api.MethodAddEscrow,
Body: cbor.Marshal(api.Escrow{
Account: dstAddr,
Tokens: *quantity.NewFromUint64(1000),
Amount: *quantity.NewFromUint64(1000),
}),
}

Expand Down
12 changes: 9 additions & 3 deletions tests/test-fixture-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
},
"network": {
"node_binary": "oasis-node",
"consensus_backend": "",
"consensus_timeout_commit": 1000000000,
"consensus_gas_costs_tx_byte": 0,
"consensus": {
"backend": "",
"params": {
"timeout_commit": 1000000000,
"gas_costs": {
"tx_byte": 0
}
}
},
"halt_epoch": 18446744073709551615,
"epochtime_mock": true,
"epochtime_tendermint_interval": 0,
Expand Down
4 changes: 3 additions & 1 deletion tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ gen_transfer() {
local amount=$2
local dst=$3
${OASIS_NODE} stake account gen_transfer \
--assume_yes \
--stake.amount $amount \
--stake.transfer.destination "$dst" \
--transaction.file "$tx" \
Expand All @@ -100,6 +101,7 @@ gen_burn() {
local tx=$1
local amount=$2
${OASIS_NODE} stake account gen_burn \
--assume_yes \
--stake.amount $amount \
--transaction.file "$tx" \
--transaction.nonce ${NONCE} \
Expand Down Expand Up @@ -163,7 +165,7 @@ go run ./check-prep
# We'll cause a sigpipe on this process, so ignore the exit status.
# The downstream awk will exit with nonzero status if this test actually fails without confirming any transactions.
./rosetta-cli --configuration-file rosetta-cli-config.json check:construction || true
} | awk '{ print $0 }; $1 == "[STATS]" && $4 >= 42 { confirmed = 1; exit }; END { exit !confirmed }'
} | stdbuf -oL awk '{ print $0 }; $1 == "[STATS]" && $4 >= 42 { confirmed = 1; exit }; END { exit !confirmed }'
rm -rf "${ROOT}/validator-data" /tmp/rosetta-cli*

printf "${GRN}### Testing construction signing workflow...${OFF}\n"
Expand Down