Skip to content

Commit fb8b145

Browse files
authored
v2 script updates (#41)
* v2 script updates * updates for v2
1 parent 282dff2 commit fb8b145

14 files changed

+96
-67
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ indexer/.DS_Store
66
.env*
77
docs/swagger.html
88
docs/swagger.yaml
9-
9+
.arkeo/
10+
.sentinel/

db/001_initial.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ create table provider_status
66
status text not null unique
77
);
88

9-
insert into provider_status(status) values ('Online');
10-
insert into provider_status(status) values ('Offline');
9+
insert into provider_status(status) values ('ONLINE');
10+
insert into provider_status(status) values ('OFFLINE');
1111

1212
create table contract_types
1313
(
@@ -18,9 +18,9 @@ create table contract_types
1818
);
1919

2020
insert into contract_types(val)
21-
values ('PayAsYouGo');
21+
values ('PAY_AS_YOU_GO');
2222
insert into contract_types(val)
23-
values ('Subscription');
23+
values ('SUBSCRIPTION');
2424

2525
---- create above / drop below ----
2626
-- undo --

docker-compose.yaml

+50-12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@ networks:
66
attachable: true
77

88
services:
9+
arkeod:
10+
hostname: arkeod
11+
image: ghcr.io/arkeonetwork/arkeo:testnet
12+
pull_policy: always
13+
ports:
14+
- "1317:1317"
15+
- "9090:9090"
16+
- "26656:26656"
17+
- "26657:26657"
18+
networks:
19+
- arkeo
20+
volumes:
21+
- ".arkeo:/root/.arkeo:rw"
22+
environment:
23+
- NET="testnet"
24+
- ARKEOD_RPC_LADDR=tcp://0.0.0.0:26657
25+
entrypoint: /scripts/genesis.sh
926
postgres:
1027
image: postgres:15.1-alpine
1128
container_name: arkeo-directory-pg
@@ -19,18 +36,6 @@ services:
1936
ports:
2037
- 5432:5432
2138

22-
arkeo-protocol:
23-
container_name: arkeo-protocol
24-
image: ghcr.io/arkeonetwork/arkeo:latest
25-
environment:
26-
- ARKEOD_RPC_LADDR=tcp://0.0.0.0:26657
27-
networks:
28-
- arkeo
29-
ports:
30-
- 1317:1317
31-
- 9090:9090
32-
- 26656-26657:26656-26657
33-
3439
indexer:
3540
build:
3641
dockerfile: docker/dev/Dockerfile.indexer
@@ -52,3 +57,36 @@ services:
5257
- arkeo
5358
ports:
5459
- 7777:7777
60+
61+
sentinel:
62+
image: ghcr.io/arkeonetwork/arkeo:testnet
63+
depends_on:
64+
- "arkeod"
65+
ports:
66+
- "3636:3636"
67+
networks:
68+
- arkeo
69+
environment:
70+
NET: "testnet"
71+
MONIKER: "local"
72+
WEBSITE: "n/a"
73+
DESCRIPTION: "n/a"
74+
LOCATION: "n/a"
75+
PORT: "3636"
76+
PROXY_HOST: "https://swapi.dev"
77+
SOURCE_CHAIN: "http://arkeod:1317"
78+
EVENT_STREAM_HOST: "arkeod:26657"
79+
FREE_RATE_LIMIT: 10
80+
FREE_RATE_LIMIT_DURATION: "1m"
81+
SUB_RATE_LIMIT: 10
82+
SUB_RATE_LIMIT_DURATION: "1m"
83+
AS_GO_RATE_LIMIT: 10
84+
AS_GO_RATE_LIMIT_DURATION: "1m"
85+
CLAIM_STORE_LOCATION: "/root/.arkeo/claims"
86+
TMHOME: "/root/.arkeo"
87+
GAIA_RPC_ARCHIVE_HOST: "http://176.34.207.130:26657"
88+
entrypoint: "/scripts/sentinel.sh"
89+
command: sentinel
90+
volumes:
91+
- ".sentinel:/root/.arkeo:rw"
92+
# - "./scripts:/scripts"

docker/dev/docker.env

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ API_STATIC_DIR=/var/www/html
44
# indexer
55
INDEXER_ID=0
66
CHAIN_ID="arkeo"
7-
BECH32_PREF_ACC_ADDR="arkeo"
8-
BECH32_PREF_ACC_PUB="arkeopub"
9-
ARKEO_API="http://arkeo-protocol:1317"
10-
TENDERMINT_API="http://arkeo-protocol:26657"
11-
TENDERMINT_WS="tcp://arkeo-protocol:26657"
7+
BECH32_PREF_ACC_ADDR="tarkeo"
8+
BECH32_PREF_ACC_PUB="tarkeopub"
9+
ARKEO_API="http://arkeod:1317"
10+
TENDERMINT_API="http://arkeod:26657"
11+
TENDERMINT_WS="tcp://arkeod:26657"
1212

1313
# db
1414
DB_HOST="arkeo-directory-pg"

docker/dev/local.env

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ API_STATIC_DIR="/tmp/docs"
55
# indexer
66
INDEXER_ID="0"
77
CHAIN_ID="arkeo"
8-
BECH32_PREF_ACC_ADDR="arkeo"
9-
BECH32_PREF_ACC_PUB="arkeopub"
8+
BECH32_PREF_ACC_ADDR="tarkeo"
9+
BECH32_PREF_ACC_PUB="tarkeopub"
1010
ARKEO_API="http://localhost:1317"
1111
TENDERMINT_API="http://localhost:26657"
1212
TENDERMINT_WS="tcp://localhost:26657"

docker/dev/testnet.env

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ API_STATIC_DIR="/var/www/html"
55
# indexer
66
INDEXER_ID="0"
77
CHAIN_ID="arkeo"
8-
BECH32_PREF_ACC_ADDR="arkeo"
9-
BECH32_PREF_ACC_PUB="arkeopub"
8+
BECH32_PREF_ACC_ADDR="tarkeo"
9+
BECH32_PREF_ACC_PUB="tarkeopub"
1010
ARKEO_API="http://testnet-seed.arkeo.shapeshift.com:1317"
1111
TENDERMINT_API="http://testnet-seed.arkeo.shapeshift.com:26657"
1212
TENDERMINT_WS="tcp://testnet-seed.arkeo.shapeshift.com:26657"

indexer/consumer.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,15 @@ func (a *IndexerApp) consumeHistoricalBlock(client *tmclient.HTTP, bheight int64
262262

263263
for _, event := range txInfo.TxResult.Events {
264264
log.Debugf("received %s txevent", event.Type)
265-
if err := a.handleAbciEvent(event, transaction); err != nil {
265+
if err := a.handleAbciEvent(event, transaction, block.Block.Height); err != nil {
266266
log.Errorf("error handling abci event %#v\n%+v", event, err)
267267
}
268268
}
269269
}
270270

271271
for _, event := range blockResults.EndBlockEvents {
272272
log.Debugf("received %s endblock event", event.Type)
273-
if err := a.handleAbciEvent(event, nil); err != nil {
273+
if err := a.handleAbciEvent(event, nil, block.Block.Height); err != nil {
274274
log.Errorf("error handling abci event %#v\n%+v", event, err)
275275
}
276276
}
@@ -283,12 +283,12 @@ func (a *IndexerApp) consumeHistoricalBlock(client *tmclient.HTTP, bheight int64
283283
return r, nil
284284
}
285285

286-
func (a *IndexerApp) handleAbciEvent(event abcitypes.Event, transaction tmtypes.Tx) error {
286+
func (a *IndexerApp) handleAbciEvent(event abcitypes.Event, transaction tmtypes.Tx, height int64) error {
287287
var err error
288288
switch event.Type {
289289
case "provider_bond":
290290
bondProviderEvent := types.BondProviderEvent{}
291-
if err = convertEvent(tmAttributeSource(transaction, event, a.Height), &bondProviderEvent); err != nil {
291+
if err = convertEvent(tmAttributeSource(transaction, event, height), &bondProviderEvent); err != nil {
292292
log.Errorf("error converting %s event: %+v", event.Type, err)
293293
break
294294
}
@@ -297,7 +297,7 @@ func (a *IndexerApp) handleAbciEvent(event abcitypes.Event, transaction tmtypes.
297297
}
298298
case "provider_mod":
299299
modProviderEvent := types.ModProviderEvent{}
300-
if err = convertEvent(tmAttributeSource(transaction, event, a.Height), &modProviderEvent); err != nil {
300+
if err = convertEvent(tmAttributeSource(transaction, event, height), &modProviderEvent); err != nil {
301301
log.Errorf("error converting %s event: %+v", event.Type, err)
302302
break
303303
}
@@ -306,7 +306,7 @@ func (a *IndexerApp) handleAbciEvent(event abcitypes.Event, transaction tmtypes.
306306
}
307307
case "open_contract":
308308
openContractEvent := types.OpenContractEvent{}
309-
if err := convertEvent(tmAttributeSource(transaction, event, a.Height), &openContractEvent); err != nil {
309+
if err := convertEvent(tmAttributeSource(transaction, event, height), &openContractEvent); err != nil {
310310
log.Errorf("error converting %s event: %+v", event.Type, err)
311311
break
312312
}
@@ -315,7 +315,7 @@ func (a *IndexerApp) handleAbciEvent(event abcitypes.Event, transaction tmtypes.
315315
}
316316
case "claim_contract_income":
317317
contractSettlementEvent := types.ContractSettlementEvent{}
318-
if err := convertEvent(tmAttributeSource(transaction, event, a.Height), &contractSettlementEvent); err != nil {
318+
if err := convertEvent(tmAttributeSource(transaction, event, height), &contractSettlementEvent); err != nil {
319319
log.Errorf("error converting claim_contract_income event: %+v", err)
320320
break
321321
}
@@ -324,7 +324,7 @@ func (a *IndexerApp) handleAbciEvent(event abcitypes.Event, transaction tmtypes.
324324
}
325325
case "validator_payout":
326326
validatorPayoutEvent := types.ValidatorPayoutEvent{}
327-
if err := convertEvent(tmAttributeSource(transaction, event, a.Height), &validatorPayoutEvent); err != nil {
327+
if err := convertEvent(tmAttributeSource(transaction, event, height), &validatorPayoutEvent); err != nil {
328328
log.Errorf("error converting validatorPayoutEvent event: %+v", err)
329329
break
330330
}
@@ -333,7 +333,7 @@ func (a *IndexerApp) handleAbciEvent(event abcitypes.Event, transaction tmtypes.
333333
}
334334
case "contract_settlement":
335335
contractSettlementEvent := types.ContractSettlementEvent{}
336-
if err := convertEvent(tmAttributeSource(transaction, event, a.Height), &contractSettlementEvent); err != nil {
336+
if err := convertEvent(tmAttributeSource(transaction, event, height), &contractSettlementEvent); err != nil {
337337
log.Errorf("error converting contractSettlementEvent: %+v", err)
338338
break
339339
}
@@ -343,7 +343,7 @@ func (a *IndexerApp) handleAbciEvent(event abcitypes.Event, transaction tmtypes.
343343
case "close_contract":
344344
log.Debugf("received close_contract event")
345345
closeContractEvent := types.CloseContractEvent{}
346-
if err := convertEvent(tmAttributeSource(transaction, event, a.Height), &closeContractEvent); err != nil {
346+
if err := convertEvent(tmAttributeSource(transaction, event, height), &closeContractEvent); err != nil {
347347
log.Errorf("error converting close_contract event: %+v", err)
348348
break
349349
}

indexer/indexer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (a *IndexerApp) Run() (done <-chan struct{}, err error) {
5050
// initialize by reading all existing providers?
5151
a.done = make(chan struct{})
5252
go a.realtime()
53-
go a.gapFiller()
53+
// go a.gapFiller()
5454
return a.done, nil
5555
}
5656

@@ -96,7 +96,7 @@ func (a *IndexerApp) gapFiller() {
9696

9797
if latestStored == nil {
9898
log.Infof("no latestStored, initializing")
99-
gaps = append(gaps, &db.BlockGap{Start: 0, End: latest.Block.Height})
99+
gaps = append(gaps, &db.BlockGap{Start: 1, End: latest.Block.Height})
100100
} else if latest.Block.Height-latestStored.Height > 1 {
101101
log.Infof("%d missed blocks from %d to current %d", latest.Block.Height-latestStored.Height, latestStored.Height, latest.Block.Height)
102102
gaps = append(gaps, &db.BlockGap{Start: latestStored.Height + 1, End: latest.Block.Height - 1})

pkg/types/types.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package types
22

33
type BondProviderEvent struct {
4-
Pubkey string `mapstructure:"pubkey"`
4+
Pubkey string `mapstructure:"provider"`
55
Chain string `mapstructure:"chain"`
66
Height int64 `mapstructure:"height"`
77
TxID string `mapstructure:"hash"`
@@ -17,7 +17,7 @@ var (
1717
)
1818

1919
type BaseContractEvent struct {
20-
ProviderPubkey string `mapstructure:"pubkey"`
20+
ProviderPubkey string `mapstructure:"provider"`
2121
Chain string `mapstructure:"chain"`
2222
ClientPubkey string `mapstructure:"client"`
2323
DelegatePubkey string `mapstructure:"delegate"` // see BaseContractEvent.GetDelegatePubkey()
@@ -72,7 +72,7 @@ var (
7272
)
7373

7474
type ModProviderEvent struct {
75-
Pubkey string `mapstructure:"pubkey"`
75+
Pubkey string `mapstructure:"pubkey"` // TODO provider
7676
Chain string `mapstructure:"chain"`
7777
Height int64 `mapstructure:"height"`
7878
TxID string `mapstructure:"hash"`

tools/claim.sh

+4-11
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,16 @@ fi
1212
echo "using nonce $NONCE"
1313
# CHAIN=eth-mainnet-fullnode
1414
CHAIN=gaia-mainnet-rpc-archive
15-
CTYPE=1 # contract type, 0 is subscription, 1 is pay-as-you-go
16-
DEPOSIT=1000 # amount of tokens you want to deposit. Subscriptions should make sense in that duration and rate equal deposit
17-
DURATION=200 # number of blocks to make a subscription. There are lower and higher limits to this number
18-
RATE=100 # should equal the porvider's rate which you can lookup at (`curl http://seed.arkeo.network:3636/metadata.json | jq .`)
1915
FROMPUBKEY=$bobkey
2016
USER=bob
2117

2218
PROVIDER_PUBKEY=$alicekey
2319
CLIENT_PUBKEY=$bobkey
2420

25-
HEIGHT=$(curl -s $ARKEOD_HOST_LCD/arkeo/contract/"$PROVIDER_PUBKEY"/"$CHAIN"/"$CLIENT_PUBKEY" | jq -r .contract.height)
21+
CONTRACT_ID=$(curl -s $ARKEOD_HOST_LCD/arkeo/active-contract/$CLIENT_PUBKEY/$PROVIDER_PUBKEY/$CHAIN | jq -r .contract.id)
22+
SIGNATURE=$(signhere -u "$USER" -m "$CONTRACT_ID:$CLIENT_PUBKEY:$NONCE")
2623

27-
echo "Using height $HEIGHT"
28-
SIGNATURE=$(signhere -u "$USER" -m "$PROVIDER_PUBKEY:$CHAIN:$CLIENT_PUBKEY:$HEIGHT:$NONCE")
29-
echo "SIGNATURE: $SIGNATURE"
30-
echo "executing arkeod tx arkeo claim-contract-income --from $USER $PROVIDER_PUBKEY $CHAIN $CLIENT_PUBKEY $NONCE $HEIGHT $SIGNATURE"
31-
32-
arkeod --node $ARKEOD_HOST tx arkeo claim-contract-income -y --from $USER -- "$PROVIDER_PUBKEY" "$CHAIN" "$CLIENT_PUBKEY" "$NONCE" "$HEIGHT" "$SIGNATURE"
24+
echo "executing arkeod tx arkeo claim-contract-income --from $USER $CHAIN $PROVIDER_PUBKEY $CONTRACT_ID $CLIENT_PUBKEY $NONCE $SIGNATURE"
25+
arkeod tx arkeo claim-contract-income -y --from $USER -- "$CONTRACT_ID" "$CLIENT_PUBKEY" "$NONCE" "$SIGNATURE"
3326

3427
echo "done"

tools/close.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ USER=bob
99
PROVIDER_PUBKEY=$alicekey
1010
CLIENT_PUBKEY=$bobkey
1111

12-
# Error: accepts 3 arg(s), received 0
13-
# Usage:
14-
# arkeod tx arkeo close-contract [pubkey] [chain] [client] [delegate-optional] [flags]
15-
arkeod tx arkeo close-contract --from $USER -y $PROVIDER_PUBKEY $CHAIN $CLIENT_PUBKEY
12+
CONTRACT_ID=$(curl -s $ARKEOD_HOST_LCD/arkeo/active-contract/$CLIENT_PUBKEY/$PROVIDER_PUBKEY/$CHAIN | jq -r .contract.id)
13+
14+
echo "Using contractID $CONTRACT_ID"
15+
16+
arkeod tx arkeo close-contract --from $USER -y $CONTRACT_ID
1617

1718
# arkeod tx arkeo open-contract --from $USER $PROVIDER_PUBKEY eth-mainnet-fullnode $CLIENT_PUBKEY 1 100 100 20 -y
1819
echo "done"

tools/env.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/bin/bash
22
export ARKEOD_HOST=http://testnet-seed.arkeo.shapeshift.com:26657
33
export ARKEOD_HOST_LCD=http://testnet-seed.arkeo.shapeshift.com:1317
4+
export METAURL="http://testnet-sentinel.arkeo.shapeshift.com:3636/metadata.json"
45

56
# export ARKEOD_HOST=http://localhost:26657
67
# export ARKEOD_HOST_LCD=http://localhost:1317
7-
8+
# export METAURL="http://localhost:3636/metadata.json"
89

910
export ARKEOD_KEYRING_BACKEND=test
1011

tools/mod.sh

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ CHAIN=gaia-mainnet-rpc-archive
88

99
USER=alice
1010
PROVIDER_PUBKEY=$alicekey
11-
METAURL="http://testnet-sentinel.arkeo.shapeshift.com:3636/metadata.json"
1211
METADATA_NONCE=0
13-
# modify provider
14-
# Error: accepts 9 arg(s), received 0
15-
# Usage:
16-
# arkeod tx arkeo mod-provider [pubkey] [chain] [metatadata-uri] [metadata-nonce] [status] [min-contract-duration] [max-contract-duration] [subscription-rate] [pay-as-you-go-rate] [flags]
17-
arkeod --node $ARKEOD_HOST tx arkeo mod-provider $PROVIDER_PUBKEY $CHAIN $METAURL $METADATA_NONCE 1 10 5256000 10 20 --from alice -y
12+
arkeod tx arkeo mod-provider $PROVIDER_PUBKEY $CHAIN $METAURL $METADATA_NONCE 1 10 5256000 10 20 10 --from alice -y
1813

1914
echo "done"

tools/open.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ source $BASEDIR/env.sh
77
# CTYPE=0 # contract type, 0 is subscription, 1 is pay-as-you-go
88
# DEPOSIT=200 # amount of tokens you want to deposit. Subscriptions should make sense in that duration and rate equal deposit
99
# DURATION=20 # number of blocks to make a subscription. There are lower and higher limits to this number
10+
# SETTLEMENT_DURATION=10
1011
# RATE=10 # should equal the porvider's rate which you can lookup at (`curl http://seed.arkeo.network:3636/metadata.json | jq .`)
1112
# FROMPUBKEY=$bobkey
1213
# USER=bob
1314
# CHAIN=gaia-mainnet-rpc-archive
14-
# arkeod --node $ARKEOD_HOST tx arkeo open-contract -y --from $USER -- $alicekey $CHAIN "$FROMPUBKEY" "$CTYPE" "$DEPOSIT" "$DURATION" $RATE
15-
16-
15+
# arkeod tx arkeo open-contract -y --from $USER -- $alicekey $CHAIN "$FROMPUBKEY" "$CTYPE" "$DEPOSIT" "$DURATION" $RATE "$SETTLEMENT_DURATION"
1716

1817
CTYPE=1 # contract type, 0 is subscription, 1 is pay-as-you-go
1918
CHAIN=gaia-mainnet-rpc-archive
2019
DEPOSIT=400 # amount of tokens you want to deposit. Subscriptions should make sense in that duration and rate equal deposit
2120
DURATION=20 # number of blocks to make a subscription. There are lower and higher limits to this number
21+
SETTLEMENT_DURATION=10
2222
RATE=20 # should equal the porvider's rate which you can lookup at (`curl http://seed.arkeo.network:3636/metadata.json | jq .`)
2323
FROMPUBKEY=$bobkey
2424
USER=bob
25-
arkeod --node $ARKEOD_HOST tx arkeo open-contract -y --from $USER -- $alicekey $CHAIN "$FROMPUBKEY" "$CTYPE" "$DEPOSIT" "$DURATION" $RATE
25+
arkeod tx arkeo open-contract -y --from $USER -- $alicekey $CHAIN "$FROMPUBKEY" "$CTYPE" "$DEPOSIT" "$DURATION" $RATE "$SETTLEMENT_DURATION"

0 commit comments

Comments
 (0)