Juvix imports
module arch.node.engines.shard_messages;
import prelude open;
import arch.node.types.basics open;
import arch.node.types.identities open;
Shard Messages¶
These are the messages that the Shard engine can receive/respond to.
Message interface¶
type ShardMsg KVSKey KVSDatum :=
| ShardMsgKVSReadRequest (KVSReadRequestMsg KVSKey)
| ShardMsgKVSWrite (KVSWriteMsg KVSKey KVSDatum)
| ShardMsgKVSAcquireLock (KVSAcquireLockMsg KVSKey)
| ShardMsgKVSLockAcquired (KVSLockAcquiredMsg)
| ShardMsgKVSRead (KVSReadMsg KVSKey KVSDatum)
| ShardMsgUpdateSeenAll (UpdateSeenAllMsg);
Message sequence diagrams¶
Transaction lock and read flow¶
sequenceDiagram
participant WorkerEngine
participant Shard
participant Executor
participant Mempool
participant Consensus
WorkerEngine->>Shard: KVSAcquireLock
Shard->>WorkerEngine: KVSLockAcquired
Executor->>Shard: KVSReadRequest
Mempool->>Shard: UpdateSeenAll
Consensus->>Shard: AnchorChosen
Shard->>Executor: KVSRead
Executor->>Shard: KVSWrite
Message types¶
KVSReadRequestMsg
¶
Read request from an Executor Engine.
type KVSReadRequestMsg KVSKey :=
mkKVSReadRequestMsg@{
timestamp : TxFingerprint;
key : KVSKey;
actual : Bool;
};
Arguments
timestamp
- The logical timestamp identifying the transaction at which to read
key
- The key to read
actual
- True if value is actually needed, false if just cleaning up a lazy read
KVSWriteMsg
¶
Write request from an Executor Engine.
type KVSWriteMsg KVSKey KVSDatum :=
mkKVSWriteMsg@{
timestamp : TxFingerprint;
key : KVSKey;
datum : Option KVSDatum;
};
Arguments
timestamp
- The logical timestamp identifying the transaction in which to write
key
- The key to write to
datum
- The data to write, or
none
to indicate no write
UpdateSeenAllMsg
¶
Update about seen transactions from a Mempool Worker Engine.
type UpdateSeenAllMsg :=
mkUpdateSeenAllMsg@{
timestamp : TxFingerprint;
write : Bool;
};
Arguments
timestamp
- The logical timestamp at which to push the SeenAll value.
write
- Whether it is the
SeenAllReads
orSeenAllWrites
to update.
KVSAcquireLockMsg
¶
Request to acquire locks for transaction execution.
type KVSAcquireLockMsg KVSKey :=
mkKVSAcquireLockMsg@{
lazy_read_keys : Set KVSKey;
eager_read_keys : Set KVSKey;
will_write_keys : Set KVSKey;
may_write_keys : Set KVSKey;
worker : EngineID;
executor : EngineID;
timestamp : TxFingerprint;
};
Arguments
lazy_read_keys
- Keys this transaction may read (only send values read in response to
KVSReadRequest
s) eager_read_keys
- Keys this transaction will read (send values read as soon as possible)
will_write_keys
- Keys this transaction will write
may_write_keys
- Keys this transaction may write
worker
- The Worker Engine in charge of the transaction
executor
- The Executor for this transaction
timestamp
- Specifies the transaction affiliated with these locks
KVSLockAcquiredMsg
¶
Confirmation that locks were acquired.
type KVSLockAcquiredMsg :=
mkKVSLockAcquiredMsg@{
timestamp : TxFingerprint;
};
Arguments
timestamp
- The timestamp of the transaction which was locked.
KVSReadMsg
¶
Value read response to executor.
type KVSReadMsg KVSKey KVSDatum :=
mkKVSReadMsg@{
timestamp : TxFingerprint;
key : KVSKey;
data : KVSDatum;
};
Arguments
timestamp
- The timestamp of the transaction which was read.
key
- The key which was read.
data
- The the data read.
ShardMsg
¶
type ShardMsg KVSKey KVSDatum :=
| ShardMsgKVSReadRequest (KVSReadRequestMsg KVSKey)
| ShardMsgKVSWrite (KVSWriteMsg KVSKey KVSDatum)
| ShardMsgKVSAcquireLock (KVSAcquireLockMsg KVSKey)
| ShardMsgKVSLockAcquired (KVSLockAcquiredMsg)
| ShardMsgKVSRead (KVSReadMsg KVSKey KVSDatum)
| ShardMsgUpdateSeenAll (UpdateSeenAllMsg);