Skip to content

Commit

Permalink
chore: update to latest stacks image with epoch2.5 bootup, pox-4 test…
Browse files Browse the repository at this point in the history
… fixes (#1924)

* chore: update to latest stacks image with epoch2.5 bootup

* chore: upgrade stacks.js

* fix: stack-extend increase

* test: attempts

* fix: stack cycle length

* fix: attempt to fix stack extend in gha

---------

Co-authored-by: Rafael Cardenas <rafael@rafaelcr.com>
  • Loading branch information
zone117x and rafaelcr authored Apr 9, 2024
1 parent 82abc90 commit ab98b97
Show file tree
Hide file tree
Showing 16 changed files with 191 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tasks:
- init: npm ci
command: npm run dev
- openMode: split-right
command: stacks-node start --config=stacks-blockchain/Stacks-dev.toml
command: stacks-node start --config stacks-blockchain/Stacks-dev.toml

github:
prebuilds:
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.dev.stacks-blockchain-follower.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
stacks-blockchain:
build:
context: ../stacks-blockchain/docker
command: stacks-node start --config=/app/config/Stacks-follower.toml
command: stacks-node start --config /app/config/Stacks-follower.toml
restart: on-failure
environment:
STACKS_EVENT_OBSERVER: host.docker.internal:3700
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.dev.stacks-blockchain.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.7'
services:
stacks-blockchain:
image: 'hirosystems/stacks-api-e2e:stacks3.0-457f270'
image: 'hirosystems/stacks-api-e2e:stacks3.0-1360a17'
restart: on-failure
environment:
STACKS_EVENT_OBSERVER: host.docker.internal:3700
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.dev.stacks-krypton.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.7'
services:
stacks-blockchain:
image: 'hirosystems/stacks-api-e2e:stacks3.0-457f270'
image: 'hirosystems/stacks-api-e2e:stacks3.0-1360a17'
ports:
- '18443:18443' # bitcoin regtest JSON-RPC interface
- '18444:18444' # bitcoin regtest p2p
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.dev.subnets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
image: "hirosystems/stacks-subnets:7012d22"
# build:
# dockerfile: ./subnet-node.Dockerfile
command: subnet-node start --config=/app/config/Stacks-subnet.toml
command: subnet-node start --config /app/config/Stacks-subnet.toml
ports:
- "30443:30443" # subnet-node RPC interface
- "30444:30444" # subnet-node p2p
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.7'
services:
stacks-blockchain:
command: stacks-node start --config=/app/config/Stacks-mocknet.toml
command: stacks-node start --config /app/config/Stacks-mocknet.toml
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
stacks-blockchain:
build:
context: ../stacks-blockchain/docker
command: stacks-node start --config=/app/config/Stacks-follower.toml
command: stacks-node start --config /app/config/Stacks-follower.toml
restart: on-failure
environment:
STACKS_EVENT_OBSERVER: stacks-blockchain-api:3700
Expand Down
2 changes: 1 addition & 1 deletion docker/rosetta.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ case "${STACKS_NETWORK}" in
;;
esac
# start stacks-blockchain and store pid
${STACKS_BLOCKCHAIN_DIR}/stacks-node start --config=${STACKS_BLOCKCHAIN_DIR}/${STACKS_NETWORK}-follower-conf.toml 2>&1 &
${STACKS_BLOCKCHAIN_DIR}/stacks-node start --config ${STACKS_BLOCKCHAIN_DIR}/${STACKS_NETWORK}-follower-conf.toml 2>&1 &
STACKS_BLOCKCHAIN_PID=$!

# start stacks-blockchain-api and store pid
Expand Down
4 changes: 2 additions & 2 deletions docker/standalone-regtest.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ RUN <<EOF

export STACKS_EVENT_OBSERVER="127.0.0.1:3998"
envsubst < config.toml.in > config.toml
stacks-node start --config=config.toml &
stacks-node start --config config.toml &
STACKS_PID=$!

while true; do
Expand Down Expand Up @@ -359,7 +359,7 @@ cat > run.sh <<'EOM'

export STACKS_EVENT_OBSERVER="127.0.0.1:3700"
envsubst < config.toml.in > config.toml
stacks-node start --config=config.toml &
stacks-node start --config config.toml &
STACKS_PID=$!

while true; do
Expand Down
92 changes: 77 additions & 15 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@
"@scure/base": "1.1.1",
"@sinclair/typebox": "0.31.28",
"@stacks/common": "6.10.0",
"@stacks/encryption": "6.13.1",
"@stacks/network": "6.11.3",
"@stacks/stacking": "6.11.3",
"@stacks/stacking": "6.13.1",
"@stacks/transactions": "6.11.3",
"@types/express-list-endpoints": "4.0.1",
"@types/lru-cache": "5.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/ec-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function p2trAddressFromKey(args: KeyInputArgs): KeyOutput {
return { ecPair, address: pmnt.address };
}

