Skip to content

Commit 98f5158

Browse files
authored
migrate: remove facilitator, use tendermint events (#429)
* refactor: remove facilitator * use events for lease, order creation * reconstruct transactions from events for listeners * refactor: remove failing tests * genesis: set initial token supply to 100M AKT (#428) * run: add minikube ip Signed-off-by: Greg Osuri <me@gregosuri.com>
1 parent 57fb473 commit 98f5158

File tree

38 files changed

+659
-1431
lines changed

38 files changed

+659
-1431
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
upstream/uitable: fix IOR error during empty listing [#421] (#422)

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ test-vet:
7979
deps-install:
8080
$(GO) mod download
8181

82+
deps-tidy:
83+
$(GO) mod tidy
84+
8285
devdeps-install:
8386
$(GO) install github.com/gogo/protobuf/protoc-gen-gogo
8487
$(GO) install github.com/vektra/mockery/.../

_integration/cmp/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func accountSendTo(from key, to key, amount int64) gestalt.Component {
2525
}
2626

2727
func groupAccountSend(key key) gestalt.Component {
28-
start := int64(1000000000000000)
28+
start := int64(100000000000000)
2929
amount := int64(100)
3030
other := newKey("other")
3131
return g.Group("account-send").

_run/multi/akash-node/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: apps/v1beta2
1+
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: {{ template "akash-node.fullname" . }}

_run/multi/akash-provider/templates/deployment.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: apps/v1beta2
1+
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: {{ template "akash-provider.fullname" . }}
@@ -34,6 +34,8 @@ spec:
3434
value: "true"
3535
- name: AKASH_DEPLOYMENT_INGRESS_DOMAIN
3636
value: "{{ .Values.deployment.ingress.domain }}"
37+
- name: AKASH_PROVIDER_FAKE_CAPACITY
38+
value: "true"
3739
ports:
3840
- containerPort: {{ .Values.provider.port }}
3941
name: http

_run/multi/deployment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ services:
1010
accept:
1111
- hello.192.168.99.132.nip.io
1212
- hello.192.168.99.130.nip.io
13+
- hello.192.168.99.112.nip.io
14+
- hello.192.168.64.2.nip.io
1315
to:
1416
- global: true
1517

@@ -22,7 +24,6 @@ profiles:
2224
placement:
2325
westcoast:
2426
attributes:
25-
region: us-west
2627
pricing:
2728
web: 100u
2829

app/app.go

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package app
22

33
import (
4-
"context"
54
"encoding/json"
6-
"errors"
75

86
"github.com/gogo/protobuf/jsonpb"
97
"github.com/ovrclk/akash/app/account"
@@ -27,7 +25,6 @@ import (
2725

2826
type Application interface {
2927
abci_types.Application
30-
ActivateMarket(market.Actor) error
3128

3229
App(name string) apptypes.Application
3330
}
@@ -40,8 +37,6 @@ type app struct {
4037

4138
apps []apptypes.Application
4239

43-
mfacilitator market.Driver
44-
4540
log log.Logger
4641
}
4742

@@ -117,29 +112,6 @@ func (app *app) App(name string) apptypes.Application {
117112
return nil
118113
}
119114

120-
func (app *app) ActivateMarket(actor market.Actor) error {
121-
122-
if app.mfacilitator != nil {
123-
return errors.New("market already activated")
124-
}
125-
126-
mapp, err := market.NewApp(app.log.With("app", market.Name))
127-
if err != nil {
128-
return err
129-
}
130-
131-
mfacilitator, err := market.NewDriver(context.Background(), app.log.With("app", "market-facilitator"), actor)
132-
if err != nil {
133-
return err
134-
}
135-
136-
app.mfacilitator = mfacilitator
137-
138-
app.apps = append(app.apps, mapp)
139-
140-
return nil
141-
}
142-
143115
func (app *app) Info(req abci_types.RequestInfo) abci_types.ResponseInfo {
144116
vsn, _ := json.Marshal(version.Get())
145117
return abci_types.ResponseInfo{
@@ -236,26 +208,25 @@ func (app *app) DeliverTx(req abci_types.RequestDeliverTx) abci_types.ResponseDe
236208

237209
func (app *app) BeginBlock(req abci_types.RequestBeginBlock) abci_types.ResponseBeginBlock {
238210
app.trace("BeginBlock", "tmhash", util.X(req.Hash))
239-
240-
if app.mfacilitator != nil {
241-
app.mfacilitator.OnBeginBlock(req)
242-
}
243-
244211
return abci_types.ResponseBeginBlock{}
245212
}
246213

247214
func (app *app) EndBlock(req abci_types.RequestEndBlock) abci_types.ResponseEndBlock {
248215
app.trace("EndBlock")
249-
return abci_types.ResponseEndBlock{}
216+
217+
events, err := market.NewEngine(app.log).Run(app.cacheState)
218+
if err != nil {
219+
app.log.Error("ERROR RUNNING ENGINE: ", "error", err)
220+
}
221+
222+
return abci_types.ResponseEndBlock{
223+
Events: events,
224+
}
250225
}
251226

252227
func (app *app) Commit() abci_types.ResponseCommit {
253228
app.trace("Commit")
254229

255-
if err := lease.ProcessLeases(app.cacheState); err != nil {
256-
app.log.Error("processing leases", "error", err)
257-
}
258-
259230
if err := app.cacheState.Write(); err != nil {
260231
panic("error when writing to cache")
261232
}
@@ -265,13 +236,6 @@ func (app *app) Commit() abci_types.ResponseCommit {
265236
return abci_types.ResponseCommit{Data: data}
266237
}
267238

268-
if app.mfacilitator != nil {
269-
err := app.mfacilitator.OnCommit(app.commitState)
270-
if err != nil {
271-
app.log.Error("error in facilitator.OnCommit", err.Error())
272-
}
273-
}
274-
275239
return abci_types.ResponseCommit{Data: data}
276240
}
277241

app/app_test.go

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@ import (
44
"testing"
55

66
app_ "github.com/ovrclk/akash/app"
7-
dapp_ "github.com/ovrclk/akash/app/deployment"
8-
fapp_ "github.com/ovrclk/akash/app/fulfillment"
9-
lapp_ "github.com/ovrclk/akash/app/lease"
10-
oapp_ "github.com/ovrclk/akash/app/order"
11-
papp_ "github.com/ovrclk/akash/app/provider"
127
"github.com/ovrclk/akash/testutil"
138
"github.com/ovrclk/akash/txutil"
149
"github.com/ovrclk/akash/types"
1510
"github.com/ovrclk/akash/types/code"
16-
"github.com/stretchr/testify/assert"
1711
"github.com/stretchr/testify/require"
1812
abci_types "github.com/tendermint/tendermint/abci/types"
1913
)
@@ -96,80 +90,3 @@ func TestApp(t *testing.T) {
9690
}
9791

9892
}
99-
100-
func TestLeaseTransfer(t *testing.T) {
101-
const (
102-
price = 10
103-
balance = 100000
104-
)
105-
nonce := uint64(1)
106-
107-
_, keyfrom := testutil.PrivateKeySigner(t)
108-
addrfrom := keyfrom.PubKey().Address().Bytes()
109-
110-
keyto := testutil.PrivateKey(t)
111-
addrto := keyto.PubKey().Address().Bytes()
112-
113-
commitState, cacheState := testutil.NewState(t, &types.Genesis{
114-
Accounts: []types.Account{
115-
{Address: addrfrom, Balance: balance, Nonce: nonce},
116-
{Address: addrto, Balance: 0, Nonce: nonce},
117-
},
118-
})
119-
120-
tacct, err := cacheState.Account().Get(addrfrom)
121-
require.NoError(t, err)
122-
123-
pacct, err := cacheState.Account().Get(addrto)
124-
require.NoError(t, err)
125-
126-
nonce++
127-
128-
app, err := app_.Create(commitState, cacheState, testutil.Logger())
129-
require.NoError(t, err)
130-
131-
dapp := app.App(dapp_.Name)
132-
require.NotNil(t, dapp)
133-
134-
oapp := app.App(oapp_.Name)
135-
require.NotNil(t, oapp)
136-
137-
lapp := app.App(lapp_.Name)
138-
require.NotNil(t, lapp)
139-
140-
papp := app.App(papp_.Name)
141-
require.NotNil(t, papp)
142-
143-
fapp := app.App(fapp_.Name)
144-
require.NotNil(t, fapp)
145-
146-
provider := testutil.CreateProvider(t, cacheState, papp, pacct, keyto, nonce)
147-
148-
deployment, groups := testutil.CreateDeployment(t, cacheState, dapp, tacct, keyfrom, nonce)
149-
group := groups.Items[0]
150-
151-
order := testutil.CreateOrder(t, cacheState, oapp, tacct, keyfrom, deployment.Address, group.Seq, group.Seq)
152-
testutil.CreateFulfillment(t, cacheState, fapp, provider.Address, keyto, deployment.Address, group.Seq, order.Seq, price)
153-
lease := testutil.CreateLease(t, cacheState, lapp, provider.Address, keyto, deployment.Address, group.Seq, order.Seq, price)
154-
155-
app.Commit()
156-
157-
pacct, err = commitState.Account().Get(addrto)
158-
require.NoError(t, err)
159-
assert.Equal(t, uint64(lease.Price), pacct.Balance)
160-
161-
tacct, err = commitState.Account().Get(addrfrom)
162-
require.NoError(t, err)
163-
assert.Equal(t, uint64(balance-lease.Price), tacct.Balance)
164-
165-
app.Commit()
166-
167-
pacct, err = commitState.Account().Get(addrto)
168-
require.NoError(t, err)
169-
assert.Equal(t, uint64(lease.Price)*2, pacct.Balance)
170-
171-
tacct, err = commitState.Account().Get(addrfrom)
172-
require.NoError(t, err)
173-
assert.Equal(t, uint64(balance-lease.Price*2), tacct.Balance)
174-
175-
}

app/deployment/app.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,6 @@ func (a *app) doCheckCloseTx(state appstate.State, ctx apptypes.Context, tx *typ
347347
}
348348

349349
switch tx.Reason {
350-
case types.TxCloseDeployment_INSUFFICIENT:
351-
// XXX: signer must be block's facilitator
352350
case types.TxCloseDeployment_TENANT_CLOSE:
353351
if !bytes.Equal(ctx.Signer().Address(), deployment.Tenant) {
354352
return abci_types.ResponseCheckTx{

app/deployment/app_test.go

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/ovrclk/akash/app/deployment"
88
"github.com/ovrclk/akash/app/fulfillment"
9-
"github.com/ovrclk/akash/app/lease"
109
"github.com/ovrclk/akash/app/order"
1110
"github.com/ovrclk/akash/app/provider"
1211
apptypes "github.com/ovrclk/akash/app/types"
@@ -280,57 +279,6 @@ func TestCloseTx_3(t *testing.T) {
280279
check(types.Deployment_CLOSED, types.DeploymentGroup_CLOSED, types.Order_CLOSED, types.Fulfillment_CLOSED)
281280
}
282281

283-
func TestCloseTx_4(t *testing.T) {
284-
285-
const (
286-
gseq = 1
287-
oseq = 3
288-
price = 1
289-
)
290-
291-
_, cacheState := testutil.NewState(t, nil)
292-
app, err := deployment.NewApp(testutil.Logger())
293-
require.NoError(t, err)
294-
account, key := testutil.CreateAccount(t, cacheState)
295-
nonce := uint64(1)
296-
depl, _ := testutil.CreateDeployment(t, cacheState, app, account, key, nonce)
297-
298-
orderapp, err := order.NewApp(testutil.Logger())
299-
require.NoError(t, err)
300-
order := testutil.CreateOrder(t, cacheState, orderapp, account, key, depl.Address, gseq, oseq)
301-
302-
providerapp, err := provider.NewApp(testutil.Logger())
303-
require.NoError(t, err)
304-
prov := testutil.CreateProvider(t, cacheState, providerapp, account, key, nonce)
305-
306-
fulfillmentapp, err := fulfillment.NewApp(testutil.Logger())
307-
require.NoError(t, err)
308-
fulfillment := testutil.CreateFulfillment(t, cacheState, fulfillmentapp, prov.Address, key, depl.Address, gseq, oseq, price)
309-
310-
leaseapp, err := lease.NewApp(testutil.Logger())
311-
require.NoError(t, err)
312-
lease := testutil.CreateLease(t, cacheState, leaseapp, prov.Address, key, depl.Address, gseq, oseq, price)
313-
314-
check := func(
315-
dstate types.Deployment_DeploymentState,
316-
gstate types.DeploymentGroup_DeploymentGroupState,
317-
ostate types.Order_OrderState,
318-
fstate types.Fulfillment_FulfillmentState,
319-
lstate types.Lease_LeaseState) {
320-
assertDeploymentState(t, cacheState, app, depl.Address, dstate)
321-
assertDeploymentGroupState(t, cacheState, app, order.GroupID(), gstate)
322-
assertOrderState(t, cacheState, orderapp, order.OrderID, ostate)
323-
assertFulfillmentState(t, cacheState, fulfillmentapp, fulfillment.FulfillmentID, fstate)
324-
assertLeaseState(t, cacheState, leaseapp, lease.LeaseID, lstate)
325-
}
326-
327-
check(types.Deployment_ACTIVE, types.DeploymentGroup_OPEN, types.Order_MATCHED, types.Fulfillment_OPEN, types.Lease_ACTIVE)
328-
329-
testutil.CloseDeployment(t, cacheState, app, &depl.Address, key)
330-
331-
check(types.Deployment_CLOSED, types.DeploymentGroup_CLOSED, types.Order_CLOSED, types.Fulfillment_CLOSED, types.Lease_CLOSED)
332-
}
333-
334282
// check deployment and group query & status
335283
func assertDeploymentState(
336284
t *testing.T,

0 commit comments

Comments
 (0)