Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove channel id array #2

Merged
merged 6 commits into from
Feb 19, 2025
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
68 changes: 34 additions & 34 deletions bindings/adjudicator/Adjudicator.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/adjudicator/AdjudicatorBinRuntime.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/assetholdererc20/AssetHolderERC20.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/assetholdererc20/AssetHolderERC20BinRuntime.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/assetholdereth/AssetHolderETH.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/assetholdereth/AssetHolderETHBinRuntime.go

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions bindings/trivialapp/TrivialApp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindings/trivialapp/TrivialAppBinRuntime.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package trivialapp // import "github.com/perun-network/perun-eth-backend/bindings/trivialapp"

// TrivialAppBinRuntime is the runtime part of the compiled bytecode used for deploying new contracts.
var TrivialAppBinRuntime = "6080604052348015600f57600080fd5b506004361060285760003560e01c806318dc6c0014602d575b600080fd5b603e60383660046057565b50505050565b005b600060a08284031215605157600080fd5b50919050565b60008060008060808587031215606c57600080fd5b843567ffffffffffffffff80821115608357600080fd5b9086019060c08289031215609657600080fd5b9094506020860135908082111560ab57600080fd5b60b5888389016040565b9450604087013591508082111560ca57600080fd5b5060d5878288016040565b94979396509394606001359350505056fea26469706673582212205081e797202cb035c07d4df0f6988f47b842ec24f720e8dc1336efef5813300764736f6c634300080f0033"
var TrivialAppBinRuntime = "6080604052348015600f57600080fd5b506004361060285760003560e01c8063f7530b4114602d575b600080fd5b603e60383660046057565b50505050565b005b600060a08284031215605157600080fd5b50919050565b60008060008060808587031215606c57600080fd5b843567ffffffffffffffff80821115608357600080fd5b9086019060c08289031215609657600080fd5b9094506020860135908082111560ab57600080fd5b60b5888389016040565b9450604087013591508082111560ca57600080fd5b5060d5878288016040565b94979396509394606001359350505056fea26469706673582212202c476f6a190b843966fe8a555305f8b86806d95b0f98acb69ff55ebc59aa68cb64736f6c634300080f0033"
2 changes: 1 addition & 1 deletion channel/adjudicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func ValidateAdjudicator(ctx context.Context, backend bind.ContractCaller, adjud
// toEthSubStates generates a channel tree in depth-first order.
func toEthSubStates(state *channel.State, subStates channel.StateMap) (ethSubStates []adjudicator.ChannelState) {
for _, subAlloc := range state.Locked {
subState, ok := subStates[channel.IDKey(subAlloc.ID)]
subState, ok := subStates[subAlloc.ID]
if !ok {
log.Panic("sub-state not found")
}
Expand Down
10 changes: 6 additions & 4 deletions channel/adjudicator_internal_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 - See NOTICE file for copyright holders.
// Copyright 2024 - See NOTICE file for copyright holders.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,8 @@ import (
"math/rand"
"testing"

"github.com/perun-network/perun-eth-backend/wallet"

"github.com/perun-network/perun-eth-backend/bindings/adjudicator"
"github.com/stretchr/testify/assert"
"perun.network/go-perun/channel"
Expand All @@ -38,13 +40,13 @@ func Test_toEthSubStates(t *testing.T) {
{
title: "nil map gives nil slice",
setup: func() (state *channel.State, subStates channel.StateMap, expected []adjudicator.ChannelState) {
return channeltest.NewRandomState(rng, channeltest.WithBackend(1)), nil, nil
return channeltest.NewRandomState(rng, channeltest.WithBackend(wallet.BackendID)), nil, nil
},
},
{
title: "fresh map gives nil slice",
setup: func() (state *channel.State, subStates channel.StateMap, expected []adjudicator.ChannelState) {
return channeltest.NewRandomState(rng, channeltest.WithBackend(1)), nil, nil
return channeltest.NewRandomState(rng, channeltest.WithBackend(wallet.BackendID)), nil, nil
},
},
{
Expand Down Expand Up @@ -84,7 +86,7 @@ func Test_toEthSubStates(t *testing.T) {
func genStates(rng *rand.Rand, n int) (states []*channel.State) {
states = make([]*channel.State, n)
for i := range states {
states[i] = channeltest.NewRandomState(rng, channeltest.WithBackend(1))
states[i] = channeltest.NewRandomState(rng, channeltest.WithBackend(wallet.BackendID))
}
return
}
Expand Down
8 changes: 4 additions & 4 deletions channel/adjudicator_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 - See NOTICE file for copyright holders.
// Copyright 2024 - See NOTICE file for copyright holders.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,7 +47,7 @@ func testSignState(t *testing.T, accounts []*keystore.Account, state *channel.St
func signState(accounts []*keystore.Account, state *channel.State) (channel.Transaction, error) {
sigs := make([][]byte, len(accounts))
for i := range accounts {
sig, err := channel.Sign(accounts[i], state, 1)
sig, err := channel.Sign(accounts[i], state, ethwallettest.BackendID)
if err != nil {
return channel.Transaction{}, errors.WithMessagef(err, "signing with account %d", i)
}
Expand All @@ -68,7 +68,7 @@ func TestSubscribeRegistered(t *testing.T) {
rng,
channeltest.WithChallengeDuration(uint64(100*time.Second)),
channeltest.WithParts(s.Parts),
channeltest.WithBackend(1),
channeltest.WithBackend(ethwallettest.BackendID),
channeltest.WithAssets(s.Asset),
channeltest.WithIsFinal(false),
channeltest.WithLedgerChannel(true),
Expand All @@ -94,7 +94,7 @@ func TestSubscribeRegistered(t *testing.T) {
tx := testSignState(t, s.Accs, state)
req := channel.AdjudicatorReq{
Params: params,
Acc: map[wallet.BackendID]wallet.Account{1: s.Accs[0]},
Acc: map[wallet.BackendID]wallet.Account{ethwallettest.BackendID: s.Accs[0]},
Idx: channel.Index(0),
Tx: tx,
}
Expand Down
18 changes: 9 additions & 9 deletions channel/asset.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 - See NOTICE file for copyright holders.
// Copyright 2024 - See NOTICE file for copyright holders.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -49,12 +49,12 @@ func MakeChainID(id *big.Int) ChainID {
return ChainID{id}
}

// MakeAssetID makes a AssetID for the given id.
func MakeAssetID(id *big.Int) multi.AssetID {
// MakeLedgerBackendID makes a AssetID for the given id.
func MakeLedgerBackendID(id *big.Int) multi.LedgerBackendID {
if id.Sign() < 0 {
panic("must not be smaller than zero")
}
return AssetID{backendID: 1, ledgerID: MakeChainID(id)}
return AssetID{backendID: wallet.BackendID, ledgerID: MakeChainID(id)}
}

// UnmarshalBinary unmarshals the chainID from its binary representation.
Expand All @@ -66,7 +66,7 @@ func (id *ChainID) UnmarshalBinary(data []byte) error {
// MarshalBinary marshals the chainID into its binary representation.
func (id ChainID) MarshalBinary() (data []byte, err error) {
if id.Sign() == -1 {
return nil, errors.New("cannot marshal negative AssetID")
return nil, errors.New("cannot marshal negative LedgerBackendID")
}
return id.Bytes(), nil
}
Expand Down Expand Up @@ -108,8 +108,8 @@ func (id AssetID) LedgerID() multi.LedgerID {
return &id.ledgerID
}

// AssetID returns the asset ID of the asset.
func (a Asset) AssetID() multi.AssetID {
// LedgerBackendID returns the asset ID of the asset.
func (a Asset) LedgerBackendID() multi.LedgerBackendID {
return a.assetID
}

Expand Down Expand Up @@ -141,12 +141,12 @@ func (a *Asset) UnmarshalBinary(data []byte) error {

// LedgerID returns the ledger ID the asset lives on.
func (a Asset) LedgerID() multi.LedgerID {
return a.AssetID().LedgerID()
return a.LedgerBackendID().LedgerID()
}

// NewAsset creates a new asset from an chainID and the AssetHolder address.
func NewAsset(chainID *big.Int, assetHolder common.Address) *Asset {
id := MakeAssetID(chainID).(AssetID) //nolint: forcetypeassert // AssetID implements multi.AssetID
id := MakeLedgerBackendID(chainID).(AssetID) //nolint: forcetypeassert // LedgerBackendID implements multi.LedgerBackendID
return &Asset{assetID: id, AssetHolder: *wallet.AsWalletAddr(assetHolder)}
}

Expand Down
2 changes: 1 addition & 1 deletion channel/asset_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 - See NOTICE file for copyright holders.
// Copyright 2024 - See NOTICE file for copyright holders.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Loading
Loading