export interface VerboseKeyOutput {
interface VerboseKeyOutput {
address: string;
wif: string;
privateKey: Buffer;
Expand Down
37 changes: 31 additions & 6 deletions src/tests-2.5/pox-4-btc-address-formats.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hexToBuffer, timeout } from '@hirosystems/api-toolkit';
import { decodeBtcAddress } from '@stacks/stacking';
import { StackingClient, decodeBtcAddress } from '@stacks/stacking';
import {
AddressStxBalanceResponse,
BurnchainRewardListResponse,
Expand All @@ -8,9 +8,11 @@ import {
} from '@stacks/stacks-blockchain-api-types';
import {
AnchorMode,
StacksPrivateKey,
bufferCV,
makeContractCall,
randomBytes,
makeRandomPrivKey,
someCV,
tupleCV,
uintCV,
} from '@stacks/transactions';
Expand All @@ -27,6 +29,8 @@ import {
testEnv,
} from '../test-utils/test-helpers';
import { RPCClient } from 'rpc-bitcoin';
import { hexToBytes } from '@stacks/common';
import { getPublicKeyFromPrivate } from '@stacks/encryption';

const BTC_PRIVATE_KEY = '0000000000000000000000000000000000000000000000000000000000000002';

Expand All @@ -41,7 +45,10 @@ describe.each([P2SH_P2WPKH, P2WPKH, P2WSH, P2TR])(
let contractAddress: string;
let contractName: string;
let ustxAmount: bigint;
const cycleCount = 1;
let stackingClient: StackingClient;
let signerPrivKey: StacksPrivateKey;
let signerPubKey: string;
const cycleCount = 2;

const { btcAddr, btcAddrDecoded, btcAddrRegtest, btcDescriptor } = addressSetup();

Expand Down Expand Up @@ -95,10 +102,25 @@ describe.each([P2SH_P2WPKH, P2WPKH, P2WSH, P2TR])(
cycleBlockLength = cycleCount * poxInfo.reward_cycle_length;
[contractAddress, contractName] = poxInfo.contract_id.split('.');

stackingClient = new StackingClient(account.stacksAddress, testEnv.stacksNetwork);
signerPrivKey = makeRandomPrivKey();
signerPubKey = getPublicKeyFromPrivate(signerPrivKey.data);

expect(contractName).toBe('pox-4');
});

test('stack-stx tx', async () => {
const signerSig = hexToBytes(
stackingClient.signPoxSignature({
topic: 'stack-stx',
poxAddress: btcAddr,
rewardCycle: poxInfo.current_cycle.id,
period: cycleCount,
signerPrivateKey: signerPrivKey,
maxAmount: ustxAmount,
authId: 0,
})
);
// Create and broadcast a `stack-stx` tx
const tx = await makeContractCall({
senderKey: account.secretKey,
Expand All @@ -113,7 +135,10 @@ describe.each([P2SH_P2WPKH, P2WPKH, P2WSH, P2TR])(
}), // pox-addr
uintCV(burnBlockHeight), // start-burn-ht
uintCV(cycleCount), // lock-period
bufferCV(randomBytes(33)), // signer-key
someCV(bufferCV(signerSig)), // signer-sig
bufferCV(hexToBytes(signerPubKey)), // signer-key
uintCV(ustxAmount.toString()), // max-amount
uintCV(0), // auth-id
],
network: testEnv.stacksNetwork,
anchorMode: AnchorMode.OnChainOnly,
Expand Down Expand Up @@ -160,7 +185,7 @@ describe.each([P2SH_P2WPKH, P2WPKH, P2WSH, P2TR])(
test('stx unlocked - RPC balance', async () => {
// Wait until account has unlocked (finished Stacking cycles)
const rpcAccount = await testEnv.client.getAccount(account.stacksAddress);
await standByUntilBurnBlock(rpcAccount.unlock_height + 1);
await standByUntilBurnBlock(rpcAccount.unlock_height + poxInfo.reward_phase_block_length);

// Check that STX are no longer reported as locked by the RPC endpoints:
await timeout(200); // make sure unlock was processed
Expand All @@ -182,7 +207,7 @@ describe.each([P2SH_P2WPKH, P2WPKH, P2WSH, P2TR])(

test('stacking rewards - API', async () => {
const slotStart = poxInfo.next_cycle.reward_phase_start_block_height;
const slotEnd = slotStart + 2; // early in the reward phase
const slotEnd = slotStart + 6; // early in the reward phase for the next-next cycle

const rewards = await fetchGet<BurnchainRewardListResponse>(
`/extended/v1/burnchain/rewards/${btcAddr}`
Expand Down
6 changes: 2 additions & 4 deletions src/tests-2.5/pox-4-burnchain-delegate-stx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import {
} from '@stacks/stacks-blockchain-api-types';
import {
AnchorMode,
bufferCV,
makeContractCall,
makeSTXTokenTransfer,
randomBytes,
standardPrincipalCV,
uintCV,
} from '@stacks/transactions';
Expand Down Expand Up @@ -359,8 +357,8 @@ describe('PoX-4 - Stack using Bitcoin-chain delegate ops', () => {
'(define-public (delegate-stx (amount-ustx uint) (delegate-to principal) (until-burn-ht (optional uint)) (pox-addr (optional (tuple (hashbytes (buff 32)) (version (buff 1)))))))',
function_args: [
{
hex: '0x0100000000000000000007fe8f3d591000',
repr: 'u2250216000000000',
hex: '0x010000000000000000000ffd1e7ab22000',
repr: 'u4500432000000000',
name: 'amount-ustx',
type: 'uint',
},
Expand Down
Loading

0 comments on commit ab98b97

Please sign in to comment.