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

Billing #154

Merged
merged 7 commits into from
Mar 27, 2018
Merged

Billing #154

merged 7 commits into from
Mar 27, 2018

Conversation

aastein
Copy link
Contributor

@aastein aastein commented Mar 27, 2018

fixes #142
fixes #151

On lease create, check if tenant has balance >= lease price
process leases in market engine
for each active lease, send a billTenantTx
Lease app accepts and checks BillTenantTx
Lease app subtracts lease.Price from the tenant and sends lease.Price to the provider.

@aastein aastein requested a review from boz as a code owner March 27, 2018 19:58
@aastein aastein closed this Mar 27, 2018
@aastein aastein reopened this Mar 27, 2018
@coveralls
Copy link

coveralls commented Mar 27, 2018

Pull Request Test Coverage Report for Build 124

  • 35 of 65 (53.85%) changed or added relevant lines in 5 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+6.2%) to 66.197%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/app.go 0 3 0.0%
app/lease/app.go 31 58 53.45%
Files with Coverage Reduction New Missed Lines %
app/app.go 1 48.66%
testutil/shrug.go 3 0.0%
Totals Coverage Status
Change from base Build 115: 6.2%
Covered Lines: 3147
Relevant Lines: 4754

💛 - Coveralls

Copy link
Contributor

@boz boz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Couple comments inline.

app/app.go Outdated
@@ -235,6 +235,8 @@ func (app *app) Commit() tmtypes.ResponseCommit {
app.mfacilitator.OnCommit(app.state)
}

lease.ProcessLeases(app.state)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.Error() or similar.

for idx := range groups.GetItems() {
require.NoError(t, state_.DeploymentGroup().Save(groups.GetItems()[idx]))
require.NoError(t, state.DeploymentGroup().Save(groups.GetItems()[idx]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be able to do the

for _, item := range groups.GetItems() {
  require.NoError(t,state.Save(item))
}

thing here.

)

const (
maxTokens uint64 = 1000000000
maxTokens uint64 = math.MaxUint64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will screw up the integration tests here.

  • Simple matter of changing the value in the test or ideally just referencing a constant.
  • The json lib we're using there maxes out at int64 which won't be able to hold math.MaxUint64.
  • Also, I think we're supposed to have a billion tokens total.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it read it as -1:

Evaluation of main failed:
/main/account-send/account-balance/akash: ../akash -d ./data/client query account 22CDFF3E908986DE2F4B1D279667BA02B84CD7D6: balance: received -1 expected 1000000000
-===[BEGIN STDOUT]===-
{
  "address": "22CDFF3E908986DE2F4B1D279667BA02B84CD7D6",
  "balance": 18446744073709551615
}

@@ -20,6 +21,7 @@ func CreateAccount(t *testing.T, state state.State) (*types.Account, crypto.Priv
key := PrivateKey(t)
account := &types.Account{
Address: key.PubKey().Address(),
Balance: math.MaxUint64 / 2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah let's do a constant somewhere for initial token count.

@@ -87,7 +87,7 @@ func (e engine) processDeployment(state state.State, w txBuffer, deployment type
if !activeFound && order.State == types.Order_OPEN || order.State == types.Order_MATCHED {
activeFound = true
}
if order.EndAt <= height {
if order.State == types.Order_OPEN && order.EndAt <= height {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@aastein aastein merged commit b66b6ec into master Mar 27, 2018
@aastein aastein deleted the billing branch March 27, 2018 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flapping test: cmd/akash/connection_test.go Lease Billing
3 participants