A distributed timestamp service providing cryptographically secure, consensus-validated timestamps for blockchain MEV prevention.
The Timeserver Core provides a distributed network of timestamp validators that work together to create tamper-proof, globally ordered timestamps. When integrated with a blockchain, it enables mathematical prevention of MEV (Maximal Extractable Value) attacks by enforcing strict chronological ordering of transactions.
- Strict Timestamp Ordering: Enforces chronological transaction ordering, making frontrunning mathematically impossible
- Threshold Signatures: Requires multiple independent validators to sign timestamps
- Drift Protection: Prevents timestamp manipulation through strict drift limits
- Geographic Distribution: Servers organized into regions for low latency
- Cross-Region Consistency: Global ordering maintained while allowing regional independence
- Latency Handling: Configurable MaxDrift parameters account for network delays
- Quick Response: Optimized path for rapid timestamp acquisition
- Median Selection: Uses median timestamp from validators to prevent outliers
- Drift Checks: Validates timestamps against drift limits
- Consensus Module: Implements PBFT consensus for timestamp validation
- Region Manager: Handles geographic distribution and server assignment
- Fast Path: Provides optimized timestamp acquisition
- Network Layer: Manages P2P communication between validators
- Threshold Signatures: Requires f+1 valid signatures in a 3f+1 system
- Drift Protection: Rejects timestamps outside acceptable drift windows
- Byzantine Fault Tolerance: Maintains correctness with up to f Byzantine validators
- Request timestamp from timeserver network
- Include signed timestamp in transaction
- Blockchain enforces strict ordering based on timestamps
- Transactions must include valid timestamps
- Block producers must respect timestamp ordering
- Higher gas fees cannot override chronological order
regions:
- id: "us-east"
name: "US East"
servers: ["validator1", "validator2", "validator3"]
- id: "eu-west"
name: "Europe West"
servers: ["validator4", "validator5", "validator6"]consensus:
maxDrift: "100ms" # Maximum drift between validators
futureWindow: "500ms" # Maximum future timestamp allowed
minValidators: 4 # Minimum validators for consensus- Go 1.21 or later
- Protocol Buffers compiler (
protoc)- Mac:
brew install protobuf - Linux:
apt-get install protobuf-compiler - Or download from protobuf releases
- Mac:
- Go plugins for protocol buffers:
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
-
Generate gRPC code:
make proto
-
Build the timeserver:
make build
-
Run tests:
make test
- Configure validators and regions in
config.yaml - Start timeserver network:
./bin/timeserver -config config.yaml
The timeserver provides both gRPC and REST APIs:
service TimestampService {
rpc GetTimestamp(GetTimestampRequest) returns (GetTimestampResponse)
rpc VerifyTimestamp(VerifyTimestampRequest) returns (VerifyTimestampResponse)
rpc GetValidators(GetValidatorsRequest) returns (GetValidatorsResponse)
rpc GetStatus(GetStatusRequest) returns (GetStatusResponse)
}POST /v1/timestamp: Get new timestampPOST /v1/timestamp/verify: Verify timestampGET /v1/validators: List validatorsGET /v1/status: Get status
See CONTRIBUTING.md for details on our code of conduct and development process.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.