@rootzero/contracts 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Core.sol +1 -3
- package/Events.sol +2 -3
- package/blocks/Cursors.sol +34 -10
- package/blocks/Keys.sol +2 -0
- package/blocks/Schema.sol +4 -2
- package/blocks/Writers.sol +36 -5
- package/core/Calls.sol +5 -5
- package/core/Host.sol +25 -20
- package/docs/Schema.md +4 -2
- package/events/Introduction.sol +22 -0
- package/events/{Piped.sol → Rooted.sol} +3 -3
- package/package.json +1 -1
- package/peer/Pipe.sol +8 -8
- package/events/Governed.sol +0 -21
- package/events/Host.sol +0 -22
- package/interfaces/IHostDiscovery.sol +0 -16
package/Core.sol
CHANGED
|
@@ -7,14 +7,12 @@ pragma solidity ^0.8.33;
|
|
|
7
7
|
import { AccessControl } from "./core/Access.sol";
|
|
8
8
|
import { Balances } from "./core/Balances.sol";
|
|
9
9
|
import { RootZeroContext } from "./core/Context.sol";
|
|
10
|
-
import { Host } from "./core/Host.sol";
|
|
10
|
+
import { Host, IHostIntroduction } from "./core/Host.sol";
|
|
11
11
|
import { FailedCall, NodeCalls } from "./core/Calls.sol";
|
|
12
12
|
import { Payable } from "./core/Payable.sol";
|
|
13
13
|
import { Pipeline } from "./core/Pipeline.sol";
|
|
14
14
|
import { AssetAmount, AccountAsset, AccountAmount, HostAmount, HostAccountAsset, HostAccountAmount, Tx } from "./core/Types.sol";
|
|
15
15
|
import { Validator } from "./core/Validator.sol";
|
|
16
|
-
import { HostDiscovery } from "./core/Host.sol";
|
|
17
|
-
import { IHostDiscovery } from "./interfaces/IHostDiscovery.sol";
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
|
package/Events.sol
CHANGED
|
@@ -14,12 +14,11 @@ import { DebtEvent } from "./events/Debt.sol";
|
|
|
14
14
|
import { DepositEvent } from "./events/Deposit.sol";
|
|
15
15
|
import { AssetPositionEvent } from "./events/Position.sol";
|
|
16
16
|
import { EventEmitter } from "./events/Emitter.sol";
|
|
17
|
-
import {
|
|
18
|
-
import { HostAnnouncedEvent } from "./events/Host.sol";
|
|
17
|
+
import { IntroductionEvent } from "./events/Introduction.sol";
|
|
19
18
|
import { ListingEvent } from "./events/Listing.sol";
|
|
20
19
|
import { PeerEvent } from "./events/Peer.sol";
|
|
21
20
|
import { QueryEvent } from "./events/Query.sol";
|
|
22
|
-
import {
|
|
21
|
+
import { RootedEvent } from "./events/Rooted.sol";
|
|
23
22
|
import { SwapEvent } from "./events/Swap.sol";
|
|
24
23
|
import { WithdrawalEvent } from "./events/Withdraw.sol";
|
|
25
24
|
|
package/blocks/Cursors.sol
CHANGED
|
@@ -524,17 +524,28 @@ library Cursors {
|
|
|
524
524
|
|
|
525
525
|
/// @notice Encode a CONTEXT block.
|
|
526
526
|
/// @param account Command account identifier.
|
|
527
|
-
/// @param value Native value budget assigned to the context.
|
|
528
527
|
/// @param state Embedded state block stream.
|
|
529
528
|
/// @param request Embedded request block stream.
|
|
530
529
|
/// @return Encoded CONTEXT block bytes.
|
|
531
|
-
function toContextBlock(
|
|
532
|
-
|
|
530
|
+
function toContextBlock(bytes32 account, bytes memory state, bytes memory request) internal pure returns (bytes memory) {
|
|
531
|
+
return createBlock(Keys.Context, bytes.concat(account, toBytesBlock(state), toBytesBlock(request)));
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/// @notice Encode a RELAY block.
|
|
535
|
+
/// @param target Command target identifier.
|
|
536
|
+
/// @param value Native value assigned to the relay.
|
|
537
|
+
/// @param account Command account identifier.
|
|
538
|
+
/// @param state Embedded state block stream.
|
|
539
|
+
/// @param request Embedded request block stream.
|
|
540
|
+
/// @return Encoded RELAY block bytes.
|
|
541
|
+
function toRelayBlock(
|
|
542
|
+
uint target,
|
|
533
543
|
uint value,
|
|
544
|
+
bytes32 account,
|
|
534
545
|
bytes memory state,
|
|
535
546
|
bytes memory request
|
|
536
547
|
) internal pure returns (bytes memory) {
|
|
537
|
-
return createBlock(Keys.
|
|
548
|
+
return createBlock(Keys.Relay, bytes.concat(bytes32(target), bytes32(value), toContextBlock(account, state, request)));
|
|
538
549
|
}
|
|
539
550
|
|
|
540
551
|
// -------------------------------------------------------------------------
|
|
@@ -1091,20 +1102,33 @@ library Cursors {
|
|
|
1091
1102
|
/// The `state` and `request` slices are the raw payloads of the required BYTES children.
|
|
1092
1103
|
/// @param cur Cursor; advanced past the block.
|
|
1093
1104
|
/// @return account Command account identifier.
|
|
1094
|
-
/// @return value Native value budget assigned to the context.
|
|
1095
1105
|
/// @return state Embedded state block stream.
|
|
1096
1106
|
/// @return request Embedded request block stream.
|
|
1097
|
-
function unpackContext(
|
|
1098
|
-
|
|
1099
|
-
) internal pure returns (bytes32 account, uint value, bytes calldata state, bytes calldata request) {
|
|
1100
|
-
uint end = cur.enter(Keys.Context, 64 + 2 * Sizes.Header, 0);
|
|
1107
|
+
function unpackContext(Cur memory cur) internal pure returns (bytes32 account, bytes calldata state, bytes calldata request) {
|
|
1108
|
+
uint end = cur.enter(Keys.Context, 32 + 2 * Sizes.Header, 0);
|
|
1101
1109
|
account = cur.read32();
|
|
1102
|
-
value = uint(cur.read32());
|
|
1103
1110
|
state = cur.unpackBytes();
|
|
1104
1111
|
request = cur.unpackBytes();
|
|
1105
1112
|
cur.exit(end);
|
|
1106
1113
|
}
|
|
1107
1114
|
|
|
1115
|
+
/// @notice Consume a RELAY block and return its target, value, and context fields.
|
|
1116
|
+
/// @param cur Cursor; advanced past the block.
|
|
1117
|
+
/// @return target Destination command/node ID.
|
|
1118
|
+
/// @return value Native value assigned to the relay.
|
|
1119
|
+
/// @return account Command account identifier.
|
|
1120
|
+
/// @return state Embedded state block stream.
|
|
1121
|
+
/// @return request Embedded request block stream.
|
|
1122
|
+
function unpackRelay(
|
|
1123
|
+
Cur memory cur
|
|
1124
|
+
) internal pure returns (uint target, uint value, bytes32 account, bytes calldata state, bytes calldata request) {
|
|
1125
|
+
uint end = cur.enter(Keys.Relay, 64 + Sizes.Header + 32 + 2 * Sizes.Header, 0);
|
|
1126
|
+
target = uint(cur.read32());
|
|
1127
|
+
value = uint(cur.read32());
|
|
1128
|
+
(account, state, request) = cur.unpackContext();
|
|
1129
|
+
cur.exit(end);
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1108
1132
|
// Type-specific validators
|
|
1109
1133
|
|
|
1110
1134
|
/// @notice Validate an AUTH block at position `i` and extract deadline and proof.
|
package/blocks/Keys.sol
CHANGED
|
@@ -43,6 +43,8 @@ library Keys {
|
|
|
43
43
|
bytes4 constant Call = bytes4(keccak256("#call"));
|
|
44
44
|
/// @dev Command context transport - (bytes32 account, #bytes as state, #bytes as request)
|
|
45
45
|
bytes4 constant Context = bytes4(keccak256("#context"));
|
|
46
|
+
/// @dev Pipeline relay - (uint target, uint value, #context)
|
|
47
|
+
bytes4 constant Relay = bytes4(keccak256("#relay"));
|
|
46
48
|
/// @dev Authentication proof - (uint cid, uint deadline, #bytes as proof); must appear last in its segment
|
|
47
49
|
bytes4 constant Auth = bytes4(keccak256("#auth"));
|
|
48
50
|
/// @dev Asset descriptor without amount - (bytes32 asset, bytes32 meta)
|
package/blocks/Schema.sol
CHANGED
|
@@ -59,9 +59,10 @@ library Schemas {
|
|
|
59
59
|
string constant Allocation = "#allocation { uint host, bytes32 asset, bytes32 meta, uint amount }";
|
|
60
60
|
string constant Allowance = "#allowance { uint host, bytes32 asset, bytes32 meta, uint amount }";
|
|
61
61
|
string constant Transaction = "#transaction { bytes32 from, bytes32 to, bytes32 asset, bytes32 meta, uint amount }";
|
|
62
|
+
string constant Context = "#context { bytes32 account, #bytes as state, #bytes as request }";
|
|
63
|
+
string constant Relay = "#relay { uint target, uint value, #context { bytes32 account, #bytes as state, #bytes as request } }";
|
|
62
64
|
string constant Call = "#call { uint target, uint value, #bytes as payload }";
|
|
63
65
|
string constant Step = "#step { uint target, uint value, #bytes as request }";
|
|
64
|
-
string constant Context = "#context { bytes32 account, uint value, #bytes as state, #bytes as request }";
|
|
65
66
|
string constant Bounty = "#bounty { uint amount, bytes32 relayer }";
|
|
66
67
|
string constant Fee = "#fee { uint amount }";
|
|
67
68
|
string constant Auth = "#auth { uint cid, uint deadline, #bytes as proof }";
|
|
@@ -81,7 +82,8 @@ library Forms {
|
|
|
81
82
|
string constant AccountAmount = "#accountAmount { bytes32 account, bytes32 asset, bytes32 meta, uint amount }";
|
|
82
83
|
string constant HostAmount = "#hostAmount { uint host, bytes32 asset, bytes32 meta, uint amount }";
|
|
83
84
|
string constant HostAccountAsset = "#hostAccountAsset { uint host, bytes32 account, bytes32 asset, bytes32 meta }";
|
|
84
|
-
string constant HostAccountAmount =
|
|
85
|
+
string constant HostAccountAmount =
|
|
86
|
+
"#hostAccountAmount { uint host, bytes32 account, bytes32 asset, bytes32 meta, uint amount }";
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
/// @title Sizes
|
package/blocks/Writers.sol
CHANGED
|
@@ -27,6 +27,7 @@ library Hints {
|
|
|
27
27
|
uint constant Step = 256;
|
|
28
28
|
uint constant Call = 256;
|
|
29
29
|
uint constant Context = 512;
|
|
30
|
+
uint constant Relay = 640;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/// @title Writers
|
|
@@ -223,6 +224,14 @@ library Writers {
|
|
|
223
224
|
return allocFromHint(count, Hints.Context);
|
|
224
225
|
}
|
|
225
226
|
|
|
227
|
+
/// @notice Allocate a writer for `count` RELAY blocks using a per-block capacity hint.
|
|
228
|
+
/// @dev The backing buffer expands automatically if encoded relays exceed the initial hint.
|
|
229
|
+
/// @param count Number of relay blocks to allocate space for.
|
|
230
|
+
/// @return writer Allocated growable writer.
|
|
231
|
+
function allocRelays(uint count) internal pure returns (Writer memory writer) {
|
|
232
|
+
return allocFromHint(count, Hints.Relay);
|
|
233
|
+
}
|
|
234
|
+
|
|
226
235
|
// -------------------------------------------------------------------------
|
|
227
236
|
// Fixed-width write helpers
|
|
228
237
|
// -------------------------------------------------------------------------
|
|
@@ -871,20 +880,42 @@ library Writers {
|
|
|
871
880
|
appendBlock64Bytes(writer, Keys.Call, bytes32(target), bytes32(value), data);
|
|
872
881
|
}
|
|
873
882
|
|
|
874
|
-
/// @notice Append a CONTEXT block with
|
|
883
|
+
/// @notice Append a CONTEXT block with nested state/request BYTES payloads.
|
|
875
884
|
/// @param writer Destination writer; `i` is advanced by the encoded CONTEXT block length.
|
|
876
885
|
/// @param account Command account identifier.
|
|
877
|
-
/// @param value Native value budget assigned to the context.
|
|
878
886
|
/// @param state Raw nested state payload.
|
|
879
887
|
/// @param request Raw nested request payload.
|
|
880
|
-
function appendContext(
|
|
888
|
+
function appendContext(Writer memory writer, bytes32 account, bytes memory state, bytes memory request) internal pure {
|
|
889
|
+
appendBlock32BytesBytes(writer, Keys.Context, account, state, request);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/// @notice Append a RELAY block with a nested CONTEXT block.
|
|
893
|
+
/// @param writer Destination writer; `i` is advanced by the encoded RELAY block length.
|
|
894
|
+
/// @param target Command target identifier.
|
|
895
|
+
/// @param value Native value assigned to the relay.
|
|
896
|
+
/// @param account Command account identifier.
|
|
897
|
+
/// @param state Raw nested state payload.
|
|
898
|
+
/// @param request Raw nested request payload.
|
|
899
|
+
function appendRelay(
|
|
881
900
|
Writer memory writer,
|
|
882
|
-
|
|
901
|
+
uint target,
|
|
883
902
|
uint value,
|
|
903
|
+
bytes32 account,
|
|
884
904
|
bytes memory state,
|
|
885
905
|
bytes memory request
|
|
886
906
|
) internal pure {
|
|
887
|
-
|
|
907
|
+
uint i = writer.i;
|
|
908
|
+
uint len = 96 + 3 * Sizes.Header + state.length + request.length;
|
|
909
|
+
uint next = i + Sizes.Header + len;
|
|
910
|
+
i = reserve(writer, next, next);
|
|
911
|
+
|
|
912
|
+
uint p = writeHeader(writer.dst, i, Keys.Relay, uint32(max32(len)));
|
|
913
|
+
assembly ("memory-safe") {
|
|
914
|
+
mstore(add(p, 0x08), target)
|
|
915
|
+
mstore(add(p, 0x28), value)
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
writeBlock32BytesBytes(writer.dst, i + Sizes.Header + 64, Keys.Context, account, state, request);
|
|
888
919
|
}
|
|
889
920
|
|
|
890
921
|
/// @notice Append a STATUS form block.
|
package/core/Calls.sol
CHANGED
|
@@ -72,13 +72,13 @@ abstract contract NodeCalls is AccessControl {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/// @notice Encode and call a trusted command node.
|
|
75
|
-
/// @param
|
|
76
|
-
/// @param cid Command node ID embedding the target selector.
|
|
75
|
+
/// @param id Command node ID embedding the target selector.
|
|
77
76
|
/// @param value Native value to forward in wei.
|
|
77
|
+
/// @param ctx Command execution context.
|
|
78
78
|
/// @return Decoded command output block stream.
|
|
79
|
-
function callCommand(
|
|
80
|
-
bytes4 selector = Ids.commandSelector(
|
|
79
|
+
function callCommand(uint id, uint value, CommandContext memory ctx) internal returns (bytes memory) {
|
|
80
|
+
bytes4 selector = Ids.commandSelector(id);
|
|
81
81
|
bytes memory data = abi.encodeWithSelector(selector, ctx);
|
|
82
|
-
return abi.decode(callTo(
|
|
82
|
+
return abi.decode(callTo(id, value, data), (bytes));
|
|
83
83
|
}
|
|
84
84
|
}
|
package/core/Host.sol
CHANGED
|
@@ -5,38 +5,43 @@ import {AccessControl} from "./Access.sol";
|
|
|
5
5
|
import {Authorize} from "../commands/admin/Authorize.sol";
|
|
6
6
|
import {Unauthorize} from "../commands/admin/Unauthorize.sol";
|
|
7
7
|
import {ExecutePayable} from "../commands/admin/Execute.sol";
|
|
8
|
-
import {
|
|
9
|
-
import {IHostDiscovery} from "../interfaces/IHostDiscovery.sol";
|
|
10
|
-
import {Ids} from "../utils/Ids.sol";
|
|
8
|
+
import {IntroductionEvent} from "../events/Introduction.sol";
|
|
11
9
|
|
|
12
|
-
/// @
|
|
13
|
-
///
|
|
14
|
-
|
|
15
|
-
/// @notice
|
|
16
|
-
///
|
|
17
|
-
/// @param
|
|
18
|
-
/// @param
|
|
19
|
-
/// @param
|
|
20
|
-
|
|
21
|
-
function announceHost(uint id, uint blocknum, uint16 version, string calldata namespace) external {
|
|
22
|
-
emit HostAnnounced(Ids.matchHost(id, msg.sender), blocknum, version, namespace);
|
|
23
|
-
}
|
|
10
|
+
/// @title IHostIntroduction
|
|
11
|
+
/// @notice Interface implemented by hosts that accept introductions from other hosts.
|
|
12
|
+
interface IHostIntroduction {
|
|
13
|
+
/// @notice Record a host introduction claim.
|
|
14
|
+
/// @param peer Host node ID being introduced.
|
|
15
|
+
/// @param blocknum Block number at which the introduction was made.
|
|
16
|
+
/// @param version Protocol version the host is running.
|
|
17
|
+
/// @param namespace Human-readable namespace or label for the host.
|
|
18
|
+
function introduce(uint peer, uint blocknum, uint16 version, string calldata namespace) external;
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
/// @title Host
|
|
27
22
|
/// @notice Abstract base contract for rootzero host implementations.
|
|
28
23
|
/// Inherits admin command support (authorize, unauthorize, executePayable) and
|
|
29
|
-
/// optionally
|
|
24
|
+
/// optionally introduces itself to a commander host at deployment.
|
|
30
25
|
/// Accepts native ETH payments via the `receive` function.
|
|
31
|
-
abstract contract Host is Authorize, Unauthorize, ExecutePayable {
|
|
26
|
+
abstract contract Host is Authorize, Unauthorize, ExecutePayable, IntroductionEvent, IHostIntroduction {
|
|
32
27
|
/// @param cmdr Commander address; passed to `AccessControl`.
|
|
33
|
-
/// If `cmdr` is a deployed contract, the host calls `
|
|
34
|
-
/// on it during construction
|
|
28
|
+
/// If `cmdr` is a deployed contract, the host calls `introduce`
|
|
29
|
+
/// on it during construction.
|
|
35
30
|
/// @param version Protocol version number to publish in the announcement.
|
|
36
31
|
/// @param namespace Human-readable namespace string for the host.
|
|
37
32
|
constructor(address cmdr, uint16 version, string memory namespace) AccessControl(cmdr) {
|
|
38
33
|
if (cmdr == address(0) || cmdr == address(this) || cmdr.code.length == 0) return;
|
|
39
|
-
|
|
34
|
+
IHostIntroduction(cmdr).introduce(host, block.number, version, namespace);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// @notice Record a host introduction claim.
|
|
38
|
+
/// @dev This event is informational only; it does not authorize or trust the introduced host.
|
|
39
|
+
/// @param peer Host node ID being introduced.
|
|
40
|
+
/// @param blocknum Block number at which the host was deployed.
|
|
41
|
+
/// @param version Protocol version the host implements.
|
|
42
|
+
/// @param namespace Human-readable namespace string for the host.
|
|
43
|
+
function introduce(uint peer, uint blocknum, uint16 version, string calldata namespace) external {
|
|
44
|
+
emit Introduction(peer, blocknum, version, namespace);
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
/// @notice Accept native ETH transfers (e.g. from command value flows).
|
package/docs/Schema.md
CHANGED
|
@@ -57,7 +57,8 @@ Once a child block appears, no more fixed fields may follow.
|
|
|
57
57
|
|
|
58
58
|
```txt
|
|
59
59
|
#call { uint target, uint value, #bytes as payload }
|
|
60
|
-
#context { bytes32 account,
|
|
60
|
+
#context { bytes32 account, #bytes as state, #bytes as request }
|
|
61
|
+
#relay { uint target, uint value, #context { bytes32 account, #bytes as state, #bytes as request } }
|
|
61
62
|
```
|
|
62
63
|
|
|
63
64
|
The tail is embedded directly as child block bytes. There is no wrapper around a
|
|
@@ -187,7 +188,8 @@ Common protocol schemas live in `contracts/blocks/Schema.sol`:
|
|
|
187
188
|
#payout { bytes32 account, bytes32 asset, bytes32 meta, uint amount }
|
|
188
189
|
#call { uint target, uint value, #bytes as payload }
|
|
189
190
|
#step { uint target, uint value, #bytes as request }
|
|
190
|
-
#context { bytes32 account,
|
|
191
|
+
#context { bytes32 account, #bytes as state, #bytes as request }
|
|
192
|
+
#relay { uint target, uint value, #context { bytes32 account, #bytes as state, #bytes as request } }
|
|
191
193
|
#auth { uint cid, uint deadline, #bytes as proof }
|
|
192
194
|
```
|
|
193
195
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
pragma solidity ^0.8.33;
|
|
3
|
+
|
|
4
|
+
import { EventEmitter } from "./Emitter.sol";
|
|
5
|
+
|
|
6
|
+
string constant ABI = "event Introduction(uint indexed host, uint blocknum, uint16 version, string namespace)";
|
|
7
|
+
|
|
8
|
+
/// @notice Emitted when a host introduces itself to another host.
|
|
9
|
+
abstract contract IntroductionEvent is EventEmitter {
|
|
10
|
+
/// @param host Host node ID of the introducing contract.
|
|
11
|
+
/// @param blocknum Block number at which the host was deployed.
|
|
12
|
+
/// @param version Protocol version the host implements.
|
|
13
|
+
/// @param namespace Human-readable namespace string for the host.
|
|
14
|
+
event Introduction(uint indexed host, uint blocknum, uint16 version, string namespace);
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
emit EventAbi(ABI);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
@@ -3,14 +3,14 @@ pragma solidity ^0.8.33;
|
|
|
3
3
|
|
|
4
4
|
import { EventEmitter } from "./Emitter.sol";
|
|
5
5
|
|
|
6
|
-
string constant ABI = "event
|
|
6
|
+
string constant ABI = "event Rooted(bytes32 indexed account, uint deadline, uint value)";
|
|
7
7
|
|
|
8
8
|
/// @notice Emitted for root-level protocol actions (e.g. governance or protocol-wide operations).
|
|
9
|
-
abstract contract
|
|
9
|
+
abstract contract RootedEvent is EventEmitter {
|
|
10
10
|
/// @param account Account identifier associated with the action.
|
|
11
11
|
/// @param deadline Expiry timestamp of the action.
|
|
12
12
|
/// @param value Native value associated with the action.
|
|
13
|
-
event
|
|
13
|
+
event Rooted(bytes32 indexed account, uint deadline, uint value);
|
|
14
14
|
|
|
15
15
|
constructor() {
|
|
16
16
|
emit EventAbi(ABI);
|
package/package.json
CHANGED
package/peer/Pipe.sol
CHANGED
|
@@ -9,26 +9,26 @@ import {Budget} from "../utils/Value.sol";
|
|
|
9
9
|
using Cursors for Cur;
|
|
10
10
|
|
|
11
11
|
/// @title PeerPipePayable
|
|
12
|
-
/// @notice Peer that consumes
|
|
13
|
-
/// Each
|
|
14
|
-
/// shared pipeline as the step stream.
|
|
12
|
+
/// @notice Peer that consumes RELAY blocks and executes each context request as a STEP stream.
|
|
13
|
+
/// Each RELAY block carries a value budget plus a CONTEXT block; the relay target is ignored
|
|
14
|
+
/// and the nested context request is passed to the shared pipeline as the step stream.
|
|
15
15
|
abstract contract PeerPipePayable is PeerBase, Pipeline {
|
|
16
16
|
string private constant NAME = "peerPipePayable";
|
|
17
17
|
uint internal immutable peerPipePayableId = peerId(NAME);
|
|
18
18
|
|
|
19
19
|
constructor() {
|
|
20
|
-
emit Peer(host, peerPipePayableId, NAME, "1:0", Schemas.
|
|
20
|
+
emit Peer(host, peerPipePayableId, NAME, "1:0", Schemas.Relay, "", true);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
/// @notice Execute peer-supplied
|
|
24
|
-
/// @dev Each
|
|
25
|
-
/// `msg.value` not assigned to a
|
|
23
|
+
/// @notice Execute peer-supplied relays through the shared payable pipe.
|
|
24
|
+
/// @dev Each relay receives its own explicit value sub-budget. Any top-level
|
|
25
|
+
/// `msg.value` not assigned to a relay remains on this host.
|
|
26
26
|
function peerPipePayable(bytes calldata request) external payable onlyPeer returns (bytes memory) {
|
|
27
27
|
(Cur memory input, ) = cursor(request, 1);
|
|
28
28
|
Budget memory budget = valueBudget();
|
|
29
29
|
|
|
30
30
|
while (input.i < input.bound) {
|
|
31
|
-
(
|
|
31
|
+
(, uint value, bytes32 account, bytes calldata state, bytes calldata steps) = input.unpackRelay();
|
|
32
32
|
pipe(account, state, steps, allocateValue(budget, value));
|
|
33
33
|
}
|
|
34
34
|
|
package/events/Governed.sol
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
-
pragma solidity ^0.8.33;
|
|
3
|
-
|
|
4
|
-
import { EventEmitter } from "./Emitter.sol";
|
|
5
|
-
|
|
6
|
-
string constant ABI = "event Governed(uint indexed host, uint deadline, uint value)";
|
|
7
|
-
|
|
8
|
-
/// @notice Emitted when a governance action is recorded on a host.
|
|
9
|
-
abstract contract GovernedEvent is EventEmitter {
|
|
10
|
-
/// @param host Host node ID where the governance action occurred.
|
|
11
|
-
/// @param deadline Expiry timestamp of the governance action.
|
|
12
|
-
/// @param value Native value associated with the action.
|
|
13
|
-
event Governed(uint indexed host, uint deadline, uint value);
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
emit EventAbi(ABI);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
package/events/Host.sol
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
-
pragma solidity ^0.8.33;
|
|
3
|
-
|
|
4
|
-
import { EventEmitter } from "./Emitter.sol";
|
|
5
|
-
|
|
6
|
-
string constant ABI = "event HostAnnounced(uint indexed host, uint blocknum, uint16 version, string namespace)";
|
|
7
|
-
|
|
8
|
-
/// @notice Emitted by the discovery contract when a host registers itself.
|
|
9
|
-
abstract contract HostAnnouncedEvent is EventEmitter {
|
|
10
|
-
/// @param host Host node ID of the registering contract.
|
|
11
|
-
/// @param blocknum Block number at which the host was deployed.
|
|
12
|
-
/// @param version Protocol version the host implements.
|
|
13
|
-
/// @param namespace Human-readable namespace string for the host.
|
|
14
|
-
event HostAnnounced(uint indexed host, uint blocknum, uint16 version, string namespace);
|
|
15
|
-
|
|
16
|
-
constructor() {
|
|
17
|
-
emit EventAbi(ABI);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
-
pragma solidity ^0.8.33;
|
|
3
|
-
|
|
4
|
-
/// @title IHostDiscovery
|
|
5
|
-
/// @notice Interface implemented by a discovery registry that hosts announce themselves to.
|
|
6
|
-
interface IHostDiscovery {
|
|
7
|
-
/// @notice Register or refresh a host entry in the discovery registry.
|
|
8
|
-
/// @param id Host node ID.
|
|
9
|
-
/// @param blocknum Block number at which the announcement was made.
|
|
10
|
-
/// @param version Protocol version the host is running.
|
|
11
|
-
/// @param namespace Human-readable namespace or label for the host.
|
|
12
|
-
function announceHost(uint id, uint blocknum, uint16 version, string calldata namespace) external;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|