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

[Supplier] Implement supplier revenue share #729

Merged
merged 64 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a18ba42
feat: Implement non-custodial staking
red-0ne Jul 30, 2024
676c2c4
chore: Address review change requests
red-0ne Aug 1, 2024
14ea326
Merge remote-tracking branch 'origin/main' into refactor/non-custodia…
red-0ne Aug 1, 2024
bae1f00
refactor: unit/integration tests
red-0ne Aug 2, 2024
b44e07b
Merge remote-tracking branch 'origin/main' into feat/non-custodial-st…
red-0ne Aug 2, 2024
5f5e98b
Merge remote-tracking branch 'origin/feat/non-custodial-staking' into…
red-0ne Aug 2, 2024
473e042
fix: Remove tabs and non-printable chars
red-0ne Aug 2, 2024
3d01f53
Merge remote-tracking branch 'origin/main' into feat/non-custodial-st…
red-0ne Aug 2, 2024
2d064fd
Merge branch 'feat/non-custodial-staking' into refactor/non-custodial…
red-0ne Aug 2, 2024
0699a35
fix: Remove shadowed variable
red-0ne Aug 2, 2024
85e6b81
Merge remote-tracking branch 'origin/main' into refactor/non-custodia…
red-0ne Aug 2, 2024
bb84ab1
Merge remote-tracking branch 'origin/main' into feat/non-custodial-st…
red-0ne Aug 2, 2024
498fc26
Merge remote-tracking branch 'origin/feat/non-custodial-staking' into…
red-0ne Aug 2, 2024
853724a
fix: All tests working
red-0ne Aug 3, 2024
6d7151e
fix: Revert merge changes
red-0ne Aug 3, 2024
20b26e7
chore: Remove imoprt newline
red-0ne Aug 3, 2024
b33a013
fix: Add missing sender address
red-0ne Aug 3, 2024
b02af2f
fix: Use higher context err variable
red-0ne Aug 3, 2024
7b3555a
Merge remote-tracking branch 'origin/feat/non-custodial-staking' into…
red-0ne Aug 3, 2024
604224d
fix: Enfore sender to be owner or operator
red-0ne Aug 3, 2024
540f5db
Merge branch 'feat/non-custodial-staking' into refactor/non-custodial…
red-0ne Aug 3, 2024
ac07b43
fix: Remove err shadow declaration
red-0ne Aug 3, 2024
79e4c39
Merge remote-tracking branch 'origin/main' into feat/non-custodial-st…
red-0ne Aug 5, 2024
473e047
fix: Err var shadowing
red-0ne Aug 6, 2024
088e675
chore: Log default operator address fallback
red-0ne Aug 6, 2024
d8e2c70
wip: rev-share features
red-0ne Aug 7, 2024
428104b
Merge remote-tracking branch 'origin/main' into feat/non-custodial-st…
red-0ne Aug 7, 2024
ef62442
Merge branch 'feat/non-custodial-staking' into refactor/non-custodial…
red-0ne Aug 7, 2024
365ee96
fix: Add missing ctx argument
red-0ne Aug 7, 2024
d096d02
fix: Add polylog as side effect
red-0ne Aug 7, 2024
20e8ed5
fix: Address review changes, mimic Morse behavior
red-0ne Aug 8, 2024
b543120
Merge remote-tracking branch 'origin/main' into feat/non-custodial-st…
red-0ne Aug 8, 2024
fdfd9b9
fix: Duplicate supplierKeeper declaration
red-0ne Aug 8, 2024
4843c21
Merge remote-tracking branch 'origin/feat/non-custodial-staking' into…
red-0ne Aug 8, 2024
095571a
fix: Reward the owner instead of the operator
red-0ne Aug 8, 2024
611f583
Merge remote-tracking branch 'origin/feat/non-custodial-staking' into…
red-0ne Aug 8, 2024
3a7c0ba
fix: Update tests
red-0ne Aug 9, 2024
e34634b
chore: Add test external signer test case
red-0ne Aug 9, 2024
910c85b
fix: Allow owner to change its aaddress
red-0ne Aug 9, 2024
e092a4e
Merge remote-tracking branch 'origin/feat/non-custodial-staking' into…
red-0ne Aug 9, 2024
b3ac63c
fix: Wrong word added
red-0ne Aug 9, 2024
1f26789
fix: Stake auth contidional
red-0ne Aug 9, 2024
0a43775
Merge remote-tracking branch 'origin/feat/non-custodial-staking' into…
red-0ne Aug 9, 2024
85d84ec
fix: Missing owner address in test
red-0ne Aug 9, 2024
7f0dcda
Merge remote-tracking branch 'origin/main' into feat/rev-share
red-0ne Aug 9, 2024
3bb9d22
test: fix all unit tests
red-0ne Aug 9, 2024
29ba54a
Merge remote-tracking branch 'origin/main' into feat/rev-share
red-0ne Aug 9, 2024
391b6db
chore: Address review change requests
red-0ne Aug 9, 2024
98b0446
Merge remote-tracking branch 'origin/main' into feat/non-custodial-st…
red-0ne Aug 9, 2024
7b78f49
Merge branch 'feat/non-custodial-staking' into refactor/non-custodial…
red-0ne Aug 9, 2024
e3cc89e
Merge remote-tracking branch 'origin/feat/non-custodial-staking' into…
red-0ne Aug 10, 2024
8034c26
Merge remote-tracking branch 'origin/refactor/non-custodial-staking-t…
red-0ne Aug 10, 2024
9530a64
fix: Failing unit tests
red-0ne Aug 12, 2024
a94fa5e
fix: comment typo
red-0ne Aug 12, 2024
d204355
fix: comment formatting
red-0ne Aug 12, 2024
d869db8
Merge remote-tracking branch 'origin/main' into feat/rev-share
red-0ne Aug 14, 2024
2fe7526
chore: Address review change requests
red-0ne Aug 14, 2024
3a7816f
fix: Renamed proto type
red-0ne Aug 14, 2024
8e1df74
fix: Rev share comparaison test
red-0ne Aug 14, 2024
7dd64eb
fix: Linter complaining about nil value
red-0ne Aug 14, 2024
27366fd
docs: Add rev share owner_address usage
red-0ne Aug 14, 2024
7a25e34
Merge branch 'main' into feat/rev-share
Olshansk Aug 14, 2024
f72e9bc
fix: Remove redundant check
red-0ne Aug 14, 2024
905f650
chore: Address review change requests
red-0ne Aug 14, 2024
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
6 changes: 3 additions & 3 deletions api/poktroll/service/relay.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

290 changes: 145 additions & 145 deletions api/poktroll/shared/service.pulsar.go

Large diffs are not rendered by default.

178 changes: 69 additions & 109 deletions api/poktroll/shared/supplier.pulsar.go

Large diffs are not rendered by default.

344 changes: 111 additions & 233 deletions api/poktroll/supplier/tx.pulsar.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ genesis:
supplier:
supplierList:
- owner_address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
operator_address: pokt19a3t4yunp0dlpfjrp7qwnzwlrzd5fzs2gjaaaj
services:
- service:
id: anvil
Expand Down
13 changes: 12 additions & 1 deletion docusaurus/docs/operate/configs/supplier_staking_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ a stake transaction required to provide RPC services on Pocket Network._
- [Reference Example](#reference-example)
- [Usage](#usage)
- [Configuration](#configuration)
- [`owner_address`](#owner_address)
- [`stake_amount`](#stake_amount)
- [`default_rev_share_percent`](#default_rev_share_percent)
- [`services`](#services)
Expand Down Expand Up @@ -45,7 +46,17 @@ poktrolld tx supplier stake-supplier \

## Configuration

<!-- TODO(#716): `owner_address` will be defined once non-custodial is merged -->
### `owner_address`

_`Required`_, _`Non-empty`_

```yaml
owner_address: <address>
```

The `owner_address` is used as the unique shareholder address for the `Supplier`
if none of `default_rev_share_percent` or `rev_share_percent` is defined in the
configuration file.

### `stake_amount`

Expand Down
6 changes: 3 additions & 3 deletions load-testing/tests/relays_stress_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,9 @@ func (s *relaysSuite) addActor(actorAddress string, actorStakeAmount sdk.Coin) *
// messages in a single supplier transaction.
func (s *relaysSuite) addPendingStakeSupplierMsg(supplier *accountInfo) {
supplier.addPendingMsg(suppliertypes.NewMsgStakeSupplier(
supplier.address,
supplier.address,
supplier.address,
supplier.address, // The message signer.
red-0ne marked this conversation as resolved.
Show resolved Hide resolved
supplier.address, // The supplier owner.
supplier.address, // The supplier operator.
supplier.amountToStake,
[]*sharedtypes.SupplierServiceConfig{
{
Expand Down
6 changes: 3 additions & 3 deletions proto/poktroll/service/relay.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ message RelayRequestMetadata {
// TODO_MAINNET: make sure we're checking/verifying this address on-chain (if needed).
// Relevant conversation: https://github.com/pokt-network/poktroll/pull/567#discussion_r1628722168
//
// The supplier address the relay is sent to. It is being used on the RelayMiner to
// route to the correct supplier.
string supplier_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application.
// The supplier operator address the relay is sent to. It is being used on the
// RelayMiner to route to the correct supplier.
string supplier_operator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application.
}

// RelayRequest holds the request details for a relay.
Expand Down
6 changes: 3 additions & 3 deletions proto/poktroll/shared/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ message SupplierServiceConfig {
// TODO_MAINNET: Avoid embedding the full Service because we just need the ID.
Service service = 1; // The Service for which the supplier is configured
repeated SupplierEndpoint endpoints = 2; // List of endpoints for the service
repeated ServiceRevShare rev_share = 3; // List of revenue share configurations for the service
repeated ServiceRevenueShare rev_share = 3; // List of revenue share configurations for the service
// TODO_MAINNET: There is an opportunity for supplier to advertise the min
// they're willing to earn for a certain configuration/price, but this is outside of scope.
}
Expand All @@ -55,8 +55,8 @@ message SupplierEndpoint {
repeated ConfigOption configs = 3; // Additional configuration options for the endpoint
}

// ServiceRevShare message to hold revenue share configuration details
message ServiceRevShare {
// ServiceRevenueShare message to hold revenue share configuration details
message ServiceRevenueShare {
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the revenue share recipient
float rev_share_percentage = 2; // The percentage of revenue share the recipient will receive
}
Expand Down
10 changes: 4 additions & 6 deletions proto/poktroll/shared/supplier.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ message Supplier {
// By default, this address is the one that receives all the rewards unless owtherwise specified.
// This property cannot be updated by the operator.
string owner_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address
// The address of the supplier operator (i.e. the one managing the off-chain server).
// The operator address of the supplier operator (i.e. the one managing the off-chain server).
// The operator address can update the supplier's configurations excluding the owner address.
// This property do not change over the supplier's lifespan, the supplier must be usnaked
// and staked again to update this value.
// TODO(#722): Rename this to `operator_address` include all downstream
// variables, comments, docs, tests, etc...
string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address
// This property does not change over the supplier's lifespan, the supplier must be unstaked
// and re-staked to effectively update this value.
string operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Bech32 cosmos address
cosmos.base.v1beta1.Coin stake = 3; // The total amount of uPOKT the supplier has staked
repeated SupplierServiceConfig services = 4; // The service configs this supplier can support
// The session end height at which an actively unbonding supplier unbonds its stake.
Expand Down
4 changes: 2 additions & 2 deletions proto/poktroll/supplier/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ message MsgStakeSupplier {

string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message signer (i.e. owner or operator)
string owner_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the owner (i.e. custodial, staker)
string address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial)
string operator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial)
cosmos.base.v1beta1.Coin stake = 4; // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any)
repeated poktroll.shared.SupplierServiceConfig services = 5; // The list of services this supplier is staked to provide service for
}
Expand All @@ -60,7 +60,7 @@ message MsgUnstakeSupplier {
option (cosmos.msg.v1.signer) = "signer";

string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message signer (i.e. owner or operator)
string address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial)
string operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial)
}

message MsgUnstakeSupplierResponse {}
Expand Down
8 changes: 4 additions & 4 deletions testutil/integration/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,12 @@ func NewCompleteIntegrationApp(t *testing.T) *App {
// Prepare the on-chain supplier
supplierStake := types.NewCoin("upokt", math.NewInt(1000000))
defaultSupplier := sharedtypes.Supplier{
OwnerAddress: supplierAddr.String(),
Address: supplierAddr.String(),
Stake: &supplierStake,
OwnerAddress: supplierOperatorAddr.String(),
OperatorAddress: supplierOperatorAddr.String(),
Stake: &supplierStake,
Services: []*sharedtypes.SupplierServiceConfig{
{
RevShare: []*sharedtypes.ServiceRevShare{
RevShare: []*sharedtypes.ServiceRevenueShare{
{
Address: sample.AccAddress(),
RevSharePercentage: 100,
Expand Down
12 changes: 6 additions & 6 deletions testutil/keeper/tokenomics.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ func TokenomicsKeeperWithActorAddrs(t testing.TB) (
}

// Prepare the test supplier.
supplierAddr = sample.AccAddress()
supplierOwnerAddr := sample.AccAddress()
supplier := sharedtypes.Supplier{
OwnerAddress: supplierAddr,
Address: supplierAddr,
Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100000)},
OwnerAddress: supplierOwnerAddr,
OperatorAddress: supplierOwnerAddr,
Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100000)},
Services: []*sharedtypes.SupplierServiceConfig{
{
Service: service,
RevShare: []*sharedtypes.ServiceRevShare{
RevShare: []*sharedtypes.ServiceRevenueShare{
{
Address: supplierAddr,
Address: supplierOwnerAddr,
RevSharePercentage: 100,
},
},
Expand Down
12 changes: 6 additions & 6 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ func DefaultSupplierModuleGenesisState(t *testing.T, n int) *suppliertypes.Genes
svcId := fmt.Sprintf("svc%d", i)
stake := sdk.NewCoin("upokt", math.NewInt(int64(i)))
supplier := sharedtypes.Supplier{
OwnerAddress: sample.AccAddress(),
Address: sample.AccAddress(),
Stake: &stake,
OwnerAddress: sample.AccAddress(),
OperatorAddress: sample.AccAddress(),
Stake: &stake,
Services: []*sharedtypes.SupplierServiceConfig{
{
Service: &sharedtypes.Service{Id: svcId},
Expand Down Expand Up @@ -170,9 +170,9 @@ func SupplierModuleGenesisStateWithAddresses(t *testing.T, addresses []string) *
state := suppliertypes.DefaultGenesis()
for _, addr := range addresses {
supplier := sharedtypes.Supplier{
OwnerAddress: sample.AccAddress(),
Address: addr,
Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(10000)},
OwnerAddress: sample.AccAddress(),
OperatorAddress: addr,
Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(10000)},
Services: []*sharedtypes.SupplierServiceConfig{
{
Service: &sharedtypes.Service{Id: "svc1"},
Expand Down
7 changes: 6 additions & 1 deletion x/shared/helpers/service_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@ func ValidateSupplierServiceConfigs(services []*sharedtypes.SupplierServiceConfi

// ValidateServiceRevShare validates the supplier's service revenue share,
// ensuring that the sum of the revenue share percentages is 100.
func ValidateServiceRevShare(revShareList []*sharedtypes.ServiceRevShare) error {
// This function is unit tested via the supplier staking config tests.
red-0ne marked this conversation as resolved.
Show resolved Hide resolved
func ValidateServiceRevShare(revShareList []*sharedtypes.ServiceRevenueShare) error {
revSharePercentageSum := float32(0)

if len(revShareList) == 0 {
return sharedtypes.ErrSharedInvalidRevShare.Wrap("no rev share configurations")
}

for _, revShare := range revShareList {
if revShare == nil {
return sharedtypes.ErrSharedInvalidRevShare.Wrap("rev share cannot be nil")
Expand Down
2 changes: 1 addition & 1 deletion x/shared/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ var (
ErrSharedParamInvalid = sdkerrors.Register(ModuleName, 1103, "the provided param is invalid")
ErrSharedEmitEvent = sdkerrors.Register(ModuleName, 1104, "failed to emit event")
ErrSharedUnauthorizedSupplierUpdate = sdkerrors.Register(ModuleName, 1105, "unauthorized supplier update")
ErrSharedInvalidRevShare = sdkerrors.Register(ModuleName, 1106, "invalid rev share")
ErrSharedInvalidRevShare = sdkerrors.Register(ModuleName, 1106, "invalid revenue share configuration")
)
Loading
Loading