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

fix: pox 4 revoke events #1829

Merged
merged 30 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9513267
fix: add pox-4 event tests
janniks Jan 16, 2024
f950379
test: fix pox-4 revoke test
janniks Jan 16, 2024
3a95c3c
chore: remove unused param from synthetic event
janniks Jan 17, 2024
dedfec8
test: add signer-keys
janniks Jan 17, 2024
8a0bc89
test: add more signer-keys
janniks Jan 17, 2024
c0d3de5
chore: update to beta stacking client
janniks Jan 17, 2024
a44cfce
test: fix single test
janniks Jan 22, 2024
62187cf
test: refactor btc address format stacking with bitcoin rpc
janniks Jan 22, 2024
bfcaa8a
test: fix pox-4-stack-extend-increase
janniks Jan 22, 2024
6607888
fix: update rosetta to use signer-key
janniks Jan 23, 2024
3abc4a3
build: add generated docs
janniks Jan 25, 2024
3f6b318
test: fix rosetta test
janniks Jan 23, 2024
9bdd4bf
fix: update to latest node image
janniks Jan 23, 2024
4716404
chore: bump latest stacks-node image
zone117x Jan 23, 2024
4ac5169
fix(test): update arg ordering for delegate-stack-extend
zone117x Jan 23, 2024
9a8969b
fix(test): update arg ordering for delegate-stack-extend
zone117x Jan 24, 2024
f34fa5c
test: revert size change for delegate-stx action
janniks Jan 24, 2024
6a2ca7d
test: skip broken burnchain op test
janniks Jan 24, 2024
3f22c66
test: unflake timing of pox test with reward slots
janniks Jan 24, 2024
091a6f6
chore: update test helper, since current_cycle.id can be incorrect
janniks Jan 24, 2024
c80d3cd
test: fix btc address test
janniks Jan 24, 2024
9bfb9d7
test: add timing tolerance on unlock tests
janniks Jan 24, 2024
966aeca
test: add timing tolerance on reward test
janniks Jan 24, 2024
02c119d
test: allow multiple rewards
janniks Jan 24, 2024
55a8b25
test: allow multiple rewards
janniks Jan 24, 2024
11ba147
fix: add migration for pox-4
janniks Jan 25, 2024
20db1c0
chore: undo beta version of stackingclient
janniks Jan 25, 2024
ffe0502
ci: do not require epoch2.5 tests to pass for now, too flaky
zone117x Jan 25, 2024
554e6ee
test: switch order in test
janniks Jan 25, 2024
ab363ef
test: fix flakiness with `pox-4-btc-address-formats` tests (#1849)
zone117x Jan 25, 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
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,6 @@ jobs:
- lint
- lint-docs
- test
- test-2_5
- test-bns
- test-rosetta
- test-rosetta-cli-construction
Expand Down
10 changes: 9 additions & 1 deletion client/src/generated/models/RosettaOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable */
/**
* Stacks Blockchain API
* Welcome to the API reference overview for the <a href=\"https://docs.hiro.so/get-started/stacks-blockchain-api\">Stacks Blockchain API</a>. <a href=\"https://hirosystems.github.io/stacks-blockchain-api/collection.json\" download=\"stacks-api-collection.json\">Download Postman collection</a>
* Welcome to the API reference overview for the [Stacks Blockchain API](https://docs.hiro.so/get-started/stacks-blockchain-api). [Download Postman collection](https://hirosystems.github.io/stacks-blockchain-api/collection.json)
*
* The version of the OpenAPI document: STACKS_API_VERSION
*
Expand Down Expand Up @@ -139,6 +139,12 @@ export interface RosettaOptions {
* @memberof RosettaOptions
*/
pox_addr?: string;
/**
* The hex-encoded signer key (buff 33) for PoX.
* @type {string}
* @memberof RosettaOptions
*/
signer_key?: string;
}

export function RosettaOptionsFromJSON(json: any): RosettaOptions {
Expand Down Expand Up @@ -171,6 +177,7 @@ export function RosettaOptionsFromJSONTyped(json: any, ignoreDiscriminator: bool
'burn_block_height': !exists(json, 'burn_block_height') ? undefined : json['burn_block_height'],
'delegate_to': !exists(json, 'delegate_to') ? undefined : json['delegate_to'],
'pox_addr': !exists(json, 'pox_addr') ? undefined : json['pox_addr'],
'signer_key': !exists(json, 'signer_key') ? undefined : json['signer_key'],
};
}

Expand Down Expand Up @@ -203,6 +210,7 @@ export function RosettaOptionsToJSON(value?: RosettaOptions | null): any {
'burn_block_height': value.burn_block_height,
'delegate_to': value.delegate_to,
'pox_addr': value.pox_addr,
'signer_key': value.signer_key,
};
}

8 changes: 4 additions & 4 deletions docker/docker-compose.dev.stacks-blockchain.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
version: '3.7'
services:
stacks-blockchain:
image: "hirosystems/stacks-api-e2e:stacks3.0-800259e"
image: 'hirosystems/stacks-api-e2e:stacks3.0-1d675fd'
restart: on-failure
environment:
STACKS_EVENT_OBSERVER: host.docker.internal:3700
BLOCKSTACK_USE_TEST_GENESIS_CHAINSTATE: 1
NOP_BLOCKSTACK_DEBUG: 1
ports:
- "20443:20443"
- "20444:20444"
- '20443:20443'
- '20444:20444'
volumes:
- ../stacks-blockchain/:/app/config
- ../stacks-blockchain/.chaindata:/tmp/stacks-blockchain-data
extra_hosts:
- "host.docker.internal:host-gateway" # fixes `host.docker.internal` on linux hosts
- 'host.docker.internal:host-gateway' # fixes `host.docker.internal` on linux hosts
12 changes: 6 additions & 6 deletions docker/docker-compose.dev.stacks-krypton.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
version: '3.7'
services:
stacks-blockchain:
image: "hirosystems/stacks-api-e2e:stacks3.0-800259e"
image: 'hirosystems/stacks-api-e2e:stacks3.0-1d675fd'
ports:
- "18443:18443" # bitcoin regtest JSON-RPC interface
- "18444:18444" # bitcoin regtest p2p
- "20443:20443" # stacks-node RPC interface
- "20444:20444" # stacks-node p2p
- '18443:18443' # bitcoin regtest JSON-RPC interface
- '18444:18444' # bitcoin regtest p2p
- '20443:20443' # stacks-node RPC interface
- '20444:20444' # stacks-node p2p
environment:
MINE_INTERVAL: 0.1s
STACKS_EVENT_OBSERVER: host.docker.internal:3700
# STACKS_LOG_TRACE: 1
# STACKS_LOG_DEBUG: 1
extra_hosts:
- "host.docker.internal:host-gateway" # fixes `host.docker.internal` on linux hosts
- 'host.docker.internal:host-gateway' # fixes `host.docker.internal` on linux hosts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
"pox_addr": {
"type": "string",
"description": "The reward address for stacking transaction. It should be a valid Bitcoin address"
},
"signer_key": {
"type": "string",
"description": "The hex-encoded signer key (buff 33) for PoX."
}
}
}
4 changes: 4 additions & 0 deletions docs/generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2538,6 +2538,10 @@ export interface RosettaOptions {
* The reward address for stacking transaction. It should be a valid Bitcoin address
*/
pox_addr?: string;
/**
* The hex-encoded signer key (buff 33) for PoX.
*/
signer_key?: string;
}
/**
* The ConstructionMetadataResponse returns network-specific metadata used for transaction construction. Optionally, the implementer can return the suggested fee associated with the transaction being constructed. The caller may use this info to adjust the intent of the transaction or to create a transaction with a different account that can pay the suggested fee. Suggested fee is an array in case fee payment must occur in multiple currencies.
Expand Down
115 changes: 115 additions & 0 deletions migrations/1706196613000_update-pox4-event-constraint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/* eslint-disable camelcase */

exports.shorthands = undefined;

exports.up = pgm => {
pgm.dropConstraint('pox4_events', 'valid_event_specific_columns', { ifExists: true });
pgm.addConstraint(
'pox4_events',
'valid_event_specific_columns',
`CHECK (
CASE name
WHEN 'handle-unlock' THEN
first_cycle_locked IS NOT NULL AND
first_unlocked_cycle IS NOT NULL
WHEN 'stack-stx' THEN
lock_period IS NOT NULL AND
lock_amount IS NOT NULL AND
start_burn_height IS NOT NULL AND
unlock_burn_height IS NOT NULL
WHEN 'stack-increase' THEN
increase_by IS NOT NULL AND
total_locked IS NOT NULL
WHEN 'stack-extend' THEN
extend_count IS NOT NULL AND
unlock_burn_height IS NOT NULL
WHEN 'delegate-stx' THEN
amount_ustx IS NOT NULL AND
delegate_to IS NOT NULL
WHEN 'delegate-stack-stx' THEN
lock_period IS NOT NULL AND
lock_amount IS NOT NULL AND
start_burn_height IS NOT NULL AND
unlock_burn_height IS NOT NULL AND
delegator IS NOT NULL
WHEN 'delegate-stack-increase' THEN
increase_by IS NOT NULL AND
total_locked IS NOT NULL AND
delegator IS NOT NULL
WHEN 'delegate-stack-extend' THEN
extend_count IS NOT NULL AND
unlock_burn_height IS NOT NULL AND
delegator IS NOT NULL
WHEN 'stack-aggregation-commit' THEN
reward_cycle IS NOT NULL AND
amount_ustx IS NOT NULL
WHEN 'stack-aggregation-commit-indexed' THEN
reward_cycle IS NOT NULL AND
amount_ustx IS NOT NULL
WHEN 'stack-aggregation-increase' THEN
reward_cycle IS NOT NULL AND
amount_ustx IS NOT NULL
WHEN 'revoke-delegate-stx' THEN
delegate_to IS NOT NULL
ELSE false
END
)`
);
};

exports.down = pgm => {
pgm.dropConstraint('pox4_events', 'valid_event_specific_columns', { ifExists: true });

// constraint from migrations/1702134678728_pox_4_events.js
// first, remove rows that would violate the constraint
pgm.sql("DELETE FROM pox4_events WHERE name = 'revoke-delegate-stx';");
zone117x marked this conversation as resolved.
Show resolved Hide resolved
pgm.addConstraint(
'pox4_events',
'valid_event_specific_columns',
`CHECK (
CASE name
WHEN 'handle-unlock' THEN
first_cycle_locked IS NOT NULL AND
first_unlocked_cycle IS NOT NULL
WHEN 'stack-stx' THEN
lock_period IS NOT NULL AND
lock_amount IS NOT NULL AND
start_burn_height IS NOT NULL AND
unlock_burn_height IS NOT NULL
WHEN 'stack-increase' THEN
increase_by IS NOT NULL AND
total_locked IS NOT NULL
WHEN 'stack-extend' THEN
extend_count IS NOT NULL AND
unlock_burn_height IS NOT NULL
WHEN 'delegate-stx' THEN
amount_ustx IS NOT NULL AND
delegate_to IS NOT NULL
WHEN 'delegate-stack-stx' THEN
lock_period IS NOT NULL AND
lock_amount IS NOT NULL AND
start_burn_height IS NOT NULL AND
unlock_burn_height IS NOT NULL AND
delegator IS NOT NULL
WHEN 'delegate-stack-increase' THEN
increase_by IS NOT NULL AND
total_locked IS NOT NULL AND
delegator IS NOT NULL
WHEN 'delegate-stack-extend' THEN
extend_count IS NOT NULL AND
unlock_burn_height IS NOT NULL AND
delegator IS NOT NULL
WHEN 'stack-aggregation-commit' THEN
reward_cycle IS NOT NULL AND
amount_ustx IS NOT NULL
WHEN 'stack-aggregation-commit-indexed' THEN
reward_cycle IS NOT NULL AND
amount_ustx IS NOT NULL
WHEN 'stack-aggregation-increase' THEN
reward_cycle IS NOT NULL AND
amount_ustx IS NOT NULL
ELSE false
END
)`
);
};
80 changes: 70 additions & 10 deletions package-lock.json

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

1 change: 0 additions & 1 deletion src/api/controllers/db-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ export function parsePoxSyntheticEvent(poxEvent: DbPoxSyntheticEvent) {
return {
...baseInfo,
data: {
amount_ustx: poxEvent.data.amount_ustx.toString(),
delegate_to: poxEvent.data.delegate_to,
},
};
Expand Down
Loading
Loading