Skip to content

Commit

Permalink
fix(pox-4-tests): Address same pool pox address comment
Browse files Browse the repository at this point in the history
- removed check that verifies all the stackers have delegated to the same PoX address
- addressed comments:
  - #4628 (comment)
  - #4628 (comment)
  - #4628 (comment)
  • Loading branch information
BowTiedRadone authored and moodmosaic committed Apr 11, 2024
1 parent fe10e3d commit b23cd8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { expect } from "vitest";
import { Cl } from "@stacks/transactions";

/**
* The `StackAggregationCommitAuthCommand` allows an operator to commit
* partially stacked STX & to allocate a new PoX reward address slot.
* This allows a stacker to lock fewer STX than the minimal threshold
* The `StackAggregationCommitAuthCommand` allows an operator to commit
* partially stacked STX & to allocate a new PoX reward address slot.
* This allows a stacker to lock fewer STX than the minimal threshold
* in multiple transactions, so long as:
* 1. The pox-addr is the same.
* 2. The "commit" transaction is called _before_ the PoX anchor block.
Expand All @@ -23,7 +23,6 @@ import { Cl } from "@stacks/transactions";
* - The Operator must have locked STX on behalf of at least one stacker.
* - The total amount previously locked by the Operator on behalf of the
* stackers has to be greater than the uSTX threshold.
* - All of the Stackers must have delegated to the same pox address.
*/
export class StackAggregationCommitAuthCommand implements PoxCommand {
readonly operator: Wallet;
Expand Down Expand Up @@ -52,22 +51,9 @@ export class StackAggregationCommitAuthCommand implements PoxCommand {
// - The Operator must have locked STX on behalf of at least one stacker.
// - The total amount previously locked by the Operator on behalf of the
// stackers has to be greater than the uSTX threshold.
// - All of the Stackers must have delegated to the same pox address.
let sameDelegatedPoxAddrAllStackers = true;
const firstDelegatedPoxAddress = this.operator.lockedAddresses.length > 0
? model.wallets.get(this.operator.lockedAddresses[0])!.delegatedPoxAddress
: this.operator.btcAddress;

this.operator.lockedAddresses.forEach((stacker) => {
if (
model.wallets.get(stacker)!.delegatedPoxAddress !==
firstDelegatedPoxAddress
) sameDelegatedPoxAddrAllStackers = false;
});

return this.operator.lockedAddresses.length > 0 &&
this.operator.amountToCommit >= model.stackingMinimum &&
sameDelegatedPoxAddrAllStackers;
this.operator.amountToCommit >= model.stackingMinimum;
}

run(model: Stub, real: Real): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { Cl } from "@stacks/transactions";
import { bufferFromHex } from "@stacks/transactions/dist/cl";

/**
* The `StackAggregationCommitSigCommand` allows an operator to commit
* partially stacked STX & to allocate a new PoX reward address slot.
* This allows a stacker to lock fewer STX than the minimal threshold
* The `StackAggregationCommitSigCommand` allows an operator to commit
* partially stacked STX & to allocate a new PoX reward address slot.
* This allows a stacker to lock fewer STX than the minimal threshold
* in multiple transactions, so long as:
* 1. The pox-addr is the same.
* 2. This "commit" transaction is called _before_ the PoX anchor block.
Expand All @@ -24,7 +24,6 @@ import { bufferFromHex } from "@stacks/transactions/dist/cl";
* - The Operator must have locked STX on behalf of at least one stacker.
* - The total amount previously locked by the Operator on behalf of the
* stackers has to be greater than the uSTX threshold.
* - All of the Stackers must have delegated to the same pox address.
*/
export class StackAggregationCommitSigCommand implements PoxCommand {
readonly operator: Wallet;
Expand Down Expand Up @@ -53,22 +52,9 @@ export class StackAggregationCommitSigCommand implements PoxCommand {
// - The Operator must have locked STX on behalf of at least one stacker.
// - The total amount previously locked by the Operator on behalf of the
// stackers has to be greater than the uSTX threshold.
// - All of the Stackers must have delegated to the same pox address.
let sameDelegatedPoxAddrAllStackers = true;
const firstDelegatedPoxAddress = this.operator.lockedAddresses.length > 0
? model.wallets.get(this.operator.lockedAddresses[0])!.delegatedPoxAddress
: this.operator.btcAddress;

this.operator.lockedAddresses.forEach((stacker) => {
if (
model.wallets.get(stacker)!.delegatedPoxAddress !==
firstDelegatedPoxAddress
) sameDelegatedPoxAddrAllStackers = false;
});

return this.operator.lockedAddresses.length > 0 &&
this.operator.amountToCommit >= model.stackingMinimum &&
sameDelegatedPoxAddrAllStackers;
this.operator.amountToCommit >= model.stackingMinimum;
}

run(model: Stub, real: Real): void {
Expand Down

0 comments on commit b23cd8d

Please sign in to comment.