DERO HE Stargate Release 20
This commit is contained in:
parent
76173abe4f
commit
90e1c89e12
@ -46,7 +46,7 @@ func (b *cbl_verify) check(tx *transaction.Transaction, insert_for_future bool)
|
|||||||
b.data[p.SCID] = map[[33]byte]uint64{}
|
b.data[p.SCID] = map[[33]byte]uint64{}
|
||||||
}
|
}
|
||||||
if p.Statement.RingSize != uint64(len(p.Statement.Publickeylist_compressed)) {
|
if p.Statement.RingSize != uint64(len(p.Statement.Publickeylist_compressed)) {
|
||||||
return fmt.Errorf("TX is not expanded. cannot cbl_verify")
|
return fmt.Errorf("TX is not expanded. cannot cbl_verify expected %d Actual %d", p.Statement.RingSize, len(p.Statement.Publickeylist_compressed))
|
||||||
}
|
}
|
||||||
|
|
||||||
for j, pkc := range p.Statement.Publickeylist_compressed {
|
for j, pkc := range p.Statement.Publickeylist_compressed {
|
||||||
|
@ -484,8 +484,15 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro
|
|||||||
if len(tx_checklist) != len(bl.Tx_hashes) { // block has duplicate tx, reject
|
if len(tx_checklist) != len(bl.Tx_hashes) { // block has duplicate tx, reject
|
||||||
block_logger.Error(fmt.Errorf("duplicate TX"), "Incomplete block", "duplicate count", len(bl.Tx_hashes)-len(tx_checklist))
|
block_logger.Error(fmt.Errorf("duplicate TX"), "Incomplete block", "duplicate count", len(bl.Tx_hashes)-len(tx_checklist))
|
||||||
return errormsg.ErrInvalidBlock, false
|
return errormsg.ErrInvalidBlock, false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i, tx := range cbl.Txs {
|
||||||
|
if tx.Height >= bl.Height {
|
||||||
|
block_logger.Error(fmt.Errorf("Invalid TX Height"), "TX height cannot be more than block", "txid", cbl.Txs[i].GetHash().String())
|
||||||
|
return errormsg.ErrInvalidBlock, false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// now lets loop through complete block, matching each tx
|
// now lets loop through complete block, matching each tx
|
||||||
// detecting any duplicates using txid hash
|
// detecting any duplicates using txid hash
|
||||||
for i := 0; i < len(cbl.Txs); i++ {
|
for i := 0; i < len(cbl.Txs); i++ {
|
||||||
@ -586,6 +593,20 @@ func (chain *Blockchain) Add_Complete_Block(cbl *block.Complete_Block) (err erro
|
|||||||
var check_data cbl_verify // used to verify sanity of new block
|
var check_data cbl_verify // used to verify sanity of new block
|
||||||
for i := 0; i < len(cbl.Txs); i++ {
|
for i := 0; i < len(cbl.Txs); i++ {
|
||||||
if !(cbl.Txs[i].IsCoinbase() || cbl.Txs[i].IsRegistration()) { // all other tx must go through this check
|
if !(cbl.Txs[i].IsCoinbase() || cbl.Txs[i].IsRegistration()) { // all other tx must go through this check
|
||||||
|
|
||||||
|
for _, p := range cbl.Txs[i].Payloads { // make sure tx is expanded
|
||||||
|
if p.Statement.RingSize != uint64(len(p.Statement.Publickeylist_compressed)) {
|
||||||
|
if err = chain.Transaction_NonCoinbase_Expand(cbl.Txs[i]); err != nil {
|
||||||
|
return err, false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if still the tx is not expanded, give err
|
||||||
|
if p.Statement.RingSize != uint64(len(p.Statement.Publickeylist_compressed)) {
|
||||||
|
err = fmt.Errorf("TXB is not expanded. cannot cbl_verify expected %d Actual %d", p.Statement.RingSize, len(p.Statement.Publickeylist_compressed))
|
||||||
|
block_logger.Error(err, "Invalid TX within block", "txid", cbl.Txs[i].GetHash())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
if err = check_data.check(cbl.Txs[i], false); err == nil {
|
if err = check_data.check(cbl.Txs[i], false); err == nil {
|
||||||
check_data.check(cbl.Txs[i], true) // keep in record for future tx
|
check_data.check(cbl.Txs[i], true) // keep in record for future tx
|
||||||
} else {
|
} else {
|
||||||
|
@ -217,6 +217,7 @@ func (chain *Blockchain) Create_new_miner_block(miner_address rpc.Address) (cbl
|
|||||||
// first of lets find the tx fees collected by consuming txs from mempool
|
// first of lets find the tx fees collected by consuming txs from mempool
|
||||||
tx_hash_list_sorted := chain.Mempool.Mempool_List_TX_SortedInfo() // hash of all tx expected to be included within this block , sorted by fees
|
tx_hash_list_sorted := chain.Mempool.Mempool_List_TX_SortedInfo() // hash of all tx expected to be included within this block , sorted by fees
|
||||||
|
|
||||||
|
logger.V(8).Info("mempool returned tx list", "tx_list", tx_hash_list_sorted)
|
||||||
var pre_check cbl_verify // used to verify sanity of new block
|
var pre_check cbl_verify // used to verify sanity of new block
|
||||||
|
|
||||||
i := 0
|
i := 0
|
||||||
@ -238,10 +239,21 @@ func (chain *Blockchain) Create_new_miner_block(miner_address rpc.Address) (cbl
|
|||||||
sizeoftxs += tx_hash_list_sorted[i].Size
|
sizeoftxs += tx_hash_list_sorted[i].Size
|
||||||
cbl.Txs = append(cbl.Txs, tx)
|
cbl.Txs = append(cbl.Txs, tx)
|
||||||
tx_hash_list_included = append(tx_hash_list_included, tx_hash_list_sorted[i].Hash)
|
tx_hash_list_included = append(tx_hash_list_included, tx_hash_list_sorted[i].Hash)
|
||||||
|
logger.V(8).Info("tx selecting for mining ", "txlist", tx_hash_list_sorted[i].Hash)
|
||||||
|
} else {
|
||||||
|
logger.V(8).Info("not selecting tx due to pre_check failure", "txid", tx_hash_list_sorted[i].Hash)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.V(8).Info("not selecting tx due to nonce failure", "txid", tx_hash_list_sorted[i].Hash)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.V(8).Info("not selecting tx due to height difference", "txid", tx_hash_list_sorted[i].Hash)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.V(8).Info("not selecting tx due to height", "txid", tx_hash_list_sorted[i].Hash)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.V(8).Info("not selecting tx since tx is nil", "txid", tx_hash_list_sorted[i].Hash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// any left over transactions, should be randomly selected
|
// any left over transactions, should be randomly selected
|
||||||
|
@ -413,12 +413,12 @@ func (chain *Blockchain) Verify_Transaction_NonCoinbase(hf_version int64, tx *tr
|
|||||||
return fmt.Errorf("mentioned balance tree not found, cannot verify TX")
|
return fmt.Errorf("mentioned balance tree not found, cannot verify TX")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := transaction_valid_cache.Load(tx_hash); ok {
|
/*if _, ok := transaction_valid_cache.Load(tx_hash); ok {
|
||||||
logger.V(1).Info("Found in cache, skipping verification", "txid", tx_hash)
|
logger.V(1).Info("Found in cache, skipping verification", "txid", tx_hash)
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
//logger.Infof("TX not found in cache %s len %d ",tx_hash, len(tmp_buffer))
|
//logger.Infof("TX not found in cache %s len %d ",tx_hash, len(tmp_buffer))
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//logger.Infof("dTX state tree has been found")
|
//logger.Infof("dTX state tree has been found")
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ func GetSC(ctx context.Context, p rpc.GetSC_Params) (result rpc.GetSC_Result, er
|
|||||||
|
|
||||||
defer func() { // safety so if anything wrong happens, we return error
|
defer func() { // safety so if anything wrong happens, we return error
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
err = fmt.Errorf("panic occured. stack trace %s", debug.Stack())
|
err = fmt.Errorf("panic occured. stack trace r %s %s", r, debug.Stack())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -101,29 +101,35 @@ func GetSC(ctx context.Context, p rpc.GetSC_Params) (result rpc.GetSC_Result, er
|
|||||||
for k, v, err = cursor.First(); err == nil; k, v, err = cursor.Next() {
|
for k, v, err = cursor.First(); err == nil; k, v, err = cursor.Next() {
|
||||||
var vark, varv dvm.Variable
|
var vark, varv dvm.Variable
|
||||||
|
|
||||||
if nil == vark.UnmarshalBinary(k) && nil == varv.UnmarshalBinary(v) {
|
_ = vark
|
||||||
switch vark.Type {
|
_ = varv
|
||||||
case dvm.Uint64:
|
_ = k
|
||||||
if varv.Type == dvm.Uint64 {
|
_ = v
|
||||||
result.VariableUint64Keys[vark.ValueUint64] = varv.ValueUint64
|
/*
|
||||||
} else {
|
fmt.Printf("key '%x' value '%x'\n", k,v)
|
||||||
result.VariableUint64Keys[vark.ValueUint64] = fmt.Sprintf("%x", []byte(varv.ValueString))
|
if len(k) == 32 && len(v) == 8 { // it's SC balance
|
||||||
|
result.Balances[fmt.Sprintf("%x", k)] = binary.BigEndian.Uint64(v)
|
||||||
|
} else if nil == vark.UnmarshalBinary(k) && nil == varv.UnmarshalBinary(v) {
|
||||||
|
switch vark.Type {
|
||||||
|
case dvm.Uint64:
|
||||||
|
if varv.Type == dvm.Uint64 {
|
||||||
|
result.VariableUint64Keys[vark.ValueUint64] = varv.ValueUint64
|
||||||
|
} else {
|
||||||
|
result.VariableUint64Keys[vark.ValueUint64] = fmt.Sprintf("%x", []byte(varv.ValueString))
|
||||||
|
}
|
||||||
|
|
||||||
|
case dvm.String:
|
||||||
|
if varv.Type == dvm.Uint64 {
|
||||||
|
result.VariableStringKeys[vark.ValueString] = varv.ValueUint64
|
||||||
|
} else {
|
||||||
|
result.VariableStringKeys[vark.ValueString] = fmt.Sprintf("%x", []byte(varv.ValueString))
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("UNKNOWN Data type")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case dvm.String:
|
} */
|
||||||
if varv.Type == dvm.Uint64 {
|
|
||||||
result.VariableStringKeys[vark.ValueString] = varv.ValueUint64
|
|
||||||
} else {
|
|
||||||
result.VariableStringKeys[vark.ValueString] = fmt.Sprintf("%x", []byte(varv.ValueString))
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("UNKNOWN Data type")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if len(k) == 32 && len(v) == 8 { // it's SC balance
|
|
||||||
result.Balances[fmt.Sprintf("%x", k)] = binary.BigEndian.Uint64(v)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,7 +588,7 @@ func load_tx_from_rpc(info *txinfo, txhash string) (err error) {
|
|||||||
var r rpc.GetSC_Result
|
var r rpc.GetSC_Result
|
||||||
|
|
||||||
if err = rpc_client.Call("DERO.GetSC", p, &r); err != nil {
|
if err = rpc_client.Call("DERO.GetSC", p, &r); err != nil {
|
||||||
return fmt.Errorf("gettransa rpc failed err %s", err)
|
logger.V(1).Error(err, "DERO.GetSC failed")
|
||||||
} else {
|
} else {
|
||||||
info.SC_State = r
|
info.SC_State = r
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ var Mainnet = CHAIN_CONFIG{Name: "mainnet",
|
|||||||
}
|
}
|
||||||
|
|
||||||
var Testnet = CHAIN_CONFIG{Name: "testnet", // testnet will always have last 3 bytes 0
|
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, 0x44, 0x00, 0x00, 0x00}),
|
Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x45, 0x00, 0x00, 0x00}),
|
||||||
P2P_Default_Port: 40401,
|
P2P_Default_Port: 40401,
|
||||||
RPC_Default_Port: 40402,
|
RPC_Default_Port: 40402,
|
||||||
Wallet_RPC_Default_Port: 40403,
|
Wallet_RPC_Default_Port: 40403,
|
||||||
|
@ -20,4 +20,4 @@ import "github.com/blang/semver/v4"
|
|||||||
|
|
||||||
// right now it has to be manually changed
|
// right now it has to be manually changed
|
||||||
// do we need to include git commitsha??
|
// do we need to include git commitsha??
|
||||||
var Version = semver.MustParse("3.4.49-1.DEROHE.STARGATE+09112021")
|
var Version = semver.MustParse("3.4.54-1.DEROHE.STARGATE+09112021")
|
||||||
|
@ -211,10 +211,12 @@ func Initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// used to recover in case of panics
|
// used to recover in case of panics
|
||||||
func Recover(level int) {
|
func Recover(level int) (err error) {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
|
err = fmt.Errorf("Recovered r:%+v stack %s", r, fmt.Sprintf("%s", string(debug.Stack())))
|
||||||
Logger.V(level).Error(nil, "Recovered ", "error", r, "stack", fmt.Sprintf("%s", string(debug.Stack())))
|
Logger.V(level).Error(nil, "Recovered ", "error", r, "stack", fmt.Sprintf("%s", string(debug.Stack())))
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// tells whether we are in mainnet mode
|
// tells whether we are in mainnet mode
|
||||||
|
@ -97,9 +97,10 @@ try_again:
|
|||||||
goto try_again
|
goto try_again
|
||||||
|
|
||||||
} else if chain.Get_Height()-response.Common.Height != 0 && chain.Get_Height()-response.Start_height <= config.STABLE_LIMIT {
|
} else if chain.Get_Height()-response.Common.Height != 0 && chain.Get_Height()-response.Start_height <= config.STABLE_LIMIT {
|
||||||
pop_count := chain.Load_TOPO_HEIGHT() - response.Start_topoheight
|
//pop_count := chain.Load_TOPO_HEIGHT() - response.Start_topoheight
|
||||||
chain.Rewind_Chain(int(pop_count)) // pop as many blocks as necessary, assumming peer has given us good chain
|
//chain.Rewind_Chain(int(pop_count)) // pop as many blocks as necessary, assumming peer has given us good chain
|
||||||
} else { // we must somehow notify that deviation is way too much and manual interaction is necessary, so as any bug for chain deviationmay be detected
|
} else if chain.Get_Height()-response.Start_height > config.STABLE_LIMIT { // we must somehow notify that deviation is way too much and manual interaction is necessary, so as any bug for chain deviationmay be detected
|
||||||
|
connection.logger.V(1).Error(nil, "we have or others have deviated too much.you may have to use --sync-node option", "our topoheight", chain.Load_TOPO_HEIGHT(), "peer topoheight start", response.Start_topoheight)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ try_again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// request alt-tips ( blocks if we are nearing the main tip )
|
// request alt-tips ( blocks if we are nearing the main tip )
|
||||||
if (response.Common.TopoHeight - chain.Load_TOPO_HEIGHT()) <= 5 {
|
/*if (response.Common.TopoHeight - chain.Load_TOPO_HEIGHT()) <= 5 {
|
||||||
for i := range response.TopBlocks {
|
for i := range response.TopBlocks {
|
||||||
if chain.Load_Block_Topological_order(response.TopBlocks[i]) == -1 {
|
if chain.Load_Block_Topological_order(response.TopBlocks[i]) == -1 {
|
||||||
//connection.Send_ObjectRequest([]crypto.Hash{response.TopBlocks[i]}, []crypto.Hash{})
|
//connection.Send_ObjectRequest([]crypto.Hash{response.TopBlocks[i]}, []crypto.Hash{})
|
||||||
@ -147,7 +148,7 @@ try_again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user