Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions XDCx/XDCx.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,17 +588,16 @@ func (XDCX *XDCX) GetEmptyTradingState() (*tradingstate.TradingStateDB, error) {
func (XDCx *XDCX) GetStateCache() tradingstate.Database {
return XDCx.StateCache
}

func (XDCx *XDCX) HasTradingState(block *types.Block, author common.Address) bool {
root, err := XDCx.GetTradingStateRoot(block, author)
if err != nil {
return false
}
_, err = XDCx.StateCache.OpenTrie(root)
if err != nil {
return false
}
return true
return err == nil
}

func (XDCx *XDCX) GetTriegc() *prque.Prque {
return XDCx.Triegc
}
Expand Down
5 changes: 1 addition & 4 deletions XDCx/tradingstate/relayer_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ func IsResignedRelayer(relayer common.Address, statedb *state.StateDB) bool {
slot := RelayerMappingSlot["RESIGN_REQUESTS"]
locBig := GetLocMappingAtKey(relayer.Hash(), slot)
locHash := common.BigToHash(locBig)
if statedb.GetState(common.HexToAddress(common.RelayerRegistrationSMC), locHash) != (common.Hash{}) {
return true
}
return false
return statedb.GetState(common.HexToAddress(common.RelayerRegistrationSMC), locHash) != (common.Hash{})
}

func GetBaseTokenLength(relayer common.Address, statedb *state.StateDB) uint64 {
Expand Down
33 changes: 7 additions & 26 deletions core/types/lending_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
var (
// ErrInvalidLengdingSig invalidate signer
ErrInvalidLengdingSig = errors.New("invalid transaction v, r, s values")
errNoSignerLengding = errors.New("missing signing methods")
)

const (
Expand Down Expand Up @@ -86,50 +85,32 @@ type lendingtxdata struct {

// IsCreatedLending check if tx is cancelled transaction
func (tx *LendingTransaction) IsCreatedLending() bool {
if (tx.IsLoTypeLending() || tx.IsMoTypeLending()) && tx.Status() == LendingStatusNew {
return true
}
return false
return (tx.IsLoTypeLending() || tx.IsMoTypeLending()) && tx.Status() == LendingStatusNew
}

// IsCancelledLending check if tx is cancelled transaction
func (tx *LendingTransaction) IsCancelledLending() bool {
if tx.Status() == LendingStatusCancelled {
return true
}
return false
return tx.Status() == LendingStatusCancelled
}

// IsRepayLending check if tx is repay lending transaction
func (tx *LendingTransaction) IsRepayLending() bool {
if tx.Type() == LendingRePay {
return true
}
return false
return tx.Type() == LendingRePay
}

// IsTopupLending check if tx is repay lending transaction
func (tx *LendingTransaction) IsTopupLending() bool {
if tx.Type() == LendingTopup {
return true
}
return false
return tx.Type() == LendingTopup
}

// IsMoTypeLending check if tx type is MO lending
func (tx *LendingTransaction) IsMoTypeLending() bool {
if tx.Type() == LendingTypeMo {
return true
}
return false
return tx.Type() == LendingTypeMo
}

// IsLoTypeLending check if tx type is LO lending
func (tx *LendingTransaction) IsLoTypeLending() bool {
if tx.Type() == LendingTypeLo {
return true
}
return false
return tx.Type() == LendingTypeLo
}

// EncodeRLP implements rlp.Encoder
Expand Down Expand Up @@ -363,7 +344,7 @@ func (s *LendingTxByNonce) Pop() interface{} {
return x
}

//LendingTransactionByNonce sort transaction by nonce
// LendingTransactionByNonce sort transaction by nonce
type LendingTransactionByNonce struct {
txs map[common.Address]LendingTransactions
heads LendingTxByNonce
Expand Down
17 changes: 3 additions & 14 deletions core/types/order_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
var (
// ErrInvalidOrderSig invalidate signer
ErrInvalidOrderSig = errors.New("invalid transaction v, r, s values")
errNoSignerOrder = errors.New("missing signing methods")
)

const (
Expand Down Expand Up @@ -77,26 +76,17 @@ type ordertxdata struct {

// IsCancelledOrder check if tx is cancelled transaction
func (tx *OrderTransaction) IsCancelledOrder() bool {
if tx.Status() == OrderStatusCancelled {
return true
}
return false
return tx.Status() == OrderStatusCancelled
}

// IsMoTypeOrder check if tx type is MO Order
func (tx *OrderTransaction) IsMoTypeOrder() bool {
if tx.Type() == OrderTypeMo {
return true
}
return false
return tx.Type() == OrderTypeMo
}

// IsLoTypeOrder check if tx type is LO Order
func (tx *OrderTransaction) IsLoTypeOrder() bool {
if tx.Type() == OrderTypeLo {
return true
}
return false
return tx.Type() == OrderTypeLo
}

// EncodeRLP implements rlp.Encoder
Expand Down Expand Up @@ -166,7 +156,6 @@ func (tx *OrderTransaction) WithSignature(signer OrderSigner, sig []byte) (*Orde

// ImportSignature make order tx with specific signature
func (tx *OrderTransaction) ImportSignature(V, R, S *big.Int) *OrderTransaction {

if V != nil {
tx.data.V = V
}
Expand Down
27 changes: 15 additions & 12 deletions core/vm/privacy/bulletproof.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ func GenerateNewParams(G, H []ECPoint, x *big.Int, L, R, P ECPoint) ([]ECPoint,
return Gprime, Hprime, Pprime
}

/* Inner Product Argument
/*
Inner Product Argument

Proves that <a,b>=c
This is a building block for BulletProofs
*/
Expand Down Expand Up @@ -323,7 +325,7 @@ func InnerProductProveSub(proof InnerProdArg, G, H []ECPoint, a []*big.Int, b []
return InnerProductProveSub(proof, Gprime, Hprime, aprime, bprime, u, Pprime)
}

//rpresult.IPP = InnerProductProve(left, right, that, P, EC.U, EC.BPG, HPrime)
// rpresult.IPP = InnerProductProve(left, right, that, P, EC.U, EC.BPG, HPrime)
func InnerProductProve(a []*big.Int, b []*big.Int, c *big.Int, P, U ECPoint, G, H []ECPoint) InnerProdArg {
loglen := int(math.Log2(float64(len(a))))

Expand Down Expand Up @@ -353,7 +355,9 @@ func InnerProductProve(a []*big.Int, b []*big.Int, c *big.Int, P, U ECPoint, G,
return InnerProductProveSub(runningProof, G, H, a, b, ux, Pprime)
}

/* Inner Product Verify
/*
Inner Product Verify

Given a inner product proof, verifies the correctness of the proof
Since we're using the Fiat-Shamir transform, we need to verify all x hash computations,
all g' and h' computations
Expand Down Expand Up @@ -416,11 +420,7 @@ func InnerProductVerify(c *big.Int, P, U ECPoint, G, H []ECPoint, ipp InnerProdA
Pcalc3 := ux.Mult(ccalc)
Pcalc := Pcalc1.Add(Pcalc2).Add(Pcalc3)

if !Pprime.Equal(Pcalc) {
return false
}

return true
return Pprime.Equal(Pcalc)
}

/* Inner Product Verify Fast
Expand Down Expand Up @@ -961,11 +961,14 @@ MultiRangeProof Prove
Takes in a list of values and provides an aggregate
range proof for all the values.
changes:
all values are concatenated
r(x) is computed differently
tau_x calculation is different
delta calculation is different

all values are concatenated
r(x) is computed differently
tau_x calculation is different
delta calculation is different

{(g, h \in G, \textbf{V} \in G^m ; \textbf{v, \gamma} \in Z_p^m) :

V_j = h^{\gamma_j}g^{v_j} \wedge v_j \in [0, 2^n - 1] \forall j \in [1, m]}
*/
var bitsPerValue = 64
Expand Down