Closed zone117x closed 1 year ago
The auto stack-unlock does not have an explicit contract-call function where we can include a print statement.
You can add print
statements to the handle-unlock
private function -- it gets invoked during the auto-unlock. Events from those invocations are all collected together. The current version in next
doesn't create a transaction receipt for those events, but this branch adds a new synthetic transaction receipt to capture those:
https://github.com/stacks-network/stacks-blockchain/tree/feat/unlock-events
It may be expensive (from a tx fee perspective) to lookup the info required to invoke these print statements. An event-emitter node already expects to spend more resources processing events -- but maybe unfair if users have to pay for regular miner nodes to generate the print data?
How expensive? Is it doing additional data fetches, and if so, like how many per operation? If it's only 1-2 more data lookups, I'm not so concerned about it. If it's more than that, then we would have to move the event generation into the rust code.
I think each print statement would need to call get-stacker-info
, reward-cycle-to-burn-height
, and stx-get-balance
if we wanted to include the full STX balance payload mentioned above. It sounds like that would be alright to implement in pox-2 Clarity?
@pavitthrap Will help with this task once https://github.com/stacks-network/stacks-blockchain/issues/3284 is wrapped up this week.
I think each print statement would need to call get-stacker-info, reward-cycle-to-burn-height, and stx-get-balance if we wanted to include the full STX balance payload mentioned above. It sounds like that would be alright to implement in pox-2 Clarity?
Yep, that would all be fine to add to pox-2
's contract. A lot of that information may be available without an additional lookup, too.
Could there be an "epoch transition" event emitted that indicated, among other things, the v1 unlock height?
The anchored block could also indicate its epoch.
pox_v1_unlock_height
to the new_block
event pushed to the API to help determine when the pox1 locked amounts become unlocked.This is closed by https://github.com/stacks-network/stacks-blockchain/pull/3318
This is a partial blocker for PoX-2 support in the API (and clients that depend on PoX related features in the API).
Every operation that changes PoX state should emit an event that includes both the operation-specific data, and global state for the given account.
For example, with a
stack-extend
:These events can almost all be emitted through
print
statements in the PoX-2 contract, except for:stack-unlock
does not have an explicit contract-call function where we can include aprint
statement.print
statements. An event-emitter node already expects to spend more resources processing events -- but maybe unfair if users have to pay for regular miner nodes to generate theprint
data?The API has two primary use cases for these events:
Determining an account's locked STX balance
See https://github.com/hirosystems/stacks-blockchain-api/issues/1277
Right now, Stacks 2.0 emits a
stx_lock_event
event which the API can store and query to determine locked STX. In PoX-2, this event is no longer enough to determine that state in given the new features in PoX-2 (e.g.stack-extend
, autostack-unlock
, etc).Parsing "PoX operations" in the Rosetta implementation
See https://github.com/hirosystems/stacks-blockchain-api/issues/1278
The Rosetta spec (used by at least a couple major exchanges) has a
Data API
which requires the API to generate "operations" for a given block. In order to create "PoX operations", the current implementation scans contract-call transactions for the PoX contract and thestack-stx
function name, then manually parses Clarity args to generate a Stacking operation. This approach has major limitations: