fix(g1): NV$ Gebuehren-Preflight fuer Gruppen und Uploads (#434)
* fix(economy): preflight upload fees without blocking peer transfers * fix(groups): preflight creation and membership fees before persistent mutations * fix(groups): guard legacy XMLRPC creation and joining fees before mutation * test(g1): verify group fee ordering and system upload preflight * ci(g1): guard fee-wallet preflight in group and upload paths * docs(g1): group and upload fee-wallet prerequisites and rollback guidance * fix(groups): reject nonexistent groups before fee and membership lookup
This commit is contained in:
1 parent
8ececfdf3b
commit
0e7d7c5ebe
6 files changed
+226
-27
No files matched your search
@@ -444,6 +444,10 @@ jobs:
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_g1_classified_fee_preflight.py
|
||||
|
||||
- name: Verify NV$ group and upload fee preflight
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_g1_fee_charges_groups_uploads.py
|
||||
|
||||
- name: Verify citizen world map integration
|
||||
shell: bash
|
||||
run: python3 tools/ci/verify_citizen_world_map.py
|
||||
|
||||
@@ -507,12 +507,13 @@ namespace NexVerse.RegionModules.Economy
|
||||
}
|
||||
}
|
||||
|
||||
// Uploads are system charges, unlike normal AmountCovered calls for
|
||||
// land and resident transfers. Block a missing fee destination before
|
||||
// a CAPS upload allocates the inventory item or spends storage.
|
||||
public bool UploadCovered(
|
||||
UUID agentID,
|
||||
int amount) =>
|
||||
AmountCovered(
|
||||
agentID,
|
||||
amount);
|
||||
TryPreflightCharge(agentID, amount, out _);
|
||||
|
||||
public bool AmountCovered(
|
||||
UUID agentID,
|
||||
|
||||
@@ -918,8 +918,13 @@ namespace OpenSim.Groups
|
||||
if (money != null)
|
||||
{
|
||||
// do the transaction, that is if the agent has got sufficient funds
|
||||
if (!money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge)) {
|
||||
remoteClient.SendCreateGroupReply(UUID.Zero, false, "Insufficient funds to create a group.");
|
||||
string feeReason = "Insufficient funds to create a group.";
|
||||
bool canCreate = money is IMoneyChargePreflight preflight
|
||||
? preflight.TryPreflightCharge(remoteClient.AgentId, money.GroupCreationCharge, out feeReason)
|
||||
: money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge);
|
||||
if (!canCreate)
|
||||
{
|
||||
remoteClient.SendCreateGroupReply(UUID.Zero, false, feeReason);
|
||||
return UUID.Zero;
|
||||
}
|
||||
}
|
||||
@@ -930,10 +935,25 @@ namespace OpenSim.Groups
|
||||
|
||||
if (!groupID.IsZero())
|
||||
{
|
||||
bool feeConfirmed = true;
|
||||
if (money != null && money.GroupCreationCharge > 0)
|
||||
money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate, name);
|
||||
{
|
||||
try
|
||||
{
|
||||
money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge,
|
||||
MoneyTransactionType.GroupCreate, name);
|
||||
}
|
||||
catch (Exception feeError)
|
||||
{
|
||||
feeConfirmed = false;
|
||||
m_log.ErrorFormat("[GROUPS]: Group {0} created for {1}, but NV$ charge not confirmed; reconcile ledger: {2}",
|
||||
groupID, remoteClient.AgentId, feeError.Message);
|
||||
remoteClient.SendAlertMessage("Group created, but NV$ fee could not be confirmed. Contact grid support before retrying.");
|
||||
}
|
||||
}
|
||||
|
||||
remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
|
||||
remoteClient.SendCreateGroupReply(groupID, true,
|
||||
feeConfirmed ? "Group created successfully" : "Group created; NV$ fee pending review.");
|
||||
|
||||
// Update the founder with new group information.
|
||||
SendAgentGroupDataUpdate(remoteClient, true);
|
||||
@@ -1129,6 +1149,11 @@ namespace OpenSim.Groups
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
|
||||
GroupRecord groupRecord = GetGroupRecord(groupID);
|
||||
if (groupRecord == null)
|
||||
{
|
||||
remoteClient.SendJoinGroupReply(groupID, false);
|
||||
return;
|
||||
}
|
||||
IMoneyModule money = remoteClient.Scene.RequestModuleInterface<IMoneyModule>();
|
||||
|
||||
// Should check to see if there's an outstanding invitation
|
||||
@@ -1136,9 +1161,13 @@ namespace OpenSim.Groups
|
||||
if (money != null && groupRecord.MembershipFee > 0)
|
||||
{
|
||||
// Does the agent have the funds to cover the group join fee?
|
||||
if (!money.AmountCovered(remoteClient.AgentId, groupRecord.MembershipFee))
|
||||
string feeReason = "Insufficient funds to join the group.";
|
||||
bool canJoin = money is IMoneyChargePreflight preflight
|
||||
? preflight.TryPreflightCharge(remoteClient.AgentId, groupRecord.MembershipFee, out feeReason)
|
||||
: money.AmountCovered(remoteClient.AgentId, groupRecord.MembershipFee);
|
||||
if (!canJoin)
|
||||
{
|
||||
remoteClient.SendAlertMessage("Insufficient funds to join the group.");
|
||||
remoteClient.SendAlertMessage(feeReason);
|
||||
remoteClient.SendJoinGroupReply(groupID, false);
|
||||
return;
|
||||
}
|
||||
@@ -1150,7 +1179,19 @@ namespace OpenSim.Groups
|
||||
if (m_groupData.AddAgentToGroup(requestingAgentIDStr, requestingAgentIDStr, groupID, UUID.Zero, string.Empty, out reason))
|
||||
{
|
||||
if (money != null && groupRecord.MembershipFee > 0)
|
||||
money.ApplyCharge(remoteClient.AgentId, groupRecord.MembershipFee, MoneyTransactionType.GroupJoin, groupRecord.GroupName);
|
||||
{
|
||||
try
|
||||
{
|
||||
money.ApplyCharge(remoteClient.AgentId, groupRecord.MembershipFee,
|
||||
MoneyTransactionType.GroupJoin, groupRecord.GroupName);
|
||||
}
|
||||
catch (Exception feeError)
|
||||
{
|
||||
m_log.ErrorFormat("[GROUPS]: Agent {0} joined group {1}, but NV$ charge not confirmed; reconcile ledger: {2}",
|
||||
remoteClient.AgentId, groupID, feeError.Message);
|
||||
remoteClient.SendAlertMessage("Membership created, but NV$ fee could not be confirmed. Contact grid support.");
|
||||
}
|
||||
}
|
||||
|
||||
remoteClient.SendJoinGroupReply(groupID, true);
|
||||
|
||||
|
||||
@@ -1027,21 +1027,46 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
|
||||
}
|
||||
}
|
||||
|
||||
// check funds
|
||||
// is there a money module present ?
|
||||
IMoneyModule money = scene.RequestModuleInterface<IMoneyModule>();
|
||||
if (money != null && money.GroupCreationCharge > 0)
|
||||
{
|
||||
// do the transaction, that is if the agent has sufficient funds
|
||||
if (!money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge)) {
|
||||
remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have insufficient funds to create a group.");
|
||||
string feeReason = "Insufficient funds to create a group.";
|
||||
bool feeReady = money is IMoneyChargePreflight preflight
|
||||
? preflight.TryPreflightCharge(remoteClient.AgentId, money.GroupCreationCharge, out feeReason)
|
||||
: money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge);
|
||||
if (!feeReady)
|
||||
{
|
||||
remoteClient.SendCreateGroupReply(UUID.Zero, false, feeReason);
|
||||
return UUID.Zero;
|
||||
}
|
||||
money.ApplyCharge(GetRequestingAgentID(remoteClient), money.GroupCreationCharge, MoneyTransactionType.GroupCreate, name);
|
||||
}
|
||||
UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
|
||||
|
||||
remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
|
||||
UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
|
||||
if (groupID.IsZero())
|
||||
{
|
||||
remoteClient.SendCreateGroupReply(UUID.Zero, false, "Group creation failed.");
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
bool feeConfirmed = true;
|
||||
if (money != null && money.GroupCreationCharge > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
money.ApplyCharge(GetRequestingAgentID(remoteClient), money.GroupCreationCharge,
|
||||
MoneyTransactionType.GroupCreate, name);
|
||||
}
|
||||
catch (Exception feeError)
|
||||
{
|
||||
feeConfirmed = false;
|
||||
m_log.ErrorFormat("[GROUPS-XMLRPC]: Group {0} created, but fee not confirmed for {1}; ledger reconciliation required: {2}",
|
||||
groupID, remoteClient.AgentId, feeError.Message);
|
||||
remoteClient.SendAlertMessage("Group created, but NV$ fee could not be confirmed. Contact grid support before retrying.");
|
||||
}
|
||||
}
|
||||
|
||||
remoteClient.SendCreateGroupReply(groupID, true,
|
||||
feeConfirmed ? "Group created successfully" : "Group created; NV$ fee pending review.");
|
||||
|
||||
// Update the founder with new group information.
|
||||
SendAgentGroupDataUpdate(remoteClient, true);
|
||||
@@ -1232,21 +1257,43 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
|
||||
{
|
||||
if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
|
||||
|
||||
// Should check to see if OpenEnrollment, or if there's an outstanding invitation
|
||||
m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero);
|
||||
|
||||
// check funds
|
||||
// is there a money module present ?
|
||||
// Preflight the fee *before* the legacy provider grants membership.
|
||||
GroupRecord groupRecord = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
|
||||
if (groupRecord == null)
|
||||
{
|
||||
remoteClient.SendJoinGroupReply(groupID, false);
|
||||
return;
|
||||
}
|
||||
IMoneyModule money = remoteClient.Scene.RequestModuleInterface<IMoneyModule>();
|
||||
if (money != null && groupRecord.MembershipFee > 0)
|
||||
{
|
||||
// do the transaction, that is if the agent has sufficient funds
|
||||
if (!money.AmountCovered(GetRequestingAgentID(remoteClient), groupRecord.MembershipFee)) {
|
||||
remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have insufficient funds to join the group.");
|
||||
string feeReason = "Insufficient funds to join the group.";
|
||||
bool feeReady = money is IMoneyChargePreflight preflight
|
||||
? preflight.TryPreflightCharge(GetRequestingAgentID(remoteClient), groupRecord.MembershipFee, out feeReason)
|
||||
: money.AmountCovered(GetRequestingAgentID(remoteClient), groupRecord.MembershipFee);
|
||||
if (!feeReady)
|
||||
{
|
||||
remoteClient.SendAlertMessage(feeReason);
|
||||
remoteClient.SendJoinGroupReply(groupID, false);
|
||||
return;
|
||||
}
|
||||
money.ApplyCharge(GetRequestingAgentID(remoteClient), groupRecord.MembershipFee, MoneyTransactionType.GroupJoin, groupRecord.GroupName);
|
||||
}
|
||||
|
||||
// The legacy provider and NV$ ledger do not share a transaction.
|
||||
m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero);
|
||||
if (money != null && groupRecord.MembershipFee > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
money.ApplyCharge(GetRequestingAgentID(remoteClient), groupRecord.MembershipFee,
|
||||
MoneyTransactionType.GroupJoin, groupRecord.GroupName);
|
||||
}
|
||||
catch (Exception feeError)
|
||||
{
|
||||
m_log.ErrorFormat("[GROUPS-XMLRPC]: Membership {0}/{1} created, but NV$ fee not confirmed; ledger reconciliation required: {2}",
|
||||
remoteClient.AgentId, groupID, feeError.Message);
|
||||
remoteClient.SendAlertMessage("Membership created, but NV$ fee could not be confirmed. Contact grid support.");
|
||||
}
|
||||
}
|
||||
|
||||
remoteClient.SendJoinGroupReply(groupID, true);
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# G1 NV$ Gebuehren - Gruppen, Mitgliedschaften und Uploads
|
||||
|
||||
Status: Quellcode-Fix mit CI- und Staging-Gates, kein Live-Rollout.
|
||||
|
||||
## Risiko vor der Korrektur
|
||||
|
||||
Der bekannte Fehler bei Classifieds (PR #432) betrifft auch
|
||||
`NexVerseMoneyModule.ApplyCharge` und `ApplyUploadCharge`.
|
||||
Bei unkonfigurierter `[NexEconomyViewer] FeeWalletId` schlugen positive
|
||||
Gebuehren mit `NV$ fee wallet is not configured` fehl.
|
||||
|
||||
Gruppen (sowohl `OpenSim/Addons/Groups` als auch der alte
|
||||
`XmlRpcGroups`-Adapter) prueften nur `AmountCovered`.
|
||||
Eine gefuellte Nutzerwallet konnte somit genuegen, um einen
|
||||
kostenpflichtigen Gruppenaufruf bis zur Gebuehrenbuchung durchzulassen.
|
||||
Im alten XmlRpc-Gruppenadapter wurde bei Gruppenerstellung zu frueh
|
||||
belastet, bei Gruppenbeitritt hingegen erst die Mitgliedschaft angelegt
|
||||
und anschliessend das Guthaben geprueft.
|
||||
|
||||
## Fix
|
||||
|
||||
- `UploadCovered` verwendet nun die getrennte
|
||||
`IMoneyChargePreflight.TryPreflightCharge`-Pruefung fuer positive
|
||||
Uploadgebuehren. `AmountCovered` fuer normale Transfers bleibt
|
||||
unveraendert.
|
||||
- Bei Neugruendung und kostenpflichtigem Beitritt wird die Systemgebuehr
|
||||
vor dem persistenten Anlegen der Gruppe/Mitgliedschaft vorvalidiert.
|
||||
Beide Gruppenmodule nutzen das optionale Interface; fremde
|
||||
`IMoneyModule` koennen weiterhin `AmountCovered` nutzen.
|
||||
- Der alte XmlRpc-Adapter bucht die Gruppenerstellungsgebuehr erst nach
|
||||
erfolgreich erstellter Gruppe; bei Mitgliedschaften wird nicht mehr
|
||||
vor der Guthabenpruefung eingetragen.
|
||||
- Eine spaete Buchungsausnahme laeuft nicht ungefangen in den
|
||||
Viewer-Request: UUIDs und Fehlergrund werden mit
|
||||
manuellem Ledger-Reconciliation-Hinweis protokolliert; der Viewer
|
||||
bekommt eine Warnung.
|
||||
|
||||
## Betrieb und Konfiguration
|
||||
|
||||
```ini
|
||||
[NexEconomyViewer]
|
||||
FeeWalletId = "<SYSTEM_FEE_WALLET_UUID>"
|
||||
```
|
||||
|
||||
Die Zielwallet muss im NV$-Ledger als tatsaechlicher, berechtigter
|
||||
Empfaenger eingerichtet sein. Die hier geaenderten Pfade
|
||||
**generieren weder Wallet-UUIDs noch erlauben sie Gebuehrenfreiheit**
|
||||
bei fehlender Konfiguration. Keine fremde Avatarwallet und nicht
|
||||
`UUID.Zero` einsetzen. Der produktive Regionsprozess braucht nach
|
||||
einem neuen Build einen kontrollierten Neustart.
|
||||
|
||||
## Abnahme und Restpunkte
|
||||
|
||||
1. `FeeWalletId` leer, UploadCharge/GroupCreationCharge oder
|
||||
MembershipFee positiv: Ablehnung *vor* dauerhafter Mutation.
|
||||
2. Gueltige Wallet, ausreichendes Guthaben: erfolgreich und einmalig
|
||||
gebuchter Geldfluss sowie korrekte Gruppe/Inventar.
|
||||
3. Keine Deckung, API timeout, falsches HG-Wallet, die gleiche Aktion
|
||||
zweimal: keine negativen Salden und keine Dopplungen.
|
||||
4. Gratis-Gruppen und UploadCharge=0: weiterhin freigeschaltet.
|
||||
5. Normale Residents- und Land-Transfers bei fehlender Gebuehrenwallet:
|
||||
nicht global blockiert.
|
||||
6. Alte XmlRpc- und neuere Groups-Implementierung getrennt pruefen.
|
||||
|
||||
**Wichtige Grenze:** Die jeweiligen externen Gruppenservices und
|
||||
das NV$-Ledger verwenden keine gemeinsame Datenbanktransaktion.
|
||||
Die Vorabpruefung macht die bekannte Konfigurationsstörung vorhersehbar;
|
||||
sie garantiert keine atomare `group/create + debit`- oder
|
||||
`inventory/upload + debit`-Buchung. Unter Last oder nach API-Timeout
|
||||
muessen Betreiber die Eintraege gegen das Ledger abgleichen. Ein
|
||||
dauerhafter `pending -> confirmed`-Workflow mit persistenter
|
||||
Idempotenz ist die Folgestufe, bevor eine allgemeine
|
||||
Exactly-Once-Zahlungsgarantie behauptet werden darf.
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Regression contracts for optional fee preflight of uploads and groups."""
|
||||
from pathlib import Path
|
||||
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
money = (root/"NexVerse/RegionModules/Economy/NexVerseMoneyModule.cs").read_text()
|
||||
modern = (root/"OpenSim/Addons/Groups/GroupsModule.cs").read_text()
|
||||
legacy = (root/"OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs").read_text()
|
||||
interface = (root/"OpenSim/Framework/IMoneyModule.cs").read_text()
|
||||
assert "public interface IMoneyChargePreflight" in interface
|
||||
|
||||
upload = money.split("public bool UploadCovered(", 1)[1].split("public bool AmountCovered(", 1)[0]
|
||||
assert "TryPreflightCharge(agentID, amount, out _)" in upload
|
||||
# Standard transfers and land purchases must not inherit fee-wallet restrictions.
|
||||
funds = money.split("public bool AmountCovered(", 1)[1].split("public bool TryPreflightCharge(", 1)[0]
|
||||
assert "GetBalance(agentID)" in funds
|
||||
assert "m_FeeWalletId.IsZero()" not in funds
|
||||
|
||||
for label, source in (("new Groups",modern),("XmlRpcGroups",legacy)):
|
||||
creation = source.split("public UUID CreateGroup(",1)[1].split("public GroupNoticeData[] GroupNoticesListRequest(",1)[0]
|
||||
joining = source.split("public void JoinGroupRequest(",1)[1].split("public void LeaveGroupRequest(",1)[0]
|
||||
for name, block, call in (("creation",creation,"CreateGroup("),
|
||||
("join",joining,"AddAgentToGroup(")):
|
||||
assert "IMoneyChargePreflight preflight" in block, (label,name)
|
||||
assert "preflight.TryPreflightCharge(" in block, (label,name)
|
||||
assert "catch (Exception feeError)" in block, (label,name)
|
||||
assert block.index("preflight.TryPreflightCharge(") < block.index("m_groupData."+call), (label,name)
|
||||
assert block.index("m_groupData."+call) < block.index("money.ApplyCharge("), (label,name)
|
||||
assert "ledger reconciliation required" in creation or "reconcile ledger" in creation
|
||||
assert "ledger reconciliation required" in joining or "reconcile ledger" in joining
|
||||
|
||||
assert "if (groupRecord == null)" in legacy
|
||||
print("G1 group and upload fee preflight contracts: PASS")
|
||||
Reference in new issue
Block a user