Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
save progress
  • Loading branch information
AdityaSripal authored and colin-axner committed Dec 20, 2018
1 parent 8cf2365 commit 467bb71
Show file tree
Hide file tree
Showing 7 changed files with 1,230 additions and 1,197 deletions.
6 changes: 4 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"fmt"
"crypto/ecdsa"
"encoding/binary"
"encoding/json"
Expand Down Expand Up @@ -111,12 +112,13 @@ func NewChildChain(logger log.Logger, db dbm.DB, traceStore io.Writer, options .
app.SetEndBlocker(app.endBlocker)

// Set Ethereum connection
client, err := eth.InitEthConn(app.nodeURL)
fmt.Println(app.nodeURL)
client, err := eth.InitEthConn(app.nodeURL, bapp.Logger)
if err != nil {
panic(err)
}

plasmaClient, err := eth.InitPlasma(app.rootchain.Hex(), client, app.BaseApp.Logger, app.validatorPrivKey, app.isValidator)
plasmaClient, err := eth.InitPlasma(app.rootchain.Hex(), app.validatorPrivKey, client, app.BaseApp.Logger, app.block_finality, app.isValidator)
if err != nil {
panic(err)
}
Expand Down
9 changes: 4 additions & 5 deletions app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ func SetEthConfig(isValidator bool, privkey_file, rootchain_addr, nodeURL, minFe
if err != nil {
panic(err)
}

block_finality, err = strconv.ParseUint(finality, 10, 64)
if err != nil {
panic(err)
}
}
block_finality, err := strconv.ParseUint(finality, 10, 64)
if err != nil {
panic(err)
}
return func(cc *ChildChain) {
cc.validatorPrivKey = privkey
Expand Down
33 changes: 25 additions & 8 deletions auth/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,17 @@ func NewAnteHandler(utxoMapper utxo.Mapper, metadataMapper metadata.MetadataMapp
if !res.IsOK() {
return ctx, res, true
}
exitErr := hasTXExited(plasmaClient, position0)
if exitErr != nil {
return ctx, exitErr.Result(), true
}
fmt.Println("I got past Tx Exited")
if position0.IsDeposit() {
deposit, _ := DepositExists(position0.DepositNum, plasmaClient)
inputUTXO := utxo.NewUTXO(deposit.Owner.Bytes(), uint64(deposit.Amount), types.Denom, position0)
inputUTXO := utxo.NewUTXO(deposit.Owner.Bytes(), deposit.Amount.Uint64(), types.Denom, position0)
utxoMapper.ReceiveUTXO(ctx, inputUTXO)
}
fmt.Println("I got past second Deposit check")

res = processSig(addr0, sigs[0], signBytes)

Expand All @@ -81,13 +87,17 @@ func NewAnteHandler(utxoMapper utxo.Mapper, metadataMapper metadata.MetadataMapp
addr1 := common.BytesToAddress(signerAddrs[1].Bytes())
position1 := types.PlasmaPosition{spendMsg.Blknum1, spendMsg.Txindex1, spendMsg.Oindex1, spendMsg.DepositNum1}

exitErr := hasTXExited(plasmaClient, position1)
if exitErr != nil {
return ctx, exitErr.Result(), true
}
res := checkUTXO(ctx, plasmaClient, utxoMapper, position1, addr1)
if !res.IsOK() {
return ctx, res, true
}
if position1.IsDeposit() {
deposit, _ := DepositExists(position1.DepositNum, plasmaClient)
inputUTXO := utxo.NewUTXO(deposit.Owner.Bytes(), uint64(deposit.Amount), types.Denom, position1)
inputUTXO := utxo.NewUTXO(deposit.Owner.Bytes(), deposit.Amount.Uint64(), types.Denom, position1)
utxoMapper.ReceiveUTXO(ctx, inputUTXO)
}

Expand Down Expand Up @@ -191,16 +201,23 @@ func checkUTXO(ctx sdk.Context, plasmaClient *eth.Plasma, mapper utxo.Mapper, po
}

func DepositExists(nonce uint64, plasmaClient *eth.Plasma) (types.Deposit, bool) {
deposit, err := plasmaClient.CheckDeposit(sdk.NewUint(nonce))
fmt.Println("Called Deposit Exists")
deposit, err := plasmaClient.GetDeposit(sdk.NewUint(nonce))

if err != nil {
return types.Deposit{}, false
}
return deposit, true
return *deposit, true
}

/*
func ExitPriority(position types.PlasmaPosition) {
if position.IsDeposit()
func hasTXExited(plasmaClient *eth.Plasma, pos types.PlasmaPosition) sdk.Error {
var positions [4]sdk.Uint
for i, num := range pos.Get() {
positions[i] = num
}
exited := plasmaClient.HasTXBeenExited(positions)
if exited {
return types.ErrInvalidTransaction(types.DefaultCodespace, "Input UTXO has already exited")
}
return nil
}
*/
Loading

0 comments on commit 467bb71

Please sign in to comment.