Skip to content

Commit

Permalink
Hoist core/node/contracts up one dir, also move river contracts to ri… (
Browse files Browse the repository at this point in the history
#268)

…ver subdir
  • Loading branch information
sergekh2 authored Jun 26, 2024
1 parent 082af0a commit 5440e84
Show file tree
Hide file tree
Showing 80 changed files with 210 additions and 242 deletions.
3 changes: 1 addition & 2 deletions core/cmd/register_xchain_node_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core/types"
node_contracts "github.com/river-build/river/core/node/contracts"
"github.com/river-build/river/core/node/crypto"
"github.com/river-build/river/core/node/infra"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -100,7 +99,7 @@ func registerImpl(operatorKeyfile string, userConfirmationMessage string, regist
return err
}

decoder, err := node_contracts.NewEVMErrorDecoder(checker.GetMetadata(), entitlementGatedMetaData.GetMetadata())
decoder, err := crypto.NewEVMErrorDecoder(checker.GetMetadata(), entitlementGatedMetaData.GetMetadata())
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions core/cmd/registry_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"

"github.com/river-build/river/core/config"
"github.com/river-build/river/core/contracts/river"
. "github.com/river-build/river/core/node/base"
"github.com/river-build/river/core/node/contracts"
"github.com/river-build/river/core/node/crypto"
"github.com/river-build/river/core/node/infra"
. "github.com/river-build/river/core/node/protocol"
Expand Down Expand Up @@ -125,7 +125,7 @@ func nodesdump(cfg *config.Config) error {
node.NodeAddress.Hex(),
node.Operator.Hex(),
node.Status,
contracts.NodeStatusString(node.Status),
river.NodeStatusString(node.Status),
node.Url,
)
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

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

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package contracts
package river

import "github.com/ethereum/go-ethereum/accounts/abi/bind"

Expand Down

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

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

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package contracts
package river

import "github.com/ethereum/go-ethereum/accounts/abi/bind"

Expand Down

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

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package contracts
package river

import "github.com/ethereum/go-ethereum/accounts/abi/bind"

Expand Down
2 changes: 1 addition & 1 deletion core/node/auth/architect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/river-build/river/core/config"
"github.com/river-build/river/core/node/contracts/base"
"github.com/river-build/river/core/contracts/base"
"github.com/river-build/river/core/node/dlog"
. "github.com/river-build/river/core/node/protocol"

Expand Down
2 changes: 1 addition & 1 deletion core/node/auth/banning.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/river-build/river/core/config"
baseContracts "github.com/river-build/river/core/contracts/base"
. "github.com/river-build/river/core/node/base"
baseContracts "github.com/river-build/river/core/node/contracts/base"
. "github.com/river-build/river/core/node/protocol"
)

Expand Down
2 changes: 1 addition & 1 deletion core/node/auth/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"time"

"github.com/river-build/river/core/contracts/base"
. "github.com/river-build/river/core/node/base"
"github.com/river-build/river/core/node/contracts/base"
"github.com/river-build/river/core/node/dlog"
. "github.com/river-build/river/core/node/protocol"
"github.com/river-build/river/core/node/shared"
Expand Down
2 changes: 1 addition & 1 deletion core/node/auth/entitlement.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"time"

"github.com/river-build/river/core/contracts/base"
. "github.com/river-build/river/core/node/base"
"github.com/river-build/river/core/node/contracts/base"
"github.com/river-build/river/core/node/dlog"
. "github.com/river-build/river/core/node/protocol"

Expand Down
2 changes: 1 addition & 1 deletion core/node/auth/pausable.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"time"

"github.com/river-build/river/core/contracts/base"
. "github.com/river-build/river/core/node/base"
"github.com/river-build/river/core/node/contracts/base"
"github.com/river-build/river/core/node/dlog"
. "github.com/river-build/river/core/node/protocol"

Expand Down
2 changes: 1 addition & 1 deletion core/node/auth/space_contract_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"
"sync"

"github.com/river-build/river/core/contracts/base"
. "github.com/river-build/river/core/node/base"
"github.com/river-build/river/core/node/contracts/base"
"github.com/river-build/river/core/node/dlog"
. "github.com/river-build/river/core/node/protocol"

Expand Down
2 changes: 1 addition & 1 deletion core/node/auth/wallet_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"time"

"github.com/river-build/river/core/config"
"github.com/river-build/river/core/contracts/base"
. "github.com/river-build/river/core/node/base"
"github.com/river-build/river/core/node/contracts/base"
"github.com/river-build/river/core/node/dlog"
. "github.com/river-build/river/core/node/protocol"

Expand Down
7 changes: 3 additions & 4 deletions core/node/crypto/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"math/big"
"testing"

"github.com/river-build/river/core/node/contracts"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/river-build/river/core/contracts/river"
. "github.com/river-build/river/core/node/base"
"github.com/river-build/river/core/node/base/test"
. "github.com/river-build/river/core/node/protocol"
Expand Down Expand Up @@ -211,7 +210,7 @@ func TestBlockchainMultiMonitor(t *testing.T) {
require.NoError(err)
defer tc.Close()

abi, err := contracts.NodeRegistryV1MetaData.GetAbi()
abi, err := river.NodeRegistryV1MetaData.GetAbi()
require.NoError(err, "node registry abi")

var (
Expand Down Expand Up @@ -239,7 +238,7 @@ func TestBlockchainMultiMonitor(t *testing.T) {
return tc.NodeRegistry.RegisterNode(
opts, node.Wallet.Address,
"http://TestBlockchainMultiMonitor.test",
contracts.NodeStatus_NotInitialized)
river.NodeStatus_NotInitialized)
})

require.NoError(err, "submit RegisterNode tx")
Expand Down
26 changes: 13 additions & 13 deletions core/node/crypto/chain_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/river-build/river/core/contracts/river"
"github.com/river-build/river/core/node/base/test"
"github.com/river-build/river/core/node/contracts"
"github.com/river-build/river/core/node/crypto"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestChainMonitorEvents(t *testing.T) {
close(onMonitorStoppedCount)
}

nodeRegistryABI, _ = abi.JSON(strings.NewReader(contracts.NodeRegistryV1ABI))
nodeRegistryABI, _ = abi.JSON(strings.NewReader(river.NodeRegistryV1ABI))

urls = []string{"https://river0.test"}
addrs = []common.Address{tc.Wallets[0].Address}
Expand All @@ -192,7 +192,7 @@ func TestChainMonitorEvents(t *testing.T) {
ctx,
"RegisterNode",
func(opts *bind.TransactOpts) (*types.Transaction, error) {
return tc.NodeRegistry.RegisterNode(opts, addrs[0], urls[0], contracts.NodeStatus_NotInitialized)
return tc.NodeRegistry.RegisterNode(opts, addrs[0], urls[0], river.NodeStatus_NotInitialized)
},
)
require.NoError(err)
Expand Down Expand Up @@ -246,7 +246,7 @@ func TestContractAllEventsFromFuture(t *testing.T) {
futureContractEventsCallback = func(ctx context.Context, event types.Log) {
futureContractEventsCallbackCapturedEvents <- event
}
nodeRegistryABI, _ = abi.JSON(strings.NewReader(contracts.NodeRegistryV1MetaData.ABI))
nodeRegistryABI, _ = abi.JSON(strings.NewReader(river.NodeRegistryV1MetaData.ABI))
readCapturedEvents = func(captured <-chan types.Log) []types.Log {
var logs []types.Log
for i := 0; i < nodeCount; i++ {
Expand Down Expand Up @@ -280,7 +280,7 @@ func TestContractAllEventsFromFuture(t *testing.T) {
opts,
wallet.Address,
fmt.Sprintf("https://node%d.river.test", i),
contracts.NodeStatus_NotInitialized,
river.NodeStatus_NotInitialized,
)
},
)
Expand Down Expand Up @@ -344,7 +344,7 @@ func TestContractAllEventsFromFuture(t *testing.T) {
opts,
wallet.Address,
fmt.Sprintf("https://node%d.river.test", i),
contracts.NodeStatus_NotInitialized,
river.NodeStatus_NotInitialized,
)
},
)
Expand Down Expand Up @@ -390,7 +390,7 @@ func TestContractAllEventsFromPast(t *testing.T) {
historicalContractEventsCallback = func(ctx context.Context, event types.Log) {
historicalContractEventsCallbackCapturedEvents <- event
}
nodeRegistryABI, _ = abi.JSON(strings.NewReader(contracts.NodeRegistryV1MetaData.ABI))
nodeRegistryABI, _ = abi.JSON(strings.NewReader(river.NodeRegistryV1MetaData.ABI))
readCapturedEvents = func(captured <-chan types.Log) []types.Log {
var logs []types.Log
for i := 0; i < nodeCount; i++ {
Expand Down Expand Up @@ -424,7 +424,7 @@ func TestContractAllEventsFromPast(t *testing.T) {
opts,
wallet.Address,
fmt.Sprintf("https://node%d.river.test", i),
contracts.NodeStatus_NotInitialized,
river.NodeStatus_NotInitialized,
)
},
)
Expand Down Expand Up @@ -510,7 +510,7 @@ func TestContractEventsWithTopicsFromPast(t *testing.T) {
historicalContractWithTopicsEventCallback = func(ctx context.Context, event types.Log) {
historicalContractWithTopicsEventCallbackCapturedEvents <- event
}
nodeRegistryABI, _ = abi.JSON(strings.NewReader(contracts.NodeRegistryV1MetaData.ABI))
nodeRegistryABI, _ = abi.JSON(strings.NewReader(river.NodeRegistryV1MetaData.ABI))
readCapturedEvents = func(captured <-chan types.Log) []types.Log {
var logs []types.Log
for i := 0; i < nodeCount; i++ {
Expand Down Expand Up @@ -540,7 +540,7 @@ func TestContractEventsWithTopicsFromPast(t *testing.T) {
ctx,
"RegisterNode",
func(opts *bind.TransactOpts) (*types.Transaction, error) {
return tc.NodeRegistry.RegisterNode(opts, wallet.Address, fmt.Sprintf("https://node%d.river.test", i), contracts.NodeStatus_NotInitialized)
return tc.NodeRegistry.RegisterNode(opts, wallet.Address, fmt.Sprintf("https://node%d.river.test", i), river.NodeStatus_NotInitialized)
},
)
require.NoError(err, "register node")
Expand Down Expand Up @@ -614,7 +614,7 @@ func TestEventsOrder(t *testing.T) {
capturedEvents <- event
}

nodeRegistryABI, _ = abi.JSON(strings.NewReader(contracts.NodeRegistryV1MetaData.ABI))
nodeRegistryABI, _ = abi.JSON(strings.NewReader(river.NodeRegistryV1MetaData.ABI))
readCapturedEvents = func(captured <-chan types.Log) []types.Log {
var logs []types.Log
for i := 0; i < nodeCount; i++ {
Expand Down Expand Up @@ -644,7 +644,7 @@ func TestEventsOrder(t *testing.T) {
ctx,
"RegisterNode",
func(opts *bind.TransactOpts) (*types.Transaction, error) {
return tc.NodeRegistry.RegisterNode(opts, wallet.Address, fmt.Sprintf("https://node%d.river.test", i), contracts.NodeStatus_NotInitialized)
return tc.NodeRegistry.RegisterNode(opts, wallet.Address, fmt.Sprintf("https://node%d.river.test", i), river.NodeStatus_NotInitialized)
},
)
require.NoError(err, "register node")
Expand All @@ -671,7 +671,7 @@ func TestEventsOrder(t *testing.T) {
if nodeRegistryABI.Events["NodeAdded"].ID != event.Topics[0] {
continue
}
var e contracts.NodeRegistryV1NodeAdded
var e river.NodeRegistryV1NodeAdded
if err := tc.NodeRegistry.BoundContract().UnpackLog(&e, "NodeAdded", event); err != nil {
require.NoError(err, "OnNodeAdded: unable to decode NodeAdded event")
}
Expand Down
10 changes: 5 additions & 5 deletions core/node/crypto/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/river-build/river/core/contracts/river"
. "github.com/river-build/river/core/node/base"
"github.com/river-build/river/core/node/contracts"
"github.com/river-build/river/core/node/dlog"
. "github.com/river-build/river/core/node/protocol"
"github.com/river-build/river/core/node/shared"
Expand Down Expand Up @@ -147,7 +147,7 @@ type (
// activeBlock holds the current block on which the node is active
activeBlock atomic.Uint64
// contract interacts with the on-chain contract and provide metadata for decoding events
contract *contracts.RiverConfigV1Caller
contract *river.RiverConfigV1Caller
}

// Settings holds a list of setting values for each type of setting.
Expand Down Expand Up @@ -190,7 +190,7 @@ func NewOnChainConfig(
appliedBlockNum BlockNumber,
chainMonitor ChainMonitor,
) (*onChainConfiguration, error) {
caller, err := contracts.NewRiverConfigV1Caller(riverRegistry, riverClient)
caller, err := river.NewRiverConfigV1Caller(riverRegistry, riverClient)
if err != nil {
return nil, err
}
Expand All @@ -217,7 +217,7 @@ func NewOnChainConfig(
// on block sets the current block number that is used to determine the active configuration setting.
chainMonitor.OnBlock(cfg.onBlock)

cfgABI, err := contracts.RiverConfigV1MetaData.GetAbi()
cfgABI, err := river.RiverConfigV1MetaData.GetAbi()
if err != nil {
panic(fmt.Sprintf("RiverConfigV1 ABI invalid: %v", err))
}
Expand Down Expand Up @@ -292,7 +292,7 @@ func (occ *onChainConfiguration) ActiveBlock() uint64 {
func (occ *onChainConfiguration) onConfigChanged(ctx context.Context, event types.Log) {
var (
log = dlog.FromCtx(ctx)
e contracts.RiverConfigV1ConfigurationChanged
e river.RiverConfigV1ConfigurationChanged
)
if err := occ.contract.BoundContract().UnpackLog(&e, "ConfigurationChanged", event); err != nil {
log.Error("OnChainConfiguration: unable to decode ConfigurationChanged event")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package contracts
package crypto

import (
"encoding/hex"
Expand Down
Loading

0 comments on commit 5440e84

Please sign in to comment.