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
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Run E2E Tests
run: ./e2e/run_e2e_tests.sh

# We disable this test for now. We should enable it once we have better way to interact with PTBs via cli.
# We disable this test for now. We should enable it once we have better way to interact with PTBs via cli.
# - name: Run E2E gap handling test
# run: ./e2e/run_e2e_gap_handling.sh

Expand Down
4 changes: 2 additions & 2 deletions bitcoinspv/clients/sui/sui_spv_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const (
containsBlockFunc = "exist"
getChainTipFunc = "head"
verifySPVFunc = "verify_tx"
newBlockHeaderFunc = "new_block_header"
newBlockHeaderFunc = "new"
lcModule = "light_client"
blockHeaderModule = "block_header"
blockHeaderModule = "header"
blockHeaderType = "BlockHeader"
// TODO: Use better defaultGasBudget
defaultGasBudget = 10000000000
Expand Down
20 changes: 13 additions & 7 deletions bitcoinspv/clients/sui/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ const BTCHeaderSize = 80
type bcsEncode []byte

// BlockHeader is block header
//
//nolint:govet
type BlockHeader struct {
Internal []uint8
Version uint32
Parent []byte
MerkleRoot []byte
Timestamp uint32
Bits uint32
Nonce uint32
BlockHash []byte
}

// LightBlock is light block
Expand All @@ -27,7 +35,7 @@ type BlockHeader struct {
type LightBlock struct {
Height uint64
ChainWork [32]uint8
Header *BlockHeader
Header BlockHeader
}

// BlockHeaderFromHex converts a hexadecimal string representation of a Bitcoin
Expand Down Expand Up @@ -83,13 +91,11 @@ func getBCSResult(res *suiclient.DevInspectTransactionBlockResponse) []bcsEncode

// BlockHash returns block hash
func (lb LightBlock) BlockHash() (chainhash.Hash, error) {
r := bytes.NewReader(lb.Header.Internal)
var header wire.BlockHeader
err := header.Deserialize(r)
hash, err := chainhash.NewHash(lb.Header.BlockHash)
if err != nil {
return header.BlockHash(), err
return chainhash.Hash{}, err
}
return header.BlockHash(), nil
return *hash, nil
}

func blockHeaderToBytes(header wire.BlockHeader) ([]byte, error) {
Expand Down
9 changes: 5 additions & 4 deletions e2e/.e2e.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Encode of serect key of your account, you can get this in ~/.sui/sui_config/sui.keystore
ENCODE_SK=AIFkXTXfEXkYEeSWIwDkVjememp3jUeTgBcq6bbUjJtt
# SPV package id
PACKAGE_ID=0x13410986ea49ecfe9ed94757d46086f45ab7269d5fcc2195ca7f8796438764ff

SPV_PACKAGE_ID=0x13410986ea49ecfe9ed94757d46086f45ab7269d5fcc2195ca7f8796438764ff
# BTC_PARSER package id
PARSER_PACKAGE_ID=0x13410986ea49ecfe9ed94757d46086f45ab7269d5fcc2195ca7f8796438764fa
# Sui network, testnet, devnet, mainnet and localnet.
NETWORK="localnet"
# BTC network spv managed. 0 = mainnet, 1 = testnet, other = regtest
Expand All @@ -13,5 +14,5 @@ BTC_HEIGHT=0
HEADERS=0x0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f2002000000
# parent chain work of first trusted header.
PARENT_CHAIN_WORK=0
# finality threshold of SPV.
FINALITY=8
# confirmation depth of SPV.
CONFIRMATION_DEPTH=8
10 changes: 2 additions & 8 deletions e2e/deploy_light_client_alpha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ CONTAINER_ID="sui-node"
PACKAGE_PATH="sui-bitcoin-spv/packages/bitcoin_spv"
CONFIG_FILE="e2e-bitcoin-spv.yml"

INIT_HEADERS='0x0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f2002000000'
BTC_NETWORK=2 # regtest (0: mainnet, 1: testnet, 2: regtest)
START_HEIGHT=0



echo "Cloning light client repo"
docker exec "$CONTAINER_ID" /bin/bash -c \
"rm -rf $PACKAGE_PATH && \
Expand All @@ -38,8 +32,8 @@ echo "Package ID: $PACKAGE_ID"

echo $(pwd)

sed -i "s#^PACKAGE_ID=.*#PACKAGE_ID=${PACKAGE_ID}#" ./e2e/.e2e.env

sed -i "s#^SPV_PACKAGE_ID=.*#SPV_PACKAGE_ID=${PACKAGE_ID}#" ./e2e/.e2e.env
sed -i "s#^PARSER_PACKAGE_ID=.*#PARSER_PACKAGE_ID=${PACKAGE_ID}#" ./e2e/.e2e.env

cd "$LOCAL_REPO_PATH"
cp ../.e2e.env ./.env
Expand Down
Loading