[#1294] Remove all uses of the incorrect 1000-ZAT fee
- Removed deprecated zip-313 fee of 1000 Zatoshi - default is now 10k zatoshi, the minimum defined by zip-317 [#1294] Remove all uses of the incorrect 1000-ZAT fee - changelog update
This commit is contained in:
parent
494a060469
commit
69e38e0667
|
@ -4,6 +4,15 @@ All notable changes to this library will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
# 2.0.1 - 2023-09-29
|
||||
|
||||
## Changed
|
||||
|
||||
### [#1294] Remove all uses of the incorrect 1000-ZAT fee
|
||||
The 1000 Zatoshi fee proposed in ZIP-313 is deprecated now and so the minimum is 10k Zatoshi, defined in ZIP-317.
|
||||
The SDK has been cleaned up from deprecated fee but note, real fee is handled in a rust layer.
|
||||
The public API `NetworkConstants.defaultFee(for: BlockHeight)` has been refactored to `NetworkConstants.defaultFee()`.
|
||||
|
||||
# 2.0.0 - 2023-09-25
|
||||
|
||||
## Notable Changes
|
||||
|
|
|
@ -154,19 +154,13 @@ public protocol NetworkConstants {
|
|||
/// Default prefix for db filenames
|
||||
static var defaultDbNamePrefix: String { get }
|
||||
|
||||
/// fixed height where the SDK considers that the ZIP-321 was deployed. This is a workaround
|
||||
/// for librustzcash not figuring out the tx fee from the tx itself.
|
||||
static var feeChangeHeight: BlockHeight { get }
|
||||
|
||||
/// Returns the default fee according to the blockheight. see [ZIP-313](https://zips.z.cash/zip-0313)
|
||||
static func defaultFee(for height: BlockHeight) -> Zatoshi
|
||||
/// Returns the default fee, hardcoded 10k Zatoshi is the minimum ZIP 317 fee
|
||||
static func defaultFee() -> Zatoshi
|
||||
}
|
||||
|
||||
public extension NetworkConstants {
|
||||
static func defaultFee(for height: BlockHeight = BlockHeight.max) -> Zatoshi {
|
||||
guard height >= feeChangeHeight else { return Zatoshi(10_000) }
|
||||
|
||||
return Zatoshi(1_000)
|
||||
static func defaultFee() -> Zatoshi {
|
||||
Zatoshi(10_000)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,8 +178,6 @@ public enum ZcashSDKMainnetConstants: NetworkConstants {
|
|||
public static let defaultCacheDbName = "caches.db"
|
||||
|
||||
public static let defaultDbNamePrefix = "ZcashSdk_mainnet_"
|
||||
|
||||
public static let feeChangeHeight: BlockHeight = 1_077_550
|
||||
}
|
||||
|
||||
public enum ZcashSDKTestnetConstants: NetworkConstants {
|
||||
|
@ -202,7 +194,4 @@ public enum ZcashSDKTestnetConstants: NetworkConstants {
|
|||
public static let defaultFsBlockDbRootName = "fs_cache"
|
||||
|
||||
public static let defaultDbNamePrefix = "ZcashSdk_testnet_"
|
||||
|
||||
/// Estimated height where wallets are supposed to change the fee
|
||||
public static let feeChangeHeight: BlockHeight = 1_028_500
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ public class SDKSynchronizer: Synchronizer {
|
|||
let tBalance = try await self.getTransparentBalance(accountIndex: accountIndex)
|
||||
|
||||
// Verify that at least there are funds for the fee. Ideally this logic will be improved by the shielding wallet.
|
||||
guard tBalance.verified >= self.network.constants.defaultFee(for: await self.latestBlocksDataProvider.maxScannedHeight) else {
|
||||
guard tBalance.verified >= self.network.constants.defaultFee() else {
|
||||
throw ZcashError.synchronizerShieldFundsInsuficientTransparentFunds
|
||||
}
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ class AdvancedReOrgTests: ZcashTestCase {
|
|||
// XCTAssertEqual(pMinedHeight, sentTxHeight)
|
||||
// // fee change on this branch
|
||||
// let expectedBalance = try await synchronizer.getShieldedBalance()
|
||||
// XCTAssertEqual(initialTotalBalance - sendAmount - Zatoshi(1000), expectedBalance)
|
||||
// XCTAssertEqual(initialTotalBalance - sendAmount - Zatoshi(10000), expectedBalance)
|
||||
// afterReOrgExpectation.fulfill()
|
||||
// },
|
||||
// error: self.handleError
|
||||
|
|
|
@ -86,10 +86,10 @@ class BalanceTests: ZcashTestCase {
|
|||
|
||||
let verifiedBalance: Zatoshi = try await coordinator.synchronizer.getShieldedVerifiedBalance()
|
||||
let totalBalance: Zatoshi = try await coordinator.synchronizer.getShieldedBalance()
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee(for: defaultLatestHeight))
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee())
|
||||
XCTAssertEqual(verifiedBalance, totalBalance)
|
||||
|
||||
let maxBalance = verifiedBalance - Zatoshi(1000)
|
||||
let maxBalance = verifiedBalance - Zatoshi(10000)
|
||||
|
||||
// 3 create a transaction for the max amount possible
|
||||
// 4 send the transaction
|
||||
|
@ -238,10 +238,10 @@ class BalanceTests: ZcashTestCase {
|
|||
|
||||
let verifiedBalance: Zatoshi = try await coordinator.synchronizer.getShieldedVerifiedBalance()
|
||||
let totalBalance: Zatoshi = try await coordinator.synchronizer.getShieldedBalance()
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee(for: defaultLatestHeight))
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee())
|
||||
XCTAssertEqual(verifiedBalance, totalBalance)
|
||||
|
||||
let maxBalanceMinusOne = verifiedBalance - Zatoshi(1000)
|
||||
let maxBalanceMinusOne = verifiedBalance - Zatoshi(10000)
|
||||
|
||||
// 3 create a transaction for the max amount possible
|
||||
// 4 send the transaction
|
||||
|
@ -385,10 +385,10 @@ class BalanceTests: ZcashTestCase {
|
|||
|
||||
let verifiedBalance: Zatoshi = try await coordinator.synchronizer.getShieldedVerifiedBalance()
|
||||
let totalBalance: Zatoshi = try await coordinator.synchronizer.getShieldedBalance()
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee(for: defaultLatestHeight))
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee())
|
||||
XCTAssertEqual(verifiedBalance, totalBalance)
|
||||
|
||||
let maxBalanceMinusOne = verifiedBalance - Zatoshi(1000) - Zatoshi(1)
|
||||
let maxBalanceMinusOne = verifiedBalance - Zatoshi(10000) - Zatoshi(1)
|
||||
|
||||
// 3 create a transaction for the max amount possible
|
||||
// 4 send the transaction
|
||||
|
@ -450,10 +450,10 @@ class BalanceTests: ZcashTestCase {
|
|||
|
||||
let verifiedBalance: Zatoshi = try await coordinator.synchronizer.getShieldedVerifiedBalance()
|
||||
let totalBalance: Zatoshi = try await coordinator.synchronizer.getShieldedBalance()
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee(for: defaultLatestHeight))
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee())
|
||||
XCTAssertEqual(verifiedBalance, totalBalance)
|
||||
|
||||
let maxBalanceMinusFee = Zatoshi(100000) - Zatoshi(1000)
|
||||
let maxBalanceMinusFee = Zatoshi(100000) - Zatoshi(10000)
|
||||
|
||||
// 3 create a transaction for the max amount possible
|
||||
// 4 send the transaction
|
||||
|
@ -613,7 +613,7 @@ class BalanceTests: ZcashTestCase {
|
|||
/*
|
||||
there's more zatoshi to send than network fee
|
||||
*/
|
||||
XCTAssertTrue(presendVerifiedBalance >= network.constants.defaultFee(for: defaultLatestHeight) + sendAmount)
|
||||
XCTAssertTrue(presendVerifiedBalance >= network.constants.defaultFee() + sendAmount)
|
||||
|
||||
var pendingTx: ZcashTransaction.Overview?
|
||||
|
||||
|
@ -663,12 +663,12 @@ class BalanceTests: ZcashTestCase {
|
|||
let expectedBalance = try await coordinator.synchronizer.getShieldedBalance()
|
||||
|
||||
XCTAssertEqual(
|
||||
presendVerifiedBalance - self.sendAmount - network.constants.defaultFee(for: defaultLatestHeight),
|
||||
presendVerifiedBalance - self.sendAmount - network.constants.defaultFee(),
|
||||
expectedBalance
|
||||
)
|
||||
|
||||
XCTAssertEqual(
|
||||
presendVerifiedBalance - self.sendAmount - network.constants.defaultFee(for: defaultLatestHeight),
|
||||
presendVerifiedBalance - self.sendAmount - network.constants.defaultFee(),
|
||||
expectedVerifiedBalance
|
||||
)
|
||||
|
||||
|
@ -754,7 +754,7 @@ class BalanceTests: ZcashTestCase {
|
|||
let presendBalance: Zatoshi = try await coordinator.synchronizer.getShieldedBalance()
|
||||
|
||||
// there's more zatoshi to send than network fee
|
||||
XCTAssertTrue(presendBalance >= network.constants.defaultFee(for: defaultLatestHeight) + sendAmount)
|
||||
XCTAssertTrue(presendBalance >= network.constants.defaultFee() + sendAmount)
|
||||
var pendingTx: ZcashTransaction.Overview?
|
||||
|
||||
var testError: Error?
|
||||
|
@ -793,7 +793,7 @@ class BalanceTests: ZcashTestCase {
|
|||
var expectedBalance = try await coordinator.synchronizer.getShieldedBalance()
|
||||
XCTAssertEqual(
|
||||
expectedBalance,
|
||||
presendBalance - self.sendAmount - network.constants.defaultFee(for: defaultLatestHeight)
|
||||
presendBalance - self.sendAmount - network.constants.defaultFee()
|
||||
)
|
||||
|
||||
let latestHeight = try await coordinator.latestHeight()
|
||||
|
@ -824,7 +824,7 @@ class BalanceTests: ZcashTestCase {
|
|||
|
||||
expectedBalance = try await coordinator.synchronizer.getShieldedBalance()
|
||||
XCTAssertEqual(
|
||||
presendBalance - self.sendAmount - network.constants.defaultFee(for: defaultLatestHeight),
|
||||
presendBalance - self.sendAmount - network.constants.defaultFee(),
|
||||
expectedBalance
|
||||
)
|
||||
}
|
||||
|
@ -1003,7 +1003,7 @@ class BalanceTests: ZcashTestCase {
|
|||
There’s a change note of value (previous note value - sent amount)
|
||||
*/
|
||||
XCTAssertEqual(
|
||||
previousVerifiedBalance - self.sendAmount - Zatoshi(1000),
|
||||
previousVerifiedBalance - self.sendAmount - Zatoshi(10000),
|
||||
changeOutput.value
|
||||
)
|
||||
|
||||
|
@ -1188,7 +1188,7 @@ class BalanceTests: ZcashTestCase {
|
|||
previousTotalbalance: Zatoshi,
|
||||
sentAmount: Zatoshi
|
||||
) {
|
||||
XCTAssertEqual(totalBalance, previousTotalbalance - sentAmount - Zatoshi(1000))
|
||||
XCTAssertEqual(totalBalance, previousTotalbalance - sentAmount - Zatoshi(10000))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class RewindRescanTests: ZcashTestCase {
|
|||
let verifiedBalance: Zatoshi = try await coordinator.synchronizer.getShieldedVerifiedBalance()
|
||||
let totalBalance: Zatoshi = try await coordinator.synchronizer.getShieldedBalance()
|
||||
// 2 check that there are no unconfirmed funds
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee(for: defaultLatestHeight))
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee())
|
||||
XCTAssertEqual(verifiedBalance, totalBalance)
|
||||
|
||||
let rewindExpectation = XCTestExpectation(description: "RewindExpectation")
|
||||
|
@ -179,7 +179,7 @@ class RewindRescanTests: ZcashTestCase {
|
|||
let verifiedBalance: Zatoshi = try await coordinator.synchronizer.getShieldedVerifiedBalance()
|
||||
let totalBalance: Zatoshi = try await coordinator.synchronizer.getShieldedBalance()
|
||||
// 2 check that there are no unconfirmed funds
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee(for: defaultLatestHeight))
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee())
|
||||
XCTAssertEqual(verifiedBalance, totalBalance)
|
||||
|
||||
// rewind to birthday
|
||||
|
@ -277,7 +277,7 @@ class RewindRescanTests: ZcashTestCase {
|
|||
let verifiedBalance: Zatoshi = try await coordinator.synchronizer.getShieldedVerifiedBalance()
|
||||
let totalBalance: Zatoshi = try await coordinator.synchronizer.getShieldedBalance()
|
||||
// 2 check that there are no unconfirmed funds
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee(for: defaultLatestHeight))
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee())
|
||||
XCTAssertEqual(verifiedBalance, totalBalance)
|
||||
|
||||
// rewind to transaction
|
||||
|
@ -365,10 +365,10 @@ class RewindRescanTests: ZcashTestCase {
|
|||
|
||||
let verifiedBalance: Zatoshi = try await coordinator.synchronizer.getShieldedVerifiedBalance()
|
||||
let totalBalance: Zatoshi = try await coordinator.synchronizer.getShieldedBalance()
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee(for: defaultLatestHeight))
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee())
|
||||
XCTAssertEqual(verifiedBalance, totalBalance)
|
||||
|
||||
let maxBalance = verifiedBalance - Zatoshi(1000)
|
||||
let maxBalance = verifiedBalance - Zatoshi(10000)
|
||||
|
||||
// 3 create a transaction for the max amount possible
|
||||
// 4 send the transaction
|
||||
|
|
|
@ -81,7 +81,6 @@ class ShieldFundsTests: ZcashTestCase {
|
|||
/// 13. sync up to chain tip
|
||||
/// Now it should verify that the balance has been shielded. The resulting balance should be zero
|
||||
/// transparent funds and `10000 - fee` total shielded funds, zero verified shielded funds.
|
||||
/// Fees at the time of writing the tests are 1000 zatoshi as defined on ZIP-313
|
||||
/// 14. proceed confirm the shielded funds by staging ten more blocks
|
||||
/// 15. sync up to the new chain tip
|
||||
/// verify that the shielded transactions are confirmed
|
||||
|
@ -294,7 +293,6 @@ class ShieldFundsTests: ZcashTestCase {
|
|||
|
||||
// Now it should verify that the balance has been shielded. The resulting balance should be zero
|
||||
// transparent funds and `10000 - fee` total shielded funds, zero verified shielded funds.
|
||||
// Fees at the time of writing the tests are 1000 zatoshi as defined on ZIP-313
|
||||
let postShieldingShieldedBalance = try await coordinator.synchronizer.getTransparentBalance(accountIndex: 0)
|
||||
|
||||
XCTAssertEqual(postShieldingShieldedBalance.total, .zero)
|
||||
|
|
|
@ -279,7 +279,7 @@ final class SynchronizerTests: ZcashTestCase {
|
|||
let verifiedBalance: Zatoshi = try await coordinator.synchronizer.getShieldedVerifiedBalance()
|
||||
let totalBalance: Zatoshi = try await coordinator.synchronizer.getShieldedBalance()
|
||||
// 2 check that there are no unconfirmed funds
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee(for: defaultLatestHeight))
|
||||
XCTAssertTrue(verifiedBalance > network.constants.defaultFee())
|
||||
XCTAssertEqual(verifiedBalance, totalBalance)
|
||||
|
||||
// Add more blocks to the chain so the long sync can start.
|
||||
|
|
|
@ -210,10 +210,6 @@ enum DarksideWalletDConstants: NetworkConstants {
|
|||
static var defaultDbNamePrefix: String {
|
||||
ZcashSDKMainnetConstants.defaultDbNamePrefix
|
||||
}
|
||||
|
||||
static var feeChangeHeight: BlockHeight {
|
||||
ZcashSDKMainnetConstants.feeChangeHeight
|
||||
}
|
||||
}
|
||||
|
||||
class DarksideWalletDNetwork: ZcashNetwork {
|
||||
|
|
|
@ -38,7 +38,7 @@ class TestsData {
|
|||
accountId: 0,
|
||||
blockTime: nil,
|
||||
expiryHeight: nil,
|
||||
fee: Zatoshi(1000),
|
||||
fee: Zatoshi(10000),
|
||||
index: nil,
|
||||
hasChange: true,
|
||||
memoCount: 0,
|
||||
|
|
Loading…
Reference in New Issue