Add Pons native contract for inter-government bridge protocol

Implement comprehensive cross-border cooperation infrastructure:

- Bilateral Agreements: Government-to-government treaties
  - Committee-managed agreement lifecycle
  - Types: Trade, Identity, Education, Health, Settlement, Comprehensive
  - Active/Suspended/Terminated status tracking

- Cross-Border Verification: Identity and credential validation
  - Request identity verification from partner governments
  - Verification types: Identity, Credential, Health, Employment
  - Pending/Verified/Rejected/Expired status management

- International Settlement: Cross-border VTS transactions
  - Settlement requests between sovereign chains
  - Fee calculation with configurable default (0.5%)
  - Complete transaction tracking with proofs

- Credential Sharing: Portable education and health records
  - Share Scire (education) and Salus (health) credentials
  - Configurable validity periods
  - Revocation support for outdated credentials

- Cross-contract integration:
  - Vita: Identity verification for requests
  - Federation: Complement intra-chain coordination
  - RoleRegistry: RoleBridgeOperator (ID 27)
  - VTS: Settlement payments
  - Scire/Salus: Credential verification

Latin naming: Pons = "bridge" - reflecting the contract's purpose
of connecting sovereign government blockchain instances.

Contract ID: -24

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Tutus Development 2025-12-20 09:57:28 +00:00
parent 1fdf29e5e9
commit 3a6ee2492e
7 changed files with 1410 additions and 1 deletions

View File

@ -634,6 +634,16 @@ func NewDefaultContracts(cfg config.ProtocolConfiguration) []interop.Contract {
palam.RoleRegistry = roleRegistry
palam.Lex = lex
// Create Pons (Inter-Government Bridge) contract
pons := newPons()
pons.NEO = neo
pons.Vita = vita
pons.Federation = federation
pons.RoleRegistry = roleRegistry
pons.VTS = vts
pons.Scire = scire
pons.Salus = salus
return []interop.Contract{
mgmt,
s,
@ -658,5 +668,6 @@ func NewDefaultContracts(cfg config.ProtocolConfiguration) []interop.Contract {
tribute,
opus,
palam,
pons,
}
}

File diff suppressed because one or more lines are too long

View File

@ -55,4 +55,6 @@ var (
Opus = util.Uint160{0xf5, 0x22, 0x73, 0x17, 0x98, 0xab, 0xfc, 0x4d, 0x7c, 0x3a, 0x51, 0x8, 0x47, 0xc7, 0xe5, 0xe4, 0x6, 0x96, 0xb6, 0xfd}
// Palam is a hash of native Palam contract.
Palam = util.Uint160{0x3, 0x23, 0x73, 0xfa, 0x71, 0x3a, 0x34, 0xab, 0x8d, 0x8c, 0xfa, 0xe2, 0xb0, 0x46, 0xdf, 0x53, 0x88, 0x79, 0x16, 0xae}
// Pons is a hash of native Pons contract.
Pons = util.Uint160{0x58, 0x39, 0xd0, 0x19, 0xa5, 0xb8, 0x8c, 0x92, 0x3f, 0x9a, 0x80, 0x2b, 0x53, 0xa7, 0xc7, 0x7c, 0x35, 0x81, 0xdd, 0xcc}
)

View File

@ -53,4 +53,6 @@ const (
Opus int32 = -22
// Palam is an ID of native Palam contract.
Palam int32 = -23
// Pons is an ID of native Pons contract.
Pons int32 = -24
)

View File

@ -25,6 +25,7 @@ const (
Tribute = "Tribute"
Opus = "Opus"
Palam = "Palam"
Pons = "Pons"
)
// All contains the list of all native contract names ordered by the contract ID.
@ -52,6 +53,7 @@ var All = []string{
Tribute,
Opus,
Palam,
Pons,
}
// IsValid checks if the name is a valid native contract's name.
@ -78,5 +80,6 @@ func IsValid(name string) bool {
name == Sese ||
name == Tribute ||
name == Opus ||
name == Palam
name == Palam ||
name == Pons
}

1260
pkg/core/native/pons.go Normal file

File diff suppressed because it is too large Load Diff

130
pkg/core/state/pons.go Normal file
View File

@ -0,0 +1,130 @@
package state
import (
"github.com/tutus-one/tutus-chain/pkg/util"
)
// AgreementStatus represents the status of a bilateral agreement.
type AgreementStatus uint8
// Agreement status constants.
const (
AgreementPending AgreementStatus = 0
AgreementActive AgreementStatus = 1
AgreementSuspended AgreementStatus = 2
AgreementTerminated AgreementStatus = 3
)
// AgreementType represents the type of bilateral agreement.
type AgreementType uint8
// Agreement type constants.
const (
AgreementTypeGeneral AgreementType = 0 // General cooperation
AgreementTypeIdentity AgreementType = 1 // Identity verification
AgreementTypeSettlement AgreementType = 2 // VTS settlement
AgreementTypeEducation AgreementType = 3 // Education credential sharing
AgreementTypeHealthcare AgreementType = 4 // Healthcare record sharing
AgreementTypeComprehensive AgreementType = 5 // All services
)
// VerificationStatus represents the status of a verification request.
type VerificationStatus uint8
// Verification status constants.
const (
VerificationPending VerificationStatus = 0
VerificationApproved VerificationStatus = 1
VerificationRejected VerificationStatus = 2
VerificationExpired VerificationStatus = 3
)
// VerificationType represents the type of verification request.
type VerificationType uint8
// Verification type constants.
const (
VerificationTypeIdentity VerificationType = 0 // Identity verification
VerificationTypeCredential VerificationType = 1 // Education credential
VerificationTypeHealth VerificationType = 2 // Healthcare record
VerificationTypeCertificate VerificationType = 3 // Professional certificate
)
// SettlementStatus represents the status of a settlement request.
type SettlementStatus uint8
// Settlement status constants.
const (
SettlementPending SettlementStatus = 0
SettlementCompleted SettlementStatus = 1
SettlementRejected SettlementStatus = 2
SettlementCancelled SettlementStatus = 3
)
// BilateralAgreement represents an agreement between two sovereign chains.
type BilateralAgreement struct {
ID uint64 // Unique agreement ID
LocalChainID uint32 // This chain's ID
RemoteChainID uint32 // Partner chain's ID
AgreementType AgreementType // Type of agreement
Status AgreementStatus
Terms util.Uint256 // Hash of off-chain terms document
EffectiveDate uint32 // Block height when effective
ExpirationDate uint32 // Block height when expires (0 = no expiry)
CreatedAt uint32 // Block height when created
UpdatedAt uint32 // Last update block height
}
// VerificationRequest represents a cross-border verification request.
type VerificationRequest struct {
ID uint64 // Unique request ID
RequestingChain uint32 // Chain requesting verification
TargetChain uint32 // Chain being queried
Subject util.Uint160 // Subject of verification
VerificationType VerificationType
DataHash util.Uint256 // Hash of requested data
Status VerificationStatus
ResponseHash util.Uint256 // Hash of response data (if any)
Requester util.Uint160 // Who initiated request
CreatedAt uint32 // Block height
ExpiresAt uint32 // Request expiry
RespondedAt uint32 // When responded (0 = pending)
}
// SettlementRequest represents an international VTS settlement request.
type SettlementRequest struct {
ID uint64 // Unique request ID
FromChain uint32 // Originating chain
ToChain uint32 // Destination chain
Sender util.Uint160 // Sender on from chain
Receiver util.Uint160 // Receiver on to chain
Amount uint64 // VTS amount (in smallest units)
Reference string // Payment reference
Status SettlementStatus
CreatedAt uint32 // Block height
SettledAt uint32 // When settled (0 = pending)
TxHash util.Uint256 // Settlement transaction hash
}
// CredentialShare represents a shared credential between chains.
type CredentialShare struct {
ID uint64 // Unique share ID
SourceChain uint32 // Chain where credential originated
TargetChain uint32 // Chain receiving credential
Owner util.Uint160 // Credential owner
CredentialType VerificationType
CredentialID uint64 // Original credential ID on source chain
ContentHash util.Uint256 // Hash of credential content
ValidUntil uint32 // Validity period on target chain
CreatedAt uint32 // Block height
IsRevoked bool // Has been revoked
}
// PonsConfig represents configurable parameters for the Pons contract.
type PonsConfig struct {
LocalChainID uint32 // This chain's unique identifier
VerificationTimeout uint32 // Blocks until verification request expires
SettlementTimeout uint32 // Blocks until settlement request expires
MaxPendingRequests uint64 // Maximum pending requests per chain
CredentialShareExpiry uint32 // Default validity period for shared credentials
}