DERO-HE STARGATE Testnet Release43
This commit is contained in:
parent
5be577718b
commit
5ad177d90d
@ -1,6 +1,8 @@
|
||||
package astrobwt
|
||||
|
||||
import "fmt"
|
||||
import "unsafe"
|
||||
import "encoding/binary"
|
||||
import "golang.org/x/crypto/sha3"
|
||||
import "golang.org/x/crypto/salsa20/salsa"
|
||||
|
||||
@ -11,8 +13,6 @@ var x = fmt.Sprintf
|
||||
const stage1_length int = 9973 // it is a prime
|
||||
|
||||
func POW16(inputdata []byte) (outputhash [32]byte) {
|
||||
|
||||
var output [stage1_length]byte
|
||||
var counter [16]byte
|
||||
|
||||
key := sha3.Sum256(inputdata)
|
||||
@ -23,14 +23,18 @@ func POW16(inputdata []byte) (outputhash [32]byte) {
|
||||
var sa [stage1_length]int16
|
||||
text_16_0alloc(stage1[:], sa[:])
|
||||
|
||||
if LittleEndian {
|
||||
var s *[stage1_length * 2]byte = (*[stage1_length * 2]byte)(unsafe.Pointer(&sa))
|
||||
outputhash = sha3.Sum256(s[:])
|
||||
return
|
||||
} else {
|
||||
var s [stage1_length * 2]byte
|
||||
for i := range sa {
|
||||
output[i] = stage1[sa[i]]
|
||||
binary.LittleEndian.PutUint16(s[i<<1:], uint16(sa[i]))
|
||||
}
|
||||
outputhash = sha3.Sum256(s[:])
|
||||
return
|
||||
}
|
||||
|
||||
// fmt.Printf("input %+v\n",inputdata)
|
||||
// fmt.Printf("sa %+v\n",sa)
|
||||
outputhash = sha3.Sum256(output[:])
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -43,7 +47,7 @@ func text_16_0alloc(text []byte, sa []int16) {
|
||||
}
|
||||
|
||||
func POW32(inputdata []byte) (outputhash [32]byte) {
|
||||
var output [stage1_length]byte
|
||||
var sa16 [stage1_length]int16
|
||||
var counter [16]byte
|
||||
key := sha3.Sum256(inputdata)
|
||||
|
||||
@ -51,10 +55,23 @@ func POW32(inputdata []byte) (outputhash [32]byte) {
|
||||
salsa.XORKeyStream(stage1[:stage1_length], stage1[:stage1_length], &counter, &key)
|
||||
var sa [stage1_length]int32
|
||||
text_32_0alloc(stage1[:], sa[:])
|
||||
|
||||
for i := range sa {
|
||||
output[i] = stage1[sa[i]]
|
||||
sa16[i] = int16(sa[i])
|
||||
}
|
||||
|
||||
if LittleEndian {
|
||||
var s *[stage1_length * 2]byte = (*[stage1_length * 2]byte)(unsafe.Pointer(&sa16))
|
||||
outputhash = sha3.Sum256(s[:])
|
||||
return
|
||||
} else {
|
||||
var s [stage1_length * 2]byte
|
||||
for i := range sa {
|
||||
binary.LittleEndian.PutUint16(s[i<<1:], uint16(sa[i]))
|
||||
}
|
||||
outputhash = sha3.Sum256(s[:])
|
||||
return
|
||||
}
|
||||
outputhash = sha3.Sum256(output[:])
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func TestSuffixArrayOptimized(t *testing.T) {
|
||||
|
||||
func TestPows(t *testing.T) {
|
||||
|
||||
for loop_var := 0; loop_var < 100000; loop_var++ {
|
||||
for loop_var := 0; loop_var < 1; loop_var++ {
|
||||
|
||||
seed := time.Now().UnixNano()
|
||||
//seed = 1635948770488138379
|
||||
@ -60,6 +60,7 @@ func TestPows(t *testing.T) {
|
||||
if result16 != result32 {
|
||||
t.Fatalf("pow test failed, seed %d %x %x ", seed, result16, result32)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
9
astrobwt/endian_big.go
Normal file
9
astrobwt/endian_big.go
Normal file
@ -0,0 +1,9 @@
|
||||
//go:build armbe || arm64be || mips || mips64 || ppc64 || s390 || s390x || sparc || sparc64
|
||||
// +build armbe arm64be mips mips64 ppc64 s390 s390x sparc sparc64
|
||||
|
||||
package astrobwt
|
||||
|
||||
const LittleEndian = false
|
||||
const BigEndian = true
|
||||
|
||||
// see https://github.com/golang/go/blob/master/src/go/build/syslist.go
|
9
astrobwt/endian_little.go
Normal file
9
astrobwt/endian_little.go
Normal file
@ -0,0 +1,9 @@
|
||||
//go:build amd64 || amd64p32 || 386 || arm || arm64 || mipsle || mips64le || mips64p32le || ppc64le || riscv || riscv64 || wasm || loong64
|
||||
// +build amd64 amd64p32 386 arm arm64 mipsle mips64le mips64p32le ppc64le riscv riscv64 wasm loong64
|
||||
|
||||
package astrobwt
|
||||
|
||||
const LittleEndian = true
|
||||
const BigEndian = false
|
||||
|
||||
//see https://github.com/golang/go/blob/master/src/go/build/syslist.go
|
@ -1122,7 +1122,7 @@ func (chain *Blockchain) Add_TX_To_Pool(tx *transaction.Transaction) error {
|
||||
if tx.IsRegistration() { // registration tx will not go any forward
|
||||
|
||||
tx_hash := tx.GetHash()
|
||||
if chain.simulator == false && tx_hash[0] != 0 && tx_hash[1] != 0 {
|
||||
if chain.simulator == false && !(tx_hash[0] == 0 && tx_hash[1] == 0 && tx_hash[2] <= 0x3) {
|
||||
return fmt.Errorf("TX doesn't solve Pow")
|
||||
}
|
||||
|
||||
|
35
blockchain/supply_test.go
Normal file
35
blockchain/supply_test.go
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright 2017-2022 DERO Project. All rights reserved.
|
||||
// Use of this source code in any form is governed by RESEARCH license.
|
||||
// license can be found in the LICENSE file.
|
||||
// GPG: 0F39 E425 8C65 3947 702A 8234 08B2 0360 A03A 9DE8
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package blockchain
|
||||
|
||||
import "testing"
|
||||
import "github.com/deroproject/derohe/globals"
|
||||
|
||||
|
||||
func Test_Supply(t *testing.T) {
|
||||
|
||||
supply_at_0 := CalcBlockReward(0)
|
||||
|
||||
for i := uint64(0); i < 10; i++ {
|
||||
supply := CalcBlockReward(i * RewardReductionInterval)
|
||||
t.Logf("Supply at height %d %s", i*RewardReductionInterval, globals.FormatMoney(supply))
|
||||
if supply != supply_at_0>>i {
|
||||
t.Errorf("supply not halvening as needed ")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
@ -124,15 +124,12 @@ func (chain *Blockchain) process_miner_transaction(bl *block.Block, genesis bool
|
||||
base_reward := CalcBlockReward(uint64(height))
|
||||
full_reward := base_reward + fees
|
||||
|
||||
integrator_reward := full_reward * 167 / 10000
|
||||
|
||||
//full_reward is divided into equal parts for all miner blocks
|
||||
// integrator only gets 1.67 % of block reward
|
||||
//full_reward is divided into equal parts for all miner blocks + miner address
|
||||
// since perfect division is not possible, ( see money handling)
|
||||
// any left over change is delivered to main miner who integrated the full block
|
||||
|
||||
share := (full_reward - integrator_reward) / uint64(len(bl.MiniBlocks)) // one block integrator, this is integer division
|
||||
leftover := full_reward - integrator_reward - (share * uint64(len(bl.MiniBlocks))) // only integrator will get this
|
||||
share := full_reward / uint64(len(bl.MiniBlocks)) // one block integrator, this is integer division
|
||||
leftover := full_reward - (share * uint64(len(bl.MiniBlocks))) // only integrator will get this
|
||||
|
||||
{ // giver integrator his reward
|
||||
balance_serialized, err := balance_tree.Get(tx.MinerAddress[:])
|
||||
@ -140,7 +137,7 @@ func (chain *Blockchain) process_miner_transaction(bl *block.Block, genesis bool
|
||||
panic(err)
|
||||
}
|
||||
nb := new(crypto.NonceBalance).Deserialize(balance_serialized)
|
||||
nb.Balance = nb.Balance.Plus(new(big.Int).SetUint64(integrator_reward + leftover)) // add miners reward to miners balance homomorphically
|
||||
nb.Balance = nb.Balance.Plus(new(big.Int).SetUint64(share + leftover)) // add miners reward to miners balance homomorphically
|
||||
balance_tree.Put(tx.MinerAddress[:], nb.Serialize()) // reserialize and store
|
||||
}
|
||||
|
||||
@ -238,6 +235,7 @@ func (chain *Blockchain) process_transaction(changed map[crypto.Hash]*graviton.T
|
||||
nb.NonceHeight = height
|
||||
}
|
||||
tree.Put(key_compressed, nb.Serialize()) // reserialize and store
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ func handle_easymenu_post_open_command(l *readline.Instance, line string) (proce
|
||||
reg_tx = wallet.GetRegistrationTX()
|
||||
hash := reg_tx.GetHash()
|
||||
|
||||
if hash[0] == 0 && hash[1] == 0 {
|
||||
if hash[0] == 0 && hash[1] == 0 && hash[2] <= 0x3 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ type metrics_generator struct{}
|
||||
|
||||
func (metrics_generator) LogRequest(ctx context.Context, req *jrpc2.Request) {}
|
||||
func (metrics_generator) LogResponse(ctx context.Context, resp *jrpc2.Response) {
|
||||
defer globals.Recover(2)
|
||||
req := jrpc2.InboundRequest(ctx) // we cannot do anything here
|
||||
if req == nil {
|
||||
return
|
||||
|
@ -107,7 +107,7 @@ var Mainnet = CHAIN_CONFIG{Name: "mainnet",
|
||||
}
|
||||
|
||||
var Testnet = CHAIN_CONFIG{Name: "testnet", // testnet will always have last 3 bytes 0
|
||||
Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x83, 0x00, 0x00, 0x00}),
|
||||
Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x86, 0x00, 0x00, 0x00}),
|
||||
GETWORK_Default_Port: 10100,
|
||||
P2P_Default_Port: 40401,
|
||||
RPC_Default_Port: 40402,
|
||||
|
@ -20,4 +20,4 @@ import "github.com/blang/semver/v4"
|
||||
|
||||
// right now it has to be manually changed
|
||||
// do we need to include git commitsha??
|
||||
var Version = semver.MustParse("3.4.109-0.DEROHE.STARGATE+18012022")
|
||||
var Version = semver.MustParse("3.4.111-43.DEROHE.STARGATE+18012022")
|
||||
|
Loading…
Reference in New Issue
Block a user