Skip to content

Commit 5ad177d

Browse files
committed
DERO-HE STARGATE Testnet Release43
1 parent 5be5777 commit 5ad177d

File tree

11 files changed

+95
-25
lines changed

11 files changed

+95
-25
lines changed

astrobwt/astrobwt.go

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package astrobwt
22

33
import "fmt"
4+
import "unsafe"
5+
import "encoding/binary"
46
import "golang.org/x/crypto/sha3"
57
import "golang.org/x/crypto/salsa20/salsa"
68

@@ -11,8 +13,6 @@ var x = fmt.Sprintf
1113
const stage1_length int = 9973 // it is a prime
1214

1315
func POW16(inputdata []byte) (outputhash [32]byte) {
14-
15-
var output [stage1_length]byte
1616
var counter [16]byte
1717

1818
key := sha3.Sum256(inputdata)
@@ -23,14 +23,18 @@ func POW16(inputdata []byte) (outputhash [32]byte) {
2323
var sa [stage1_length]int16
2424
text_16_0alloc(stage1[:], sa[:])
2525

26-
for i := range sa {
27-
output[i] = stage1[sa[i]]
26+
if LittleEndian {
27+
var s *[stage1_length * 2]byte = (*[stage1_length * 2]byte)(unsafe.Pointer(&sa))
28+
outputhash = sha3.Sum256(s[:])
29+
return
30+
} else {
31+
var s [stage1_length * 2]byte
32+
for i := range sa {
33+
binary.LittleEndian.PutUint16(s[i<<1:], uint16(sa[i]))
34+
}
35+
outputhash = sha3.Sum256(s[:])
36+
return
2837
}
29-
30-
// fmt.Printf("input %+v\n",inputdata)
31-
// fmt.Printf("sa %+v\n",sa)
32-
outputhash = sha3.Sum256(output[:])
33-
3438
return
3539
}
3640

@@ -43,18 +47,31 @@ func text_16_0alloc(text []byte, sa []int16) {
4347
}
4448

4549
func POW32(inputdata []byte) (outputhash [32]byte) {
46-
var output [stage1_length]byte
50+
var sa16 [stage1_length]int16
4751
var counter [16]byte
4852
key := sha3.Sum256(inputdata)
4953

5054
var stage1 [stage1_length]byte // stages are taken from it
5155
salsa.XORKeyStream(stage1[:stage1_length], stage1[:stage1_length], &counter, &key)
5256
var sa [stage1_length]int32
5357
text_32_0alloc(stage1[:], sa[:])
58+
5459
for i := range sa {
55-
output[i] = stage1[sa[i]]
60+
sa16[i] = int16(sa[i])
61+
}
62+
63+
if LittleEndian {
64+
var s *[stage1_length * 2]byte = (*[stage1_length * 2]byte)(unsafe.Pointer(&sa16))
65+
outputhash = sha3.Sum256(s[:])
66+
return
67+
} else {
68+
var s [stage1_length * 2]byte
69+
for i := range sa {
70+
binary.LittleEndian.PutUint16(s[i<<1:], uint16(sa[i]))
71+
}
72+
outputhash = sha3.Sum256(s[:])
73+
return
5674
}
57-
outputhash = sha3.Sum256(output[:])
5875

5976
return
6077
}

astrobwt/astrobwt_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestSuffixArrayOptimized(t *testing.T) {
4343

4444
func TestPows(t *testing.T) {
4545

46-
for loop_var := 0; loop_var < 100000; loop_var++ {
46+
for loop_var := 0; loop_var < 1; loop_var++ {
4747

4848
seed := time.Now().UnixNano()
4949
//seed = 1635948770488138379
@@ -60,6 +60,7 @@ func TestPows(t *testing.T) {
6060
if result16 != result32 {
6161
t.Fatalf("pow test failed, seed %d %x %x ", seed, result16, result32)
6262
}
63+
6364
}
6465
}
6566

astrobwt/endian_big.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build armbe || arm64be || mips || mips64 || ppc64 || s390 || s390x || sparc || sparc64
2+
// +build armbe arm64be mips mips64 ppc64 s390 s390x sparc sparc64
3+
4+
package astrobwt
5+
6+
const LittleEndian = false
7+
const BigEndian = true
8+
9+
// see https://github.com/golang/go/blob/master/src/go/build/syslist.go

astrobwt/endian_little.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build amd64 || amd64p32 || 386 || arm || arm64 || mipsle || mips64le || mips64p32le || ppc64le || riscv || riscv64 || wasm || loong64
2+
// +build amd64 amd64p32 386 arm arm64 mipsle mips64le mips64p32le ppc64le riscv riscv64 wasm loong64
3+
4+
package astrobwt
5+
6+
const LittleEndian = true
7+
const BigEndian = false
8+
9+
//see https://github.com/golang/go/blob/master/src/go/build/syslist.go

blockchain/blockchain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ func (chain *Blockchain) Add_TX_To_Pool(tx *transaction.Transaction) error {
11221122
if tx.IsRegistration() { // registration tx will not go any forward
11231123

11241124
tx_hash := tx.GetHash()
1125-
if chain.simulator == false && tx_hash[0] != 0 && tx_hash[1] != 0 {
1125+
if chain.simulator == false && !(tx_hash[0] == 0 && tx_hash[1] == 0 && tx_hash[2] <= 0x3) {
11261126
return fmt.Errorf("TX doesn't solve Pow")
11271127
}
11281128

blockchain/supply_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2017-2022 DERO Project. All rights reserved.
2+
// Use of this source code in any form is governed by RESEARCH license.
3+
// license can be found in the LICENSE file.
4+
// GPG: 0F39 E425 8C65 3947 702A 8234 08B2 0360 A03A 9DE8
5+
//
6+
//
7+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
8+
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9+
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
10+
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
11+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
12+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
13+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
14+
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
15+
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16+
17+
package blockchain
18+
19+
import "testing"
20+
import "github.com/deroproject/derohe/globals"
21+
22+
23+
func Test_Supply(t *testing.T) {
24+
25+
supply_at_0 := CalcBlockReward(0)
26+
27+
for i := uint64(0); i < 10; i++ {
28+
supply := CalcBlockReward(i * RewardReductionInterval)
29+
t.Logf("Supply at height %d %s", i*RewardReductionInterval, globals.FormatMoney(supply))
30+
if supply != supply_at_0>>i {
31+
t.Errorf("supply not halvening as needed ")
32+
return
33+
}
34+
}
35+
}

blockchain/transaction_execute.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,21 @@ func (chain *Blockchain) process_miner_transaction(bl *block.Block, genesis bool
124124
base_reward := CalcBlockReward(uint64(height))
125125
full_reward := base_reward + fees
126126

127-
integrator_reward := full_reward * 167 / 10000
128-
129-
//full_reward is divided into equal parts for all miner blocks
130-
// integrator only gets 1.67 % of block reward
127+
//full_reward is divided into equal parts for all miner blocks + miner address
131128
// since perfect division is not possible, ( see money handling)
132129
// any left over change is delivered to main miner who integrated the full block
133130

134-
share := (full_reward - integrator_reward) / uint64(len(bl.MiniBlocks)) // one block integrator, this is integer division
135-
leftover := full_reward - integrator_reward - (share * uint64(len(bl.MiniBlocks))) // only integrator will get this
131+
share := full_reward / uint64(len(bl.MiniBlocks)) // one block integrator, this is integer division
132+
leftover := full_reward - (share * uint64(len(bl.MiniBlocks))) // only integrator will get this
136133

137134
{ // giver integrator his reward
138135
balance_serialized, err := balance_tree.Get(tx.MinerAddress[:])
139136
if err != nil {
140137
panic(err)
141138
}
142139
nb := new(crypto.NonceBalance).Deserialize(balance_serialized)
143-
nb.Balance = nb.Balance.Plus(new(big.Int).SetUint64(integrator_reward + leftover)) // add miners reward to miners balance homomorphically
144-
balance_tree.Put(tx.MinerAddress[:], nb.Serialize()) // reserialize and store
140+
nb.Balance = nb.Balance.Plus(new(big.Int).SetUint64(share + leftover)) // add miners reward to miners balance homomorphically
141+
balance_tree.Put(tx.MinerAddress[:], nb.Serialize()) // reserialize and store
145142
}
146143

147144
// all the other miniblocks will get their share
@@ -238,6 +235,7 @@ func (chain *Blockchain) process_transaction(changed map[crypto.Hash]*graviton.T
238235
nb.NonceHeight = height
239236
}
240237
tree.Put(key_compressed, nb.Serialize()) // reserialize and store
238+
241239
}
242240
}
243241

cmd/dero-wallet-cli/easymenu_post_open.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func handle_easymenu_post_open_command(l *readline.Instance, line string) (proce
139139
reg_tx = wallet.GetRegistrationTX()
140140
hash := reg_tx.GetHash()
141141

142-
if hash[0] == 0 && hash[1] == 0 {
142+
if hash[0] == 0 && hash[1] == 0 && hash[2] <= 0x3 {
143143
break
144144
}
145145
}

cmd/derod/rpc/websocket_server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ type metrics_generator struct{}
7373

7474
func (metrics_generator) LogRequest(ctx context.Context, req *jrpc2.Request) {}
7575
func (metrics_generator) LogResponse(ctx context.Context, resp *jrpc2.Response) {
76+
defer globals.Recover(2)
7677
req := jrpc2.InboundRequest(ctx) // we cannot do anything here
7778
if req == nil {
7879
return

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ var Mainnet = CHAIN_CONFIG{Name: "mainnet",
107107
}
108108

109109
var Testnet = CHAIN_CONFIG{Name: "testnet", // testnet will always have last 3 bytes 0
110-
Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x83, 0x00, 0x00, 0x00}),
110+
Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x86, 0x00, 0x00, 0x00}),
111111
GETWORK_Default_Port: 10100,
112112
P2P_Default_Port: 40401,
113113
RPC_Default_Port: 40402,

config/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ import "github.com/blang/semver/v4"
2020

2121
// right now it has to be manually changed
2222
// do we need to include git commitsha??
23-
var Version = semver.MustParse("3.4.109-0.DEROHE.STARGATE+18012022")
23+
var Version = semver.MustParse("3.4.111-43.DEROHE.STARGATE+18012022")

0 commit comments

Comments
 (0)