From 874b0656a0e6846ef1e1132f050330b8b525b9cd Mon Sep 17 00:00:00 2001 From: J Fixby Date: Thu, 7 Nov 2019 16:29:47 +0100 Subject: [PATCH] Consensus 2.0 --- blockchain/estimatesubsidy_test.go | 26 +++++++++++++------------- blockchain/subsidy_test.go | 2 +- chaincfg/genesis_test.go | 2 +- chaincfg/pfcnetparams.go | 4 ++-- chaincfg/premine_test.go | 6 +++--- go.mod | 4 ++-- go.sum | 22 ++++------------------ 7 files changed, 26 insertions(+), 40 deletions(-) diff --git a/blockchain/estimatesubsidy_test.go b/blockchain/estimatesubsidy_test.go index 4573664..01fdf59 100644 --- a/blockchain/estimatesubsidy_test.go +++ b/blockchain/estimatesubsidy_test.go @@ -31,19 +31,19 @@ func TestEstimateSupplyPicFightCoin(t *testing.T) { expectedValues := map[int64]int64{ 0: 0, 1: calc.PreminedCoins().AtomsValue, - 2: 400000172962501, - 4: 400000518887391, - 40: 400006745509838, - 400: 400069009068787, - 4000: 400691378106416, - 40000: 406888413296876, - 400000: 466193246619086, - 1200000: 580630465698828, - 2400000: 707412244109675, - 3600000: 780345162270002, - 4000000: 792689721601108, - 4625285: 799999997687360, - calc.NumberOfGeneratingBlocks() + 5: 799999997687360, + 2: 2035109104832, + 4: 2035127314475, + 40: 2035455083102, + 400: 2038732254894, + 4000: 2071452524241, + 40000: 2393510359606, + 400000: 5099602903191, + 1200000: 7764076009766, + 2400000: 7777699369282, + 3600000: 7777699369282, + 4000000: 7777699369282, + 4625285: 7777699369282, + calc.NumberOfGeneratingBlocks() + 5: 7777699369282, } for height, expected := range expectedValues { diff --git a/blockchain/subsidy_test.go b/blockchain/subsidy_test.go index 6564ae1..97bcef7 100644 --- a/blockchain/subsidy_test.go +++ b/blockchain/subsidy_test.go @@ -18,7 +18,7 @@ func TestPicfightCoinBlockSubsidy(t *testing.T) { net := &chaincfg.PicFightCoinNetParams calc := net.SubsidyCalculator() expectedTotal := calc.ExpectedTotalNetworkSubsidy() - expectedActual := coin.Amount{799999997687360} + expectedActual := coin.Amount{7777699369282} expectedTotal = expectedActual genBlocksNum := calc.NumberOfGeneratingBlocks() preminedCoins := calc.PreminedCoins() diff --git a/chaincfg/genesis_test.go b/chaincfg/genesis_test.go index 7a4734b..65940b4 100644 --- a/chaincfg/genesis_test.go +++ b/chaincfg/genesis_test.go @@ -17,7 +17,7 @@ import ( // TestPicfightGenesisBlock tests the genesis block of the main network for validity by // checking the encoded bytes and hashes. func TestPicfightGenesisBlock(t *testing.T) { - genesisHexString := "0100000000000000000000000000000000000000000000000000000000000000000000000dc101dfc3c6a2eb10ca0c5374e10d28feb53f7eabcc850511ceadb99174aa66000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffff001f00c2eb0b000000000000000000000000c13c935d000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff00ffffffff010000000000000000000020801679e98561ada96caec2949a5d41c4cab3851eb740d951c10ecbcf265c1fd9000000000000000001ffffffffffffffff00000000ffffffff02000000" + genesisHexString := "0100000000000000000000000000000000000000000000000000000000000000000000000dc101dfc3c6a2eb10ca0c5374e10d28feb53f7eabcc850511ceadb99174aa66000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffff001f00c2eb0b000000000000000000000000e820c45d000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff00ffffffff010000000000000000000020801679e98561ada96caec2949a5d41c4cab3851eb740d951c10ecbcf265c1fd9000000000000000001ffffffffffffffff00000000ffffffff02000000" genesisBlockBytes, _ := hex.DecodeString(genesisHexString) // Encode the genesis block to raw bytes. diff --git a/chaincfg/pfcnetparams.go b/chaincfg/pfcnetparams.go index 70f8927..e624b91 100644 --- a/chaincfg/pfcnetparams.go +++ b/chaincfg/pfcnetparams.go @@ -88,8 +88,8 @@ var PicFightCoinNetParams = Params{ SLIP0044CoinType: 42, // SLIP0044, Decred LegacyCoinType: 20, // for backwards compatibility - // Decred PoS parameters - MinimumStakeDiff: 2 * 1e8, // 2 Coin + // PoS parameters + MinimumStakeDiff: picfightcoin.MinStakeDifficulty(), TicketPoolSize: 8192, TicketsPerBlock: picfightcoin.PicFightCoinSubsidy().TicketsPerBlock(), TicketMaturity: 256, diff --git a/chaincfg/premine_test.go b/chaincfg/premine_test.go index 54fc4c0..d336c66 100644 --- a/chaincfg/premine_test.go +++ b/chaincfg/premine_test.go @@ -10,7 +10,7 @@ import ( func TestLockPremine(t *testing.T) { { // LOCK PROJECT SUBSIDY projectPremine := picfightcoin.Premine()["JsKFRL5ivSH7CnYaTtaBT4M9fZG878g49Fg"] - expected := coin.FromFloat(4000000 - 6000) + expected := coin.FromFloat(20291) if projectPremine.AtomsValue != expected.AtomsValue { t.Errorf("Premine mismatch: got %v expected %v ", projectPremine, @@ -21,7 +21,7 @@ func TestLockPremine(t *testing.T) { } { // LOCK PROJECT POS SUBSIDY projectPosPremine := picfightcoin.Premine()["JsRjbYZ448FxZQ5kQAc15NcwUQ1oqYydVEG"] - expected := coin.FromFloat(6000) + expected := coin.FromFloat(60) if projectPosPremine.AtomsValue != expected.AtomsValue { t.Errorf("Premine mismatch: got %v expected %v ", projectPosPremine, @@ -51,7 +51,7 @@ func TestPremine(t *testing.T) { ) t.Fail() } - expected = coin.FromFloat(4000000).AtomsValue + expected = coin.FromFloat(20351).AtomsValue if totalAtoms != expected { t.Errorf("Premine mismatch: got %v expected %v ", totalAtoms, diff --git a/go.mod b/go.mod index 4836ae1..0259577 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,6 @@ require ( github.com/jfixby/pin v0.0.0-20190926185208-4828e1e664f4 github.com/jrick/bitset v1.0.0 github.com/jrick/logrotate v1.0.0 - github.com/picfight/picfightcoin v0.0.0-20191002184602-b5e70e4070ea - golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad + github.com/picfight/picfightcoin v0.0.0-20191107151210-0ab5c80ba5bc + golang.org/x/crypto v0.0.0-20191106202628-ed6320f186d4 ) diff --git a/go.sum b/go.sum index ff5c295..af306ef 100644 --- a/go.sum +++ b/go.sum @@ -28,25 +28,11 @@ github.com/jrick/bitset v1.0.0/go.mod h1:ZOYB5Uvkla7wIEY4FEssPVi3IQXa02arznRaYaA github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/picfight/picfightcoin v0.0.0-20190930150635-03da47866cbd h1:GVdVk8msxZ5RKxcEOBii9Vy/fj1Mlsr4LYJ4giEF7Ik= -github.com/picfight/picfightcoin v0.0.0-20190930150635-03da47866cbd/go.mod h1:ha+rYP3z5+4VMMFtxAen2S0YKzVQeR5+B/gLkwAjx18= -github.com/picfight/picfightcoin v0.0.0-20190930184150-707a9cdf5bf8 h1:7BpJahM9PU0iGbAqRjzoOvdYAamF5hJWstD7nHrhnOQ= -github.com/picfight/picfightcoin v0.0.0-20190930184150-707a9cdf5bf8/go.mod h1:ha+rYP3z5+4VMMFtxAen2S0YKzVQeR5+B/gLkwAjx18= -github.com/picfight/picfightcoin v0.0.0-20190930210555-0c9b14074eac h1:2xODeCNcLFr0axG+EGMVNWMMlPOM54FAizVYNAWeRT8= -github.com/picfight/picfightcoin v0.0.0-20190930210555-0c9b14074eac/go.mod h1:ha+rYP3z5+4VMMFtxAen2S0YKzVQeR5+B/gLkwAjx18= -github.com/picfight/picfightcoin v0.0.0-20191001114557-5face52e5bde h1:GXO8kJfntYJNO7pKlmA6/NzGJgQ/K1eK7bs2jzdGW7g= -github.com/picfight/picfightcoin v0.0.0-20191001114557-5face52e5bde/go.mod h1:ha+rYP3z5+4VMMFtxAen2S0YKzVQeR5+B/gLkwAjx18= -github.com/picfight/picfightcoin v0.0.0-20191001115746-c680a917d1fe h1:q+o3HxSv/u67nKRb5Q1b/egqxJgY9Ck0nZp00AJvzmg= -github.com/picfight/picfightcoin v0.0.0-20191001115746-c680a917d1fe/go.mod h1:ha+rYP3z5+4VMMFtxAen2S0YKzVQeR5+B/gLkwAjx18= -github.com/picfight/picfightcoin v0.0.0-20191001123624-84c8bd500392 h1:VRLJNVZVXZdcK/gzwADaYxQG13JCGvwUZEjJ7k1RQns= -github.com/picfight/picfightcoin v0.0.0-20191001123624-84c8bd500392/go.mod h1:ha+rYP3z5+4VMMFtxAen2S0YKzVQeR5+B/gLkwAjx18= -github.com/picfight/picfightcoin v0.0.0-20191002123151-f8c564eeaeaa h1:jfluI547/yk4sa5DaRY3wL2lxHyFeGz8rIUE4qQHuZQ= -github.com/picfight/picfightcoin v0.0.0-20191002123151-f8c564eeaeaa/go.mod h1:ha+rYP3z5+4VMMFtxAen2S0YKzVQeR5+B/gLkwAjx18= -github.com/picfight/picfightcoin v0.0.0-20191002184602-b5e70e4070ea h1:rPCedxD0FT6mjcEPwvrAzP3LBbKNJaNJMWcmubDvXkg= -github.com/picfight/picfightcoin v0.0.0-20191002184602-b5e70e4070ea/go.mod h1:ha+rYP3z5+4VMMFtxAen2S0YKzVQeR5+B/gLkwAjx18= +github.com/picfight/picfightcoin v0.0.0-20191107151210-0ab5c80ba5bc h1:40Fh7v29VEayd3PmWBQqqiDB0r2oXHjC3DpNkeIr49U= +github.com/picfight/picfightcoin v0.0.0-20191107151210-0ab5c80ba5bc/go.mod h1:ha+rYP3z5+4VMMFtxAen2S0YKzVQeR5+B/gLkwAjx18= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad h1:5E5raQxcv+6CZ11RrBYQe5WRbUIWpScjh0kvHZkZIrQ= -golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191106202628-ed6320f186d4 h1:PDpCLFAH/YIX0QpHPf2eO7L4rC2OOirBrKtXTLLiNTY= +golang.org/x/crypto v0.0.0-20191106202628-ed6320f186d4/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=