Skip to content

Commit

Permalink
Merge branch 'main' of github.com:AudiusProject/audius-protocol into …
Browse files Browse the repository at this point in the history
…jd/mute-and-report-fixes

# Conflicts:
#	packages/discovery-provider/src/queries/get_comments.py
  • Loading branch information
DejayJD committed Oct 16, 2024
2 parents 05b5ab5 + 4732864 commit b9c4781
Show file tree
Hide file tree
Showing 106 changed files with 1,835 additions and 2,538 deletions.
8 changes: 8 additions & 0 deletions .circleci/src/jobs/@audiusd-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ test-audiusd-devnet:
name: Teardown
command: |
audius-ctl --debug down -af
- run:
name: test isLocalhost config
command: |
audius-ctl config create-context test-localhost -f dev-tools/templates/test-localhost.yaml
audius-ctl up --debug
audius-ctl restart -f --debug
audius-ctl down -f --debug
audius-ctl devnet down --debug
test-config-subcommands:
docker:
Expand Down
2 changes: 1 addition & 1 deletion cmd/audius-ctl/jump.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
if _, ok := ctx.Nodes[args[0]]; !ok {
return logger.Errorf("No host named '%s' in the current context.", args[0])
}
return orchestration.ShellIntoNode(args[0])
return orchestration.ShellIntoNode(args[0], ctx.Nodes[args[0]].IsLocalhost)
},
}
)
32 changes: 17 additions & 15 deletions cmd/audius-ctl/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,19 @@ func readOrCreateContext() (*conf.ContextConfig, error) {
}

func runDownNodes(all bool, force bool, hosts []string) error {
ctx, err := readOrCreateContext()
if err != nil {
return logger.Error("Could not get current context:", err)
}

if all && len(hosts) > 0 {
return logger.Error("Cannot combine specific nodes with flag --all/-a.")
} else if !all && len(hosts) == 0 {
} else if !all && len(hosts) == 0 && len(ctx.Nodes) > 1 {
return logger.Error("Must specify which nodes to take down or use --all/-a.")
}

ctx, err := readOrCreateContext()
if err != nil {
return logger.Error("Could not get current context:", err)
}
var nodesToRunDown map[string]conf.NodeConfig
if all {
if all || len(ctx.Nodes) == 1 {
nodesToRunDown = ctx.Nodes
} else {
nodesToRunDown, err = filterNodesFromContext(hosts, ctx)
Expand All @@ -120,8 +121,8 @@ func runDownNodes(all bool, force bool, hosts []string) error {
return logger.Error("Aborted")
}

for host := range nodesToRunDown {
if err := orchestration.RunDownNode(host); err != nil {
for host, config := range nodesToRunDown {
if err := orchestration.RunDownNode(host, config.IsLocalhost); err != nil {
fmt.Fprintf(os.Stderr, "Warning: skipping error encountered while spinning down %s: %s", host, err.Error())
}
}
Expand All @@ -147,18 +148,19 @@ func runUpNodes(waitForHealthy bool, audiusdTag string, hosts []string) error {
}

func restartNodes(all, force, waitForHealthy bool, hosts []string) error {
ctx, err := readOrCreateContext()
if err != nil {
return logger.Error("Could not get current context:", err)
}

if all && len(hosts) > 0 {
return logger.Error("Cannot combine specific nodes with flag --all/-a.")
} else if !all && len(hosts) == 0 {
} else if !all && len(hosts) == 0 && len(ctx.Nodes) > 1 {
return logger.Error("Must specify which nodes to take down or use --all/-a.")
}

ctx, err := readOrCreateContext()
if err != nil {
return logger.Error("Could not get current context:", err)
}
var nodesToRestart map[string]conf.NodeConfig
if all {
if all || len(ctx.Nodes) == 1 {
nodesToRestart = ctx.Nodes
} else {
nodesToRestart, err = filterNodesFromContext(hosts, ctx)
Expand All @@ -178,7 +180,7 @@ func restartNodes(all, force, waitForHealthy bool, hosts []string) error {
}

for host, config := range nodesToRestart {
if err := orchestration.RunDownNode(host); err != nil {
if err := orchestration.RunDownNode(host, config.IsLocalhost); err != nil {
fmt.Fprintf(os.Stderr, "Warning: skipping error encountered while spinning down %s: %s", host, err.Error())
}
orchestration.RunAudiusNodes(
Expand Down
2 changes: 1 addition & 1 deletion cmd/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $(GEN_ARTIFACTS): $(GEN_SRCS)
)
cd ../../pkg/core && go generate ./...
cd ../../pkg/core/db && sqlc generate
protoc --go_out=../../pkg/core/gen --go-grpc_out=../../pkg/core/gen ../../pkg/core/protocol.proto
protoc --go_out=../../pkg/core/gen --go-grpc_out=../../pkg/core/gen --proto_path=../../pkg/core ../../pkg/core/protocol.proto
go mod tidy

.PHONY: core-dev
Expand Down
15 changes: 13 additions & 2 deletions comms/discovery/db/queries/get_new_blasts.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ func GetNewBlasts(q db.Queryable, ctx context.Context, arg ChatMembershipParams)
// see also: subtly different inverse query exists in chat_blast.go
// to fan out messages to existing chat
var findNewBlasts = `
with all_new as (
with
last_permission_change as (
select max(t) as t from (
select updated_at as t from chat_permissions where user_id = $1
union
select created_at as t from chat_blocked_users where blocker_user_id = $1
union
select to_timestamp(0)
)
),
all_new as (
select *
from chat_blast blast
where
Expand Down Expand Up @@ -85,7 +95,8 @@ func GetNewBlasts(q db.Queryable, ctx context.Context, arg ChatMembershipParams)
)
)
select * from all_new
where chat_allowed(from_user_id, $1)
where created_at > (select t from last_permission_change)
and chat_allowed(from_user_id, $1)
order by created_at
`

Expand Down
47 changes: 47 additions & 0 deletions comms/discovery/rpcz/chat_blast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func TestChatBlast(t *testing.T) {
err = chatSetPermissions(tx, 69, schema.None, nil, nil, t0)
assert.NoError(t, err)

// Other user (104) closes inbox
err = chatSetPermissions(tx, 104, schema.None, nil, nil, t0)
assert.NoError(t, err)

// ----------------- some threads already exist -------------
// user 100 starts a thread with 69 before first blast
chatId_100_69 := misc.ChatID(100, 69)
Expand Down Expand Up @@ -216,6 +220,15 @@ func TestChatBlast(t *testing.T) {
assert.Len(t, blasts, 1)
}

// user 104 has zero blasts (inbox closed)
{
blasts, err := queries.GetNewBlasts(tx, ctx, queries.ChatMembershipParams{
UserID: 104,
})
assert.NoError(t, err)
assert.Len(t, blasts, 0)
}

// user 999 does not
{
assertChatCreateAllowed(t, tx, 999, 69, false)
Expand Down Expand Up @@ -308,6 +321,11 @@ func TestChatBlast(t *testing.T) {
}

// ----------------- a second message ------------------------

// Other user (104) re-opens inbox
err = chatSetPermissions(tx, 104, schema.All, nil, nil, t3)
assert.NoError(t, err)

_, err = chatBlast(tx, 69, t4, schema.ChatBlastRPCParams{
BlastID: "b2",
Audience: schema.FollowerAudience,
Expand Down Expand Up @@ -386,6 +404,35 @@ func TestChatBlast(t *testing.T) {
}
}

// user 104 should have just 1 blast
// since 104 opened inbox after first blast
{
blasts, err := queries.GetNewBlasts(tx, ctx, queries.ChatMembershipParams{
UserID: 104,
})
assert.NoError(t, err)
assert.Len(t, blasts, 1)

// 104 does upgrade
chatId_104_69 := misc.ChatID(104, 69)

err = chatCreate(tx, 104, t6, schema.ChatCreateRPCParams{
ChatID: chatId_104_69,
Invites: []schema.PurpleInvite{
{UserID: misc.MustEncodeHashID(104), InviteCode: "earlier"},
{UserID: misc.MustEncodeHashID(69), InviteCode: "earlier"},
},
})
assert.NoError(t, err)

// 104 convo seeded with 1 message

messages := mustGetMessagesAndReactions(104, chatId_104_69)
assert.Len(t, messages, 1)
messages = mustGetMessagesAndReactions(69, chatId_104_69)
assert.Len(t, messages, 1)
}

// ------ sender can get blasts in a given thread ----------
{
chat, err := queries.UserChat(tx, ctx, queries.ChatMembershipParams{
Expand Down
14 changes: 14 additions & 0 deletions dev-tools/templates/test-localhost.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
network:
deployOn: devnet
nodes:
creator-localhost.devnet.audius-d:
type: content
isLocalhost: true
httpPort: 4000
httpsPort: 4001
version: prerelease
privateKey: 21118f9a6de181061a2abd549511105adb4877cf9026f271092e6813b7cf58ab
wallet: 0x0D38e653eC28bdea5A2296fD5940aaB2D0B8875c
rewardsWallet: 0xb3c66e682Bf9a85F6800c769AC5A05c18C3F331d
corePortP2P: 36656
corePortRPC: 36657
Loading

0 comments on commit b9c4781

Please sign in to comment.