Skip to content

Commit 7480a18

Browse files
committed
Website/transaction: update documentation about coinbase transfers
1 parent 63a7865 commit 7480a18

File tree

1 file changed

+58
-178
lines changed

1 file changed

+58
-178
lines changed

website/docs/developers/transactions/coinbase.md

Lines changed: 58 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ Coinbase transactions are constructed with validation logic:
4242
<!-- CODE_REFERENCE: ledger/src/scan_state/transaction_logic/mod.rs#L452-L473 -->
4343

4444
```rust reference title="ledger/src/scan_state/transaction_logic/mod.rs"
45-
https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/mod.rs#L452-L473
45+
https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/mod.rs#L452-L476
4646
```
4747

4848
## Transaction application
4949

5050
### First pass
5151

5252
During the first pass
53-
([`apply_transaction_first_pass`](https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs#L190)),
53+
([`apply_coinbase`](https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs#L454)),
5454
the coinbase:
5555

5656
1. **Applies coinbase reward**
@@ -63,9 +63,6 @@ the coinbase:
6363
- Deducts fee from coinbase receiver's reward
6464
- Creates fee transfer receiver account if needed
6565

66-
**Implementation:**
67-
[`ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs`](https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs)
68-
6966
### No fee payment
7067

7168
Like fee transfers, coinbase transactions do not pay fees:
@@ -77,221 +74,104 @@ Like fee transfers, coinbase transactions do not pay fees:
7774

7875
## Coinbase amount
7976

80-
The coinbase amount is configured in constraint constants:
81-
82-
```rust
83-
pub struct ConstraintConstants {
84-
pub coinbase_amount: u64, // 720_000_000_000 (720 MINA)
85-
pub supercharged_coinbase_factor: u32, // 2x for supercharged rewards
86-
// ...
87-
}
88-
```
77+
The coinbase amount is configured in
78+
[`ConstraintConstants`](https://github.com/o1-labs/mina-rust/blob/develop/core/src/constants.rs#L39-L42)
79+
(`core/src/constants.rs`), which includes the base `coinbase_amount` and the
80+
`supercharged_coinbase_factor` for rewards when SNARK work is included. The
81+
specific values are defined in the network configurations:
82+
[devnet](https://github.com/o1-labs/mina-rust/blob/develop/core/src/network.rs#L145-L146)
83+
sets `coinbase_amount` to 720,000,000,000 nanomina (720 MINA) and
84+
`supercharged_coinbase_factor` to 1, while
85+
[mainnet](https://github.com/o1-labs/mina-rust/blob/develop/core/src/network.rs#L223-L224)
86+
uses the same values.
8987

9088
### Supercharged coinbase
9189

92-
Block producers who include SNARK work may receive a supercharged coinbase (2x
93-
the base amount). This incentivizes SNARK work production and inclusion.
90+
Supercharged rewards were designed to provide double block rewards (factor of 2)
91+
to block producers staking with unlocked tokens during the early mainnet period
92+
following the 2021 launch. This mechanism incentivized participation and orderly
93+
markets after mainnet launch.
94+
95+
**Historical values**:
96+
97+
- Original mainnet: 2 (double rewards for unlocked tokens)
98+
- Berkeley hardfork (June 2024): 1 (supercharged rewards removed via
99+
[MIP1](https://github.com/MinaProtocol/MIPs/blob/main/MIPS/mip-0001-remove-supercharged-rewards.md))
100+
101+
The removal was decided by community vote on January 1, 2023, as proposed by
102+
community member Gareth Davies. This change ensures uniform rewards for all
103+
tokens and reduces inflation, promoting a sustainable economic model.
104+
105+
**References**:
106+
107+
- [Berkeley Upgrade](https://minaprotocol.com/blog/minas-berkeley-upgrade-what-to-expect)
108+
- [Supercharged Rewards Removal](https://minaprotocol.com/blog/update-on-minas-supercharged-rewards-schedule)
109+
- [Original Proposal](https://github.com/MinaProtocol/mina/issues/5753)
94110

95111
## Fee transfer interaction
96112

97113
### Splitting the reward
98114

99-
When a coinbase includes a fee transfer, the reward is split:
115+
When a coinbase includes a fee transfer, the reward is split
116+
([implementation](https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs#L496-L498)):
100117

101118
- **Coinbase receiver**: Gets `coinbase_amount - fee_transfer_amount`
102119
- **Fee transfer receiver**: Gets `fee_transfer_amount`
103120

104121
This mechanism allows block producers to share rewards with SNARK workers.
105122

106-
### Same receiver optimization
123+
### Same receiver
107124

108125
If the fee transfer receiver equals the coinbase receiver, the fee transfer is
109-
removed:
126+
removed
127+
([`Coinbase::create`](https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/mod.rs#L452)):
110128

111-
```rust
112-
// Fee transfer to self is removed
113-
let coinbase = Coinbase::create(
114-
amount,
115-
alice_pk.clone(),
116-
Some(CoinbaseFeeTransfer::create(alice_pk.clone(), fee))
117-
).unwrap();
129+
<!-- CODE_REFERENCE: ledger/src/scan_state/transaction_logic/mod.rs#L464-L472 -->
118130

119-
assert!(coinbase.fee_transfer.is_none());
131+
```rust reference title="ledger/src/scan_state/transaction_logic/mod.rs"
132+
https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/mod.rs#L464-L472
120133
```
121134

122-
This prevents unnecessary complexity when the reward would go to the same
123-
account.
124-
125135
## Account creation
126136

127137
If receiver accounts don't exist, they are created automatically:
128138

129139
### Coinbase receiver creation
130140

131-
```rust
132-
// Coinbase receiver gets: coinbase_amount - account_creation_fee
133-
let expected_balance = Balance::from_u64(
134-
coinbase_amount.as_u64().saturating_sub(account_creation_fee)
135-
);
136-
```
137-
138-
### Fee transfer receiver creation
139-
140-
The fee transfer receiver follows standard account creation rules (fee transfer
141-
must be sufficient to cover the account creation fee).
142-
143-
## Examples
141+
When creating a new coinbase receiver account, the account creation fee is
142+
deducted from the reward:
144143

145-
### Coinbase without fee transfer
144+
<!-- CODE_REFERENCE: ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs#L559-L561 -->
146145

147-
From the test suite (`tests/test_transaction_logic_first_pass_coinbase.rs:76`):
148-
149-
```rust
150-
// Create coinbase of 720 MINA to Alice with no fee transfer
151-
let coinbase_amount = Amount::from_u64(720_000_000_000);
152-
let coinbase = Coinbase::create(coinbase_amount, alice_pk.clone(), None).unwrap();
153-
154-
let result = apply_transaction_first_pass(
155-
constraint_constants,
156-
Slot::from_u32(0),
157-
&state_view,
158-
&mut ledger,
159-
&Transaction::Coinbase(coinbase),
160-
);
161-
162-
assert!(result.is_ok());
163-
164-
// Verify state changes:
165-
// - Alice's balance increased by 720 MINA
166-
// - Alice's nonce unchanged (coinbase doesn't affect nonces)
146+
```rust reference title="ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs"
147+
https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs#L559-L561
167148
```
168149

169-
### Coinbase with fee transfer
170-
171-
From the test suite (`tests/test_transaction_logic_first_pass_coinbase.rs:135`):
172-
173-
```rust
174-
// Create coinbase of 720 MINA to Alice with 10 MINA fee transfer to Bob
175-
let coinbase_amount = Amount::from_u64(720_000_000_000);
176-
let fee_transfer_amount = Fee::from_u64(10_000_000_000);
177-
let fee_transfer = CoinbaseFeeTransfer::create(bob_pk.clone(), fee_transfer_amount);
178-
let coinbase = Coinbase::create(coinbase_amount, alice_pk.clone(), Some(fee_transfer)).unwrap();
179-
180-
let result = apply_transaction_first_pass(/* ... */);
181-
182-
assert!(result.is_ok());
183-
184-
// Verify state changes:
185-
// - Alice's balance increased by: 720 - 10 = 710 MINA
186-
// - Bob's balance increased by: 10 MINA
187-
// - Both nonces unchanged
188-
```
189-
190-
### Coinbase with fee transfer to same account
191-
192-
From the test suite (`tests/test_transaction_logic_first_pass_coinbase.rs:231`):
193-
194-
```rust
195-
// Create coinbase to Alice with fee transfer also to Alice
196-
let coinbase_amount = Amount::from_u64(720_000_000_000);
197-
let fee_transfer_amount = Fee::from_u64(10_000_000_000);
198-
let fee_transfer = CoinbaseFeeTransfer::create(alice_pk.clone(), fee_transfer_amount);
199-
let coinbase = Coinbase::create(coinbase_amount, alice_pk.clone(), Some(fee_transfer)).unwrap();
200-
201-
// Fee transfer is removed during creation
202-
assert!(coinbase.fee_transfer.is_none());
203-
204-
let result = apply_transaction_first_pass(/* ... */);
150+
The
151+
[`sub_account_creation_fee`](https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs#L653)
152+
function handles the fee deduction logic.
205153

206-
assert!(result.is_ok());
207-
208-
// Alice receives only the coinbase amount (not coinbase + fee transfer)
209-
// - Alice's balance increased by: 720 MINA
210-
```
211-
212-
### Coinbase creating account
213-
214-
From the test suite (`tests/test_transaction_logic_first_pass_coinbase.rs:306`):
215-
216-
```rust
217-
// Create coinbase of 720 MINA to Bob (who doesn't exist yet)
218-
let coinbase_amount = Amount::from_u64(720_000_000_000);
219-
let coinbase = Coinbase::create(coinbase_amount, bob_pk.clone(), None).unwrap();
220-
221-
let result = apply_transaction_first_pass(/* ... */);
222-
223-
assert!(result.is_ok());
224-
225-
// Bob's account created with: 720 - 1 (account creation fee) = 719 MINA
226-
```
227-
228-
## Block production workflow
229-
230-
### Coinbase generation
231-
232-
During block production:
233-
234-
1. Block producer successfully produces a block
235-
2. Coinbase transaction is created with the configured amount
236-
3. Optional fee transfer is added for SNARK workers
237-
4. Coinbase is applied as the first transaction in the block
238-
239-
### SNARK work incentive
240-
241-
The fee transfer mechanism incentivizes SNARK work:
242-
243-
- Block producers can allocate fees to SNARK workers
244-
- Workers receive compensation for proof generation
245-
- Creates a marketplace for SNARK work
246-
247-
## Supercharged coinbase
248-
249-
Blocks that include sufficient SNARK work may receive supercharged coinbase:
250-
251-
```rust
252-
let supercharged_amount = if includes_snark_work {
253-
coinbase_amount * supercharged_coinbase_factor // 720 * 2 = 1440 MINA
254-
} else {
255-
coinbase_amount // 720 MINA
256-
};
257-
```
258-
259-
This provides additional incentive for including SNARK work in blocks.
260-
261-
## Balance constraints
154+
### Fee transfer receiver creation
262155

263-
### Account creation
156+
The fee transfer receiver follows standard account creation rules (fee transfer
157+
must be sufficient to cover the account creation fee):
264158

265-
When creating coinbase receiver account:
159+
<!-- CODE_REFERENCE: ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs#L508-L509 -->
266160

267-
```rust
268-
if coinbase_amount < account_creation_fee {
269-
// Coinbase may fail or create account with zero balance
270-
}
161+
```rust reference title="ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs"
162+
https://github.com/o1-labs/mina-rust/blob/develop/ledger/src/scan_state/transaction_logic/transaction_partially_applied.rs#L508-L509
271163
```
272164

273-
### Receiver balance limits
274-
275-
The receiver's balance cannot overflow the maximum amount (2^64 nanomina).
276-
277-
## Monetary policy
278-
279-
Coinbase transactions are the primary mechanism for:
280-
281-
- **Token issuance**: New MINA enters circulation
282-
- **Block producer rewards**: Compensation for consensus participation
283-
- **Network security**: Economic incentive for honest behavior
284-
285-
The coinbase amount and issuance schedule are defined in constraint constants
286-
and may change through protocol upgrades.
287-
288165
## Testing
289166

290167
Comprehensive tests are available in
291168
[`ledger/tests/test_transaction_logic_first_pass_coinbase.rs`](https://github.com/o1-labs/mina-rust/blob/develop/ledger/tests/test_transaction_logic_first_pass_coinbase.rs):
292169

293170
- `test_apply_coinbase_without_fee_transfer` - Basic coinbase reward
294-
- `test_apply_coinbase_with_fee_transfer` - Coinbase with SNARK work payment
171+
- `test_apply_coinbase_with_fee_transfer` - Coinbase with SNARK work payment to
172+
existing account
173+
- `test_apply_coinbase_with_fee_transfer_creates_account` - Fee transfer
174+
creating new account
295175
- `test_apply_coinbase_with_fee_transfer_to_same_account` - Same receiver
296176
optimization
297177
- `test_apply_coinbase_creates_account` - Coinbase creating new account

0 commit comments

Comments
 (0)