Skip to content
Open
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
8 changes: 8 additions & 0 deletions pkg/lumera/modules/action_msg/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package action_msg
import (
"context"
"fmt"
"sync"

actiontypes "github.com/LumeraProtocol/lumera/x/action/v1/types"
"github.com/LumeraProtocol/supernode/v2/pkg/lumera/modules/auth"
Expand All @@ -16,6 +17,7 @@ import (
type module struct {
client actiontypes.MsgClient
txHelper *txmod.TxHelper
mu sync.Mutex
}
Comment on lines 17 to 21
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SetTxHelperConfig and GetTxHelper methods access m.txHelper without mutex protection, which could cause race conditions if called concurrently with the now-protected RequestAction or FinalizeCascadeAction methods. Additionally, SimulateFinalizeCascadeAction also accesses m.txHelper without protection.

While the mutex correctly protects the transaction execution in the modified methods, consider whether these other methods that access the shared txHelper state should also be protected to ensure complete thread safety across the module.

Copilot uses AI. Check for mistakes.

func newModule(conn *grpc.ClientConn, authmodule auth.Module, txmodule txmod.Module, kr keyring.Keyring, keyName string, chainID string) (Module, error) {
Expand Down Expand Up @@ -49,6 +51,9 @@ func (m *module) RequestAction(ctx context.Context, actionType, metadata, price,
return nil, err
}

m.mu.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need lock here... RequestAction signed by user, not supernode.
This works just fine now with lots of accounts concurrently.

defer m.mu.Unlock()

return m.txHelper.ExecuteTransaction(ctx, func(creator string) (types.Msg, error) {
return createRequestActionMessage(creator, actionType, metadata, price, expirationTime), nil
})
Expand All @@ -59,6 +64,9 @@ func (m *module) FinalizeCascadeAction(ctx context.Context, actionId string, rqI
return nil, err
}

m.mu.Lock()
defer m.mu.Unlock()

return m.txHelper.ExecuteTransaction(ctx, func(creator string) (types.Msg, error) {
return createFinalizeActionMessage(creator, actionId, rqIdsIds)
})
Expand Down
Loading