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
19 changes: 0 additions & 19 deletions .github/workflows/build.yml

This file was deleted.

7 changes: 5 additions & 2 deletions .github/workflows/go-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: "1.25.x"
# Analyzer tools must build with the Go above (1.25: cmd/blox doesn't build on 1.26 yet). staticcheck
# v0.7.0 (2026.1) and x/tools v0.49.0 are the last releases that do; newer ones need Go 1.26, and
# v0.4.6 no longer builds on 1.25. Bump these together with go-version.
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@v0.4.6
run: go install honnef.co/go/tools/cmd/staticcheck@v0.7.0
- name: Clear Go module cache
run: go clean -modcache
- name: Check that go.mod is tidy
Expand All @@ -37,7 +40,7 @@ jobs:
run: go vet ./...
- name: Install shadow analyzer
if: success() || failure()
run: go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
run: go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@v0.49.0
# A shadowed `err` in wap/pkg/server once left the WAP API refusing to start after a SUCCESSFUL bind:
# the retry loop redeclared err, so the outer err still held the original failure and Serve() logged
# "Successfully bound ..." immediately followed by "... Server will not start." `go vet` does not catch
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ jobs:
env:
SECRETS_DIR: ${{ github.workspace }}/secrets

# mobile's client tests spend ~5 min waiting out the client's fixed dial timeouts (there is no device to
# reach); under -race that package alone comes close to go test's default 10 min limit.
- name: Run tests with race detector
run: go test -v -race ./...
run: go test -v -race -timeout 20m ./...
env:
SECRETS_DIR: ${{ github.workspace }}/secrets
42 changes: 0 additions & 42 deletions .github/workflows/publish.yml

This file was deleted.

46 changes: 0 additions & 46 deletions Dockerfile

This file was deleted.

42 changes: 12 additions & 30 deletions blockchain/abi/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ var MethodSignatures = struct {
// DecodePoolsResult decodes the result from pools(uint32) contract call
func DecodePoolsResult(data string) (*Pool, error) {
// Remove 0x prefix
if strings.HasPrefix(data, "0x") {
data = data[2:]
}
data = strings.TrimPrefix(data, "0x")

// Check if we have enough data (minimum 9 * 32 bytes = 288 hex chars)
if len(data) < 288 {
Expand Down Expand Up @@ -247,9 +245,7 @@ func DecodePoolsResult(data string) (*Pool, error) {
// DecodeIsMemberOfPoolResult decodes the result from isPeerIdMemberOfPool(uint32,bytes32) contract call
func DecodeIsMemberOfPoolResult(data string) (*IsMemberOfPoolResult, error) {
// Remove 0x prefix
if strings.HasPrefix(data, "0x") {
data = data[2:]
}
data = strings.TrimPrefix(data, "0x")

// Check if we have enough data (2 * 32 bytes = 128 hex chars)
if len(data) < 128 {
Expand Down Expand Up @@ -280,9 +276,7 @@ func DecodeIsMemberOfPoolResult(data string) (*IsMemberOfPoolResult, error) {
// DecodeGetMemberPeerIdsResult decodes the result from getMemberPeerIds(uint32,address) contract call
func DecodeGetMemberPeerIdsResult(data string) (*GetMemberPeerIdsResult, error) {
// Remove 0x prefix
if strings.HasPrefix(data, "0x") {
data = data[2:]
}
data = strings.TrimPrefix(data, "0x")

// Check if we have enough data (minimum 64 hex chars for offset + length)
if len(data) < 64 {
Expand Down Expand Up @@ -346,40 +340,34 @@ func EncodePoolIdsCall(index uint32) string {
// DecodePoolIdResponse decodes the response from poolIds(uint256) call
func DecodePoolIdResponse(result string) (uint32, error) {
// Remove 0x prefix
if strings.HasPrefix(result, "0x") {
result = result[2:]
}

result = strings.TrimPrefix(result, "0x")

// Should be 64 hex characters (32 bytes)
if len(result) != 64 {
return 0, fmt.Errorf("invalid response length: expected 64 hex chars, got %d", len(result))
}

// Parse as uint64 first, then convert to uint32
poolID, err := strconv.ParseUint(result, 16, 64)
if err != nil {
return 0, fmt.Errorf("failed to parse pool ID: %w", err)
}

return uint32(poolID), nil
}

// EncodeIsPeerIdMemberOfPoolCall encodes the isPeerIdMemberOfPool(uint32,bytes32) method call
func EncodeIsPeerIdMemberOfPoolCall(poolID uint32, peerIDBytes32 string) string {
// Remove 0x prefix from peerIDBytes32 if present
if strings.HasPrefix(peerIDBytes32, "0x") {
peerIDBytes32 = peerIDBytes32[2:]
}
peerIDBytes32 = strings.TrimPrefix(peerIDBytes32, "0x")

return fmt.Sprintf("%s%064x%s", MethodSignatures.IsPeerIdMemberOfPool, poolID, peerIDBytes32)
}

// EncodeGetMemberPeerIdsCall encodes the getMemberPeerIds(uint32,address) method call
func EncodeGetMemberPeerIdsCall(poolID uint32, memberAddress string) string {
// Remove 0x prefix from memberAddress if present
if strings.HasPrefix(memberAddress, "0x") {
memberAddress = memberAddress[2:]
}
memberAddress = strings.TrimPrefix(memberAddress, "0x")

// Pad address to 32 bytes (64 hex chars)
paddedAddress := fmt.Sprintf("%064s", memberAddress)
Expand All @@ -390,19 +378,15 @@ func EncodeGetMemberPeerIdsCall(poolID uint32, memberAddress string) string {
// EncodeRemoveMemberPeerIdCall encodes the removeMemberPeerId(uint32,bytes32) method call
func EncodeRemoveMemberPeerIdCall(poolID uint32, peerIDBytes32 string) string {
// Remove 0x prefix from peerIDBytes32 if present
if strings.HasPrefix(peerIDBytes32, "0x") {
peerIDBytes32 = peerIDBytes32[2:]
}
peerIDBytes32 = strings.TrimPrefix(peerIDBytes32, "0x")

return fmt.Sprintf("%s%064x%s", MethodSignatures.RemoveMemberPeerId, poolID, peerIDBytes32)
}

// EncodeJoinRequestsCall encodes the joinRequests(uint32,bytes32) public-mapping getter call
func EncodeJoinRequestsCall(poolID uint32, peerIDBytes32 string) string {
// Remove 0x prefix from peerIDBytes32 if present
if strings.HasPrefix(peerIDBytes32, "0x") {
peerIDBytes32 = peerIDBytes32[2:]
}
peerIDBytes32 = strings.TrimPrefix(peerIDBytes32, "0x")

return fmt.Sprintf("%s%064x%s", MethodSignatures.JoinRequests, poolID, peerIDBytes32)
}
Expand All @@ -412,9 +396,7 @@ func EncodeJoinRequestsCall(poolID uint32, peerIDBytes32 string) string {
// 0 = no request.
func DecodeJoinRequestStatus(data string) (uint8, error) {
// Remove 0x prefix
if strings.HasPrefix(data, "0x") {
data = data[2:]
}
data = strings.TrimPrefix(data, "0x")

// 8 * 32 bytes = 512 hex chars
if len(data) < 512 {
Expand Down
14 changes: 7 additions & 7 deletions blockchain/bl_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func (bl *FxBlockchain) Seeded(ctx context.Context, to peer.ID, r SeededRequest) ([]byte, error) {

if bl.allowTransientConnection {
ctx = network.WithUseTransient(ctx, "fx.blockchain")
ctx = network.WithAllowLimitedConn(ctx, "fx.blockchain")
}

var buf bytes.Buffer
Expand Down Expand Up @@ -46,7 +46,7 @@ func (bl *FxBlockchain) Seeded(ctx context.Context, to peer.ID, r SeededRequest)

func (bl *FxBlockchain) AccountCreate(ctx context.Context, to peer.ID) ([]byte, error) {
if bl.allowTransientConnection {
ctx = network.WithUseTransient(ctx, "fx.blockchain")
ctx = network.WithAllowLimitedConn(ctx, "fx.blockchain")
}

req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://"+to.String()+".invalid/"+actionAccountCreate, nil)
Expand All @@ -72,7 +72,7 @@ func (bl *FxBlockchain) AccountCreate(ctx context.Context, to peer.ID) ([]byte,

func (bl *FxBlockchain) AccountFund(ctx context.Context, to peer.ID, r AccountFundRequest) ([]byte, error) {
if bl.allowTransientConnection {
ctx = network.WithUseTransient(ctx, "fx.blockchain")
ctx = network.WithAllowLimitedConn(ctx, "fx.blockchain")
}

var buf bytes.Buffer
Expand Down Expand Up @@ -104,7 +104,7 @@ func (bl *FxBlockchain) AccountFund(ctx context.Context, to peer.ID, r AccountFu
func (bl *FxBlockchain) AccountExists(ctx context.Context, to peer.ID, r AccountExistsRequest) ([]byte, error) {

if bl.allowTransientConnection {
ctx = network.WithUseTransient(ctx, "fx.blockchain")
ctx = network.WithAllowLimitedConn(ctx, "fx.blockchain")
}

var buf bytes.Buffer
Expand Down Expand Up @@ -135,7 +135,7 @@ func (bl *FxBlockchain) AccountExists(ctx context.Context, to peer.ID, r Account
func (bl *FxBlockchain) AccountBalance(ctx context.Context, to peer.ID, r AccountBalanceRequest) ([]byte, error) {

if bl.allowTransientConnection {
ctx = network.WithUseTransient(ctx, "fx.blockchain")
ctx = network.WithAllowLimitedConn(ctx, "fx.blockchain")
}

var buf bytes.Buffer
Expand Down Expand Up @@ -165,7 +165,7 @@ func (bl *FxBlockchain) AccountBalance(ctx context.Context, to peer.ID, r Accoun

func (bl *FxBlockchain) AssetsBalance(ctx context.Context, to peer.ID, r AssetsBalanceRequest) ([]byte, error) {
if bl.allowTransientConnection {
ctx = network.WithUseTransient(ctx, "fx.blockchain")
ctx = network.WithAllowLimitedConn(ctx, "fx.blockchain")
}

var buf bytes.Buffer
Expand Down Expand Up @@ -195,7 +195,7 @@ func (bl *FxBlockchain) AssetsBalance(ctx context.Context, to peer.ID, r AssetsB

func (bl *FxBlockchain) TransferToFula(ctx context.Context, to peer.ID, r TransferToFulaRequest) ([]byte, error) {
if bl.allowTransientConnection {
ctx = network.WithUseTransient(ctx, "fx.blockchain")
ctx = network.WithAllowLimitedConn(ctx, "fx.blockchain")
}

var buf bytes.Buffer
Expand Down
6 changes: 3 additions & 3 deletions blockchain/bl_autopin.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (bl *FxBlockchain) handleAutoPinUnpair(from peer.ID, w http.ResponseWriter,
// AutoPinPair is the P2P client-side method for the mobile bridge.
func (bl *FxBlockchain) AutoPinPair(ctx context.Context, to peer.ID, r AutoPinPairRequest) ([]byte, error) {
if bl.allowTransientConnection {
ctx = network.WithUseTransient(ctx, "fx.blockchain")
ctx = network.WithAllowLimitedConn(ctx, "fx.blockchain")
}

var buf bytes.Buffer
Expand Down Expand Up @@ -203,7 +203,7 @@ func (bl *FxBlockchain) AutoPinPair(ctx context.Context, to peer.ID, r AutoPinPa
// AutoPinRefresh is the P2P client-side method for the mobile bridge.
func (bl *FxBlockchain) AutoPinRefresh(ctx context.Context, to peer.ID, r AutoPinRefreshRequest) ([]byte, error) {
if bl.allowTransientConnection {
ctx = network.WithUseTransient(ctx, "fx.blockchain")
ctx = network.WithAllowLimitedConn(ctx, "fx.blockchain")
}

var buf bytes.Buffer
Expand Down Expand Up @@ -235,7 +235,7 @@ func (bl *FxBlockchain) AutoPinRefresh(ctx context.Context, to peer.ID, r AutoPi
// AutoPinUnpair is the P2P client-side method for the mobile bridge.
func (bl *FxBlockchain) AutoPinUnpair(ctx context.Context, to peer.ID) ([]byte, error) {
if bl.allowTransientConnection {
ctx = network.WithUseTransient(ctx, "fx.blockchain")
ctx = network.WithAllowLimitedConn(ctx, "fx.blockchain")
}

req, err := http.NewRequestWithContext(ctx, http.MethodPost, "http://"+to.String()+".invalid/"+actionAutoPinUnpair, nil)
Expand Down
Loading
Loading