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

[Utility] trustless relays servicer token validation #803

Merged
merged 28 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bcd29fe
merge main
adshmh Jun 1, 2023
21e88c0
Validate trustless relay: available service tokens for the application
adshmh Jun 2, 2023
0c64aaa
merge main
adshmh Jun 2, 2023
6b9e44d
Fix double error wrapping until we move to go 1.20
adshmh Jun 2, 2023
934d5a3
Feature: use persistence module for token usage maintenance
adshmh Jun 6, 2023
f37b394
Add relay execution logic to servicer
adshmh Jun 6, 2023
eb1bb93
Address review comments
adshmh Jun 12, 2023
9729440
Merge remote-tracking branch 'origin/main' into feat-utility-trustles…
adshmh Jun 12, 2023
a64822b
Fix proto files
adshmh Jun 12, 2023
9ae0912
Remove gomock temp program
adshmh Jun 12, 2023
c1a6a92
Fix linter errors
adshmh Jun 13, 2023
a98595f
Fix failing unit test in runtime
adshmh Jun 13, 2023
3790f07
Address review comments round 2
adshmh Jun 17, 2023
30750ff
Merge remote-tracking branch 'origin/main' into feat-utility-trustles…
adshmh Jun 17, 2023
1400396
Fix linter warnings
adshmh Jun 17, 2023
f3bfe13
Fix default configuration override
adshmh Jun 19, 2023
58625a0
Address review comments
adshmh Jun 21, 2023
c276c99
Merge main
adshmh Jun 21, 2023
7a8dda0
Revert "Fix default configuration override"
adshmh Jun 25, 2023
821925a
Use an INCOMPLETE item for default servicer config
adshmh Jun 25, 2023
c21f729
Fix failing unit test
adshmh Jun 25, 2023
0014e20
Address review comments
adshmh Jun 26, 2023
76fa1b4
Merge main
adshmh Jun 26, 2023
b758fef
Fix failing unit tests
adshmh Jun 26, 2023
98e4930
Address review comments
adshmh Jun 29, 2023
08fb9b9
Merge main
adshmh Jun 29, 2023
e8021e3
Fix linter warning
adshmh Jun 29, 2023
bc1f3d4
Address review comments
adshmh Jun 29, 2023
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
4 changes: 4 additions & 0 deletions persistence/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.56] - 2023-06-06

- Add place-holder for servicer token usage support methods

## [0.0.0.55] - 2023-06-01

- Integrate lazy loading SMT (release v0.5.0) into V1
Expand Down
13 changes: 13 additions & 0 deletions persistence/servicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package persistence

import (
"encoding/hex"
"math/big"

"github.com/pokt-network/pocket/persistence/types"
coreTypes "github.com/pokt-network/pocket/shared/core/types"
Expand Down Expand Up @@ -79,3 +80,15 @@ func (p *PostgresContext) SetServicerPauseHeight(address []byte, height int64) e
func (p *PostgresContext) GetServicerOutputAddress(operator []byte, height int64) (output []byte, err error) {
return p.GetActorOutputAddress(types.ServicerActor, operator, height)
}

// INCOMPLETE: implement this
// DISCUSS: both the relay and the response can be large structures: we may need to truncate the stored values
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
func (p *PostgresContext) RecordRelayService(applicationAddress string, key []byte, relay *coreTypes.Relay, response *coreTypes.RelayResponse) error {
return nil
}

// INCOMPLETE: implement this
// GetServicerTokenUsage returns the number of tokens used by the servicer in the current session, i.e. for the application associated with the session
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
func (p *PostgresContext) GetServicerTokenUsage(session *coreTypes.Session) (*big.Int, error) {
return nil, nil
}
12 changes: 11 additions & 1 deletion runtime/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,17 @@ func NewDefaultConfig(options ...func(*Config)) *Config {
},
Utility: &UtilityConfig{
ServicerConfig: &ServicerConfig{
Chains: []string{"0001"},
Chains: map[string]*ChainConfig{
"0021": {
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
Url: "http://chain-url.pokt.network",
UserAgent: "user-agent",
TimeoutMilliseconds: 5000,
BasicAuth: &BasicAuth{
UserName: "user",
Password: "password",
},
},
},
},
MaxMempoolTransactionBytes: defaults.DefaultUtilityMaxMempoolTransactionBytes,
MaxMempoolTransactions: defaults.DefaultUtilityMaxMempoolTransactions,
Expand Down
15 changes: 14 additions & 1 deletion runtime/configs/proto/utility_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,18 @@ message UtilityConfig {
message ServicerConfig {
string public_key = 1;
string address = 2;
repeated string chains = 3;
map<string, ChainConfig> chains = 3;
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
}

message ChainConfig {
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
string url = 1;
string user_agent = 2;
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
uint64 timeout_milliseconds = 3;
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
BasicAuth basic_auth = 4;
}

message BasicAuth {
string user_name = 1;
// DISCUSS: does this need to be encrypted?
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
string password = 2;
}
4 changes: 4 additions & 0 deletions runtime/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.41] - 2023-06-06

- Add a new ChainConfig configuration field to servicer config
Olshansk marked this conversation as resolved.
Show resolved Hide resolved

## [0.0.0.40] - 2023-06-01

- Add an Address field to Servicer configuration
Expand Down
5 changes: 5 additions & 0 deletions shared/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.60] - 2023-06-06

- Add place-holders for servicer token usage support
- Add a TODO comment for supporting different relay payload types in core types

## [0.0.0.59] - 2023-06-01

- Use ApplicationAddress in RelayMeta
Expand Down
1 change: 1 addition & 0 deletions shared/core/types/proto/relay.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ message Relay {
RelayMeta meta = 2;
}

// INCOMPLETE: add support for different payloads, e.g. JSON, GRPC, etc.
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
adshmh marked this conversation as resolved.
Show resolved Hide resolved
message RelayPayload {
string data = 1;
string method = 2;
Expand Down
7 changes: 7 additions & 0 deletions shared/modules/persistence_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package modules
//go:generate mockgen -destination=./mocks/persistence_module_mock.go github.com/pokt-network/pocket/shared/modules PersistenceModule,PersistenceRWContext,PersistenceReadContext,PersistenceWriteContext

import (
"math/big"

"github.com/pokt-network/pocket/persistence/blockstore"
"github.com/pokt-network/pocket/persistence/indexer"
"github.com/pokt-network/pocket/runtime/genesis"
Expand Down Expand Up @@ -129,6 +131,8 @@ type PersistenceWriteContext interface {
// Flag Operations
InitFlags() error
SetFlag(paramName string, value any, enabled bool) error

Olshansk marked this conversation as resolved.
Show resolved Hide resolved
RecordRelayService(applicationAddress string, key []byte, relay *coreTypes.Relay, response *coreTypes.RelayResponse) error
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
}

type PersistenceReadContext interface {
Expand Down Expand Up @@ -219,4 +223,7 @@ type PersistenceReadContext interface {
GetIntFlag(paramName string, height int64) (int, bool, error)
GetStringFlag(paramName string, height int64) (string, bool, error)
GetBytesFlag(paramName string, height int64) ([]byte, bool, error)

// Servicer application tokens
GetServicerTokenUsage(session *coreTypes.Session) (*big.Int, error)
Olshansk marked this conversation as resolved.
Show resolved Hide resolved
}
5 changes: 5 additions & 0 deletions utility/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.44] - 2023-06-06

- Add trustless relay validation: available service tokens for the application
- Add relay execution logic to the servicer

## [0.0.0.43] - 2023-06-01

- Add a place-holder Servicer implementation
Expand Down
Loading