|
| 1 | +// Package types defines the data structures for the x/mempoolshield module. |
| 2 | +// Implements the Compliance Membrane per CHAIN-SPEC-v1.5.1 Section 6.2. |
| 3 | +package types |
| 4 | + |
| 5 | +const ( |
| 6 | + ModuleName = "mempoolshield" |
| 7 | + StoreKey = ModuleName |
| 8 | + |
| 9 | + // Threat level constants per CHAIN-SPEC-v1.5.1 Section 8. |
| 10 | + ThreatLevelStandard = 1 // Default: oracle-screened capital routing |
| 11 | + ThreatLevelElevated = 2 // Enhanced screening |
| 12 | + ThreatLevelHigh = 3 // Dual oracle confirmation |
| 13 | + ThreatLevelConflict = 4 // Level 4 / Art. VIII: capital routing SUSPENDED |
| 14 | +) |
| 15 | + |
| 16 | +// FailsafeMode defines the behavior when the oracle is unavailable. |
| 17 | +type FailsafeMode string |
| 18 | + |
| 19 | +const ( |
| 20 | + // FailsafeLockdownCapitalOnly rejects capital-routing txs only; blocks continue. |
| 21 | + // This is the REQUIRED default per CHAIN-SPEC-v1.5.1 Liveness Invariant #3. |
| 22 | + FailsafeLockdownCapitalOnly FailsafeMode = "LOCKDOWN_CAPITAL_ONLY" |
| 23 | + // FailsafePassThrough allows all txs when oracle is unavailable (NOT RECOMMENDED). |
| 24 | + FailsafePassThrough FailsafeMode = "PASS_THROUGH" |
| 25 | +) |
| 26 | + |
| 27 | +// Params defines the configurable parameters for x/mempoolshield. |
| 28 | +type Params struct { |
| 29 | + // Enabled controls whether the Mempool Shield is active. |
| 30 | + Enabled bool `json:"enabled"` |
| 31 | + // ThreatLevel is the current operational threat level (1-4). |
| 32 | + ThreatLevel int32 `json:"threat_level"` |
| 33 | + // OracleThreshold is the minimum oracle signatures required (default: 5). |
| 34 | + OracleThreshold int32 `json:"oracle_threshold"` |
| 35 | + // OracleSigners is the total number of oracle nodes (default: 7). |
| 36 | + OracleSigners int32 `json:"oracle_signers"` |
| 37 | + // FailsafeDefault defines behavior when the oracle is unavailable. |
| 38 | + // MUST be LOCKDOWN_CAPITAL_ONLY to satisfy liveness invariants. |
| 39 | + FailsafeDefault FailsafeMode `json:"failsafe_default"` |
| 40 | + // ProhibitedEntities is the local testnet allow/deny list. |
| 41 | + // Populated from the 5-of-7 oracle committee in production. |
| 42 | + ProhibitedEntities []string `json:"prohibited_entities"` |
| 43 | +} |
| 44 | + |
| 45 | +// DefaultParams returns the default Mempool Shield parameters. |
| 46 | +func DefaultParams() Params { |
| 47 | + return Params{ |
| 48 | + Enabled: true, |
| 49 | + ThreatLevel: ThreatLevelStandard, |
| 50 | + OracleThreshold: 5, |
| 51 | + OracleSigners: 7, |
| 52 | + FailsafeDefault: FailsafeLockdownCapitalOnly, |
| 53 | + ProhibitedEntities: []string{}, |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +// OracleNode represents a registered Mempool Shield oracle signer. |
| 58 | +type OracleNode struct { |
| 59 | + // Address is the bech32 validator address. |
| 60 | + Address string `json:"address"` |
| 61 | + // FeedType identifies the compliance feed (e.g., "OFAC", "UN", "EU", "FATF"). |
| 62 | + FeedType string `json:"feed_type"` |
| 63 | + // Active indicates whether this node is currently participating. |
| 64 | + Active bool `json:"active"` |
| 65 | + // LastUpdateBlock is the last block at which this node submitted an oracle update. |
| 66 | + LastUpdateBlock int64 `json:"last_update_block"` |
| 67 | +} |
| 68 | + |
| 69 | +// ScreeningResult is the oracle committee's response for a capital-routing transaction. |
| 70 | +type ScreeningResult struct { |
| 71 | + // TxHash identifies the transaction. |
| 72 | + TxHash string `json:"tx_hash"` |
| 73 | + // Approved is true if the transaction passed all compliance checks. |
| 74 | + Approved bool `json:"approved"` |
| 75 | + // MatchedEntities lists any prohibited entity identifiers found. |
| 76 | + MatchedEntities []string `json:"matched_entities"` |
| 77 | + // OracleSignatures contains the approving/rejecting oracle signatures. |
| 78 | + OracleSignatures int32 `json:"oracle_signatures"` |
| 79 | +} |
0 commit comments