Skip to content

Commit

Permalink
refactor: remove facilitator
Browse files Browse the repository at this point in the history
* use events for lease, order creation
* reconstruct transactions from events for listeners
  • Loading branch information
boz committed Nov 19, 2019
1 parent 3199975 commit 730d0d8
Show file tree
Hide file tree
Showing 29 changed files with 600 additions and 1,038 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ test-vet:
deps-install:
$(GO) mod download

deps-tidy:
$(GO) mod tidy

devdeps-install:
$(GO) install github.com/gogo/protobuf/protoc-gen-gogo
$(GO) install github.com/vektra/mockery/.../
Expand Down
2 changes: 1 addition & 1 deletion _run/multi/akash-node/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: apps/v1beta2
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "akash-node.fullname" . }}
Expand Down
4 changes: 3 additions & 1 deletion _run/multi/akash-provider/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: apps/v1beta2
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "akash-provider.fullname" . }}
Expand Down Expand Up @@ -34,6 +34,8 @@ spec:
value: "true"
- name: AKASH_DEPLOYMENT_INGRESS_DOMAIN
value: "{{ .Values.deployment.ingress.domain }}"
- name: AKASH_PROVIDER_FAKE_CAPACITY
value: "true"
ports:
- containerPort: {{ .Values.provider.port }}
name: http
Expand Down
2 changes: 1 addition & 1 deletion _run/multi/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
accept:
- hello.192.168.99.132.nip.io
- hello.192.168.99.130.nip.io
- hello.192.168.99.112.nip.io
to:
- global: true

Expand All @@ -22,7 +23,6 @@ profiles:
placement:
westcoast:
attributes:
region: us-west
pricing:
web: 100u

Expand Down
54 changes: 9 additions & 45 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package app

import (
"context"
"encoding/json"
"errors"

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

type Application interface {
abci_types.Application
ActivateMarket(market.Actor) error

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

apps []apptypes.Application

mfacilitator market.Driver

log log.Logger
}

Expand Down Expand Up @@ -117,29 +112,6 @@ func (app *app) App(name string) apptypes.Application {
return nil
}

func (app *app) ActivateMarket(actor market.Actor) error {

if app.mfacilitator != nil {
return errors.New("market already activated")
}

mapp, err := market.NewApp(app.log.With("app", market.Name))
if err != nil {
return err
}

mfacilitator, err := market.NewDriver(context.Background(), app.log.With("app", "market-facilitator"), actor)
if err != nil {
return err
}

app.mfacilitator = mfacilitator

app.apps = append(app.apps, mapp)

return nil
}

func (app *app) Info(req abci_types.RequestInfo) abci_types.ResponseInfo {
vsn, _ := json.Marshal(version.Get())
return abci_types.ResponseInfo{
Expand Down Expand Up @@ -236,26 +208,25 @@ func (app *app) DeliverTx(req abci_types.RequestDeliverTx) abci_types.ResponseDe

func (app *app) BeginBlock(req abci_types.RequestBeginBlock) abci_types.ResponseBeginBlock {
app.trace("BeginBlock", "tmhash", util.X(req.Hash))

if app.mfacilitator != nil {
app.mfacilitator.OnBeginBlock(req)
}

return abci_types.ResponseBeginBlock{}
}

func (app *app) EndBlock(req abci_types.RequestEndBlock) abci_types.ResponseEndBlock {
app.trace("EndBlock")
return abci_types.ResponseEndBlock{}

events, err := market.NewEngine(app.log).Run(app.cacheState)
if err != nil {
app.log.Error("ERROR RUNNING ENGINE: ", "error", err)
}

return abci_types.ResponseEndBlock{
Events: events,
}
}

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

if err := lease.ProcessLeases(app.cacheState); err != nil {
app.log.Error("processing leases", "error", err)
}

if err := app.cacheState.Write(); err != nil {
panic("error when writing to cache")
}
Expand All @@ -265,13 +236,6 @@ func (app *app) Commit() abci_types.ResponseCommit {
return abci_types.ResponseCommit{Data: data}
}

if app.mfacilitator != nil {
err := app.mfacilitator.OnCommit(app.commitState)
if err != nil {
app.log.Error("error in facilitator.OnCommit", err.Error())
}
}

return abci_types.ResponseCommit{Data: data}
}

Expand Down
2 changes: 0 additions & 2 deletions app/deployment/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ func (a *app) doCheckCloseTx(state appstate.State, ctx apptypes.Context, tx *typ
}

switch tx.Reason {
case types.TxCloseDeployment_INSUFFICIENT:
// XXX: signer must be block's facilitator
case types.TxCloseDeployment_TENANT_CLOSE:
if !bytes.Equal(ctx.Signer().Address(), deployment.Tenant) {
return abci_types.ResponseCheckTx{
Expand Down
Loading

0 comments on commit 730d0d8

Please sign in to comment.