Skip to content

Feat/coinbase pay to contract #3164

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

Merged
merged 41 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e64b87b
docs: warn the reader that get-block-info? only returns the miner add…
jcnelson Jun 8, 2022
4917d78
chore: coinbase variant takes an optional smart contract ID
jcnelson Jun 8, 2022
b8e0c78
feat: get the network-formatted address for a spending condition
jcnelson Jun 8, 2022
d94e05e
feat: add an optional smart contract ID to the transaction payload co…
jcnelson Jun 8, 2022
96920f3
feat: update MinerReward to track the reward recipient address separa…
jcnelson Jun 8, 2022
283d46a
feat: when preprocessing a block, pass the current epoch into the sta…
jcnelson Jun 8, 2022
304ced4
chore: store recipient address and miner address separately in the mi…
jcnelson Jun 8, 2022
4532672
chore: API sync with new coinbase variant
jcnelson Jun 8, 2022
f8ddaa9
feat: add new unit test for mining pay-to-contract blocks. Verify tha…
jcnelson Jun 8, 2022
2f18806
chore: add transaction codec test coverage for pay-to-contract coinba…
jcnelson Jun 8, 2022
058baf3
chore: add codec support for pay-to-contract coinbase transactions
jcnelson Jun 8, 2022
1fa2459
chore: API sync -- use the new coinbase variant constructor
jcnelson Jun 8, 2022
688e835
chore: use the new coinbase type variant
jcnelson Jun 8, 2022
585f06c
fix: if a block has no parent, patch its block-commit to refer to (0,…
jcnelson Jun 8, 2022
d4e9ce1
chore: add a unit test to verify that the relayer rejects pay-to-cont…
jcnelson Jun 8, 2022
e4f08cb
chore: use the new coinbase variant
jcnelson Jun 8, 2022
ab05aa6
feat: add pay_to_contract field under [miner] to make the miner pay t…
jcnelson Jun 8, 2022
aea2412
feat: generate a pay-to-contract coinbase if a contract address is in…
jcnelson Jun 8, 2022
50dc6ae
chore: use new coinbase variant
jcnelson Jun 8, 2022
fc41895
chore: use new coinbase variant
jcnelson Jun 8, 2022
f404a13
chore: use new coinbase variant
jcnelson Jun 8, 2022
3c9a5bd
feat: add integration test to verify that the miner will build pay-to…
jcnelson Jun 8, 2022
90a9f68
Merge branch 'next' into feat/coinbase-pay-to-contract
jcnelson Jun 8, 2022
dfbd0e0
fix: failing to preprocess a stacks block because it is invalid (e.g.…
jcnelson Jun 8, 2022
65dcc53
chore: run new integration test to make sure pay-to-contract activates
jcnelson Jun 27, 2022
d6dbd1b
chore: "warning" --> "note"
jcnelson Jun 27, 2022
3a6e7f1
chore: log txid in rejecting coinbase tx
jcnelson Jun 27, 2022
bb4fec8
chore: support PrincipalData as an optional block reward recipient
jcnelson Jun 28, 2022
cabcd79
feat: `recipient` can be either a standard or contract principal, and…
jcnelson Jun 28, 2022
c0de7e7
feat: block reward can be paid to a standard principal or contract pr…
jcnelson Jun 28, 2022
bc90068
feat: block reward recipient is unconditionally set now, and can be e…
jcnelson Jun 28, 2022
60ec41b
chore: test coverage for paying the block reward to either an alterna…
jcnelson Jun 28, 2022
2422882
chore: test coverage for codec for standard and contract principals a…
jcnelson Jun 28, 2022
6a4b3c3
feat: coinbase can encode a standard or contract principal as an alte…
jcnelson Jun 28, 2022
06f088a
chore: API sync
jcnelson Jun 28, 2022
608eabf
chore: it's now [miner].block_reward_recipient
jcnelson Jun 28, 2022
00838aa
chore: support both standard and contract principals when building co…
jcnelson Jun 28, 2022
e8c85f8
chore: test coverage for both paying to contracts and standard princi…
jcnelson Jun 28, 2022
d813eb8
chore: fix #3159 by separating out miner tests into their own test mo…
jcnelson Jun 28, 2022
768a608
chore: plumb through refactoring
jcnelson Jun 28, 2022
6376520
Merge pull request #3180 from stacks-network/fix/3159
jcnelson Jun 29, 2022
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: 1 addition & 0 deletions .github/workflows/bitcoin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
- tests::epoch_21::transition_fixes_utxo_chaining
- tests::epoch_21::transition_adds_burn_block_height
- tests::epoch_21::transition_fixes_bitcoin_rigidity
- tests::epoch_21::transition_adds_pay_to_contract
steps:
- uses: actions/checkout@v2
- name: Download docker image
Expand Down
6 changes: 4 additions & 2 deletions clarity/src/vm/docs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1470,10 +1470,12 @@ from the block hash and the history of accepted PoX operations. This is also th
`header-hash`: This property returns a `(buff 32)` value containing the header hash of a Stacks block, given a Stacks chain height. **WARNING* this hash is
not guaranteed to be globally unique, since the same Stacks block can be mined in different PoX forks. If you need global uniqueness, you should use `id-header-hash`.

`miner-address`: This property returns a `principal` value corresponding to the miner of the given block.
`miner-address`: This property returns a `principal` value corresponding to the miner of the given block. **WARNING** In Stacks 2.1, this is not guaranteed to
be the same `principal` that received the block reward, since Stacks 2.1 supports coinbase transactions that pay the reward to a contract address. This is merely
the address of the `principal` that produced the block.
Comment on lines +1473 to +1475
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of a **WARNING**, this should just be a Note:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


`time`: This property returns a `uint` value of the block header time field. This is a Unix epoch timestamp in seconds
which roughly corresponds to when the block was mined. **Warning**: this does not increase monotonically with each block
which roughly corresponds to when the block was mined. **Note**: this does not increase monotonically with each block
and block times are accurate only to within two hours. See [BIP113](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki) for more information.

New in Stacks 2.1:
Expand Down
4 changes: 2 additions & 2 deletions src/chainstate/coordinator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ fn make_genesis_block_with_recipients(
let mut tx = StacksTransaction::new(
TransactionVersion::Testnet,
tx_auth,
TransactionPayload::Coinbase(CoinbasePayload([0u8; 32])),
TransactionPayload::Coinbase(CoinbasePayload([0u8; 32]), None),
);
tx.chain_id = 0x80000000;
tx.anchor_mode = TransactionAnchorMode::OnChainOnly;
Expand Down Expand Up @@ -612,7 +612,7 @@ fn make_stacks_block_with_input(
let mut tx = StacksTransaction::new(
TransactionVersion::Testnet,
tx_auth,
TransactionPayload::Coinbase(CoinbasePayload([0u8; 32])),
TransactionPayload::Coinbase(CoinbasePayload([0u8; 32]), None),
);
tx.chain_id = 0x80000000;
tx.anchor_mode = TransactionAnchorMode::OnChainOnly;
Expand Down
9 changes: 9 additions & 0 deletions src/chainstate/stacks/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,15 @@ impl TransactionSpendingCondition {
}
}

/// Get the address for an account, given the network flag
pub fn get_address(&self, mainnet: bool) -> StacksAddress {
if mainnet {
self.address_mainnet()
} else {
self.address_testnet()
}
}

/// Clear fee rate, nonces, signatures, and public keys
pub fn clear(&mut self) -> () {
match *self {
Expand Down
Loading