Skip to content

Commit 551ec95

Browse files
M02: per-entrypoint context word columns (WIP phase 3)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 172d052 commit 551ec95

27 files changed

Lines changed: 641 additions & 534 deletions

‎crates/test_fixtures/abis/RaindexV6.json‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎crates/test_fixtures/abis/RaindexV6SubParser.json‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎meta/RaindexV6SubParser.rain.meta‎

-8 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

‎src/concrete/parser/RaindexV6SubParser.sol‎

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {LibUint256Matrix} from "rain-solmem-0.1.28/src/lib/LibUint256Matrix.sol"
1414
import {
1515
LibRaindexSubParser,
1616
SUB_PARSER_WORD_PARSERS_LENGTH,
17+
BASE_WORD_RAINDEX,
18+
BASE_WORDS_LENGTH,
1719
DEPOSIT_WORD_VAULT_ID,
1820
DEPOSIT_WORD_TOKEN,
1921
DEPOSIT_WORD_DEPOSITOR,
@@ -30,12 +32,7 @@ import {
3032
WITHDRAW_WORD_TOKEN_DECIMALS,
3133
WITHDRAW_WORDS_LENGTH
3234
} from "../../lib/LibRaindexSubParser.sol";
33-
import {
34-
CONTEXT_BASE_COLUMN,
35-
CONTEXT_BASE_ROW_SENDER,
36-
CONTEXT_BASE_ROW_CALLING_CONTRACT,
37-
CONTEXT_BASE_ROWS
38-
} from "rainlang-interface-0.2.13/src/lib/caller/LibContext.sol";
35+
import {CONTEXT_BASE_COLUMN} from "rainlang-interface-0.2.13/src/lib/caller/LibContext.sol";
3936
import {
4037
CONTEXT_COLUMNS_EXTENDED,
4138
CONTEXT_VAULT_OUTPUTS_COLUMN,
@@ -51,6 +48,9 @@ import {
5148
CONTEXT_CALCULATIONS_ROW_MAX_OUTPUT,
5249
CONTEXT_CALCULATIONS_ROWS,
5350
CONTEXT_CALLING_CONTEXT_ROW_ORDER_COUNTERPARTY,
51+
CONTEXT_CALLING_CONTEXT_ROW_ORDER_CLEARER,
52+
CONTEXT_DEPOSIT_COLUMN,
53+
CONTEXT_WITHDRAW_COLUMN,
5454
CONTEXT_CALLING_CONTEXT_ROW_ORDER_OWNER,
5555
CONTEXT_CALLING_CONTEXT_ROW_ORDER_HASH,
5656
CONTEXT_CALLING_CONTEXT_ROWS,
@@ -72,8 +72,8 @@ import {IDescribedByMetaV1} from "rain-metadata-0.1.43/src/interface/IDescribedB
7272
import {ISubParserToolingV1} from "rain-sol-codegen-0.1.39/src/interface/ISubParserToolingV1.sol";
7373

7474
/// @title RaindexV6SubParser
75-
/// @notice Sub-parser that provides raindex-specific context words (sender,
76-
/// order hash, vault IO, deposit/withdraw, signed context, etc.) to the
75+
/// @notice Sub-parser that provides raindex-specific context words (raindex,
76+
/// order hash, clearer, vault IO, deposit/withdraw, signed context, etc.) to the
7777
/// Rain interpreter.
7878
contract RaindexV6SubParser is BaseRainlangSubParser {
7979
using LibUint256Matrix for uint256[][];
@@ -109,16 +109,17 @@ contract RaindexV6SubParser is BaseRainlangSubParser {
109109
new function(bytes32[] memory) internal pure returns (OperandV2)[][](CONTEXT_COLUMNS_EXTENDED);
110110

111111
function(bytes32[] memory) internal pure returns (OperandV2)[] memory contextBaseHandlers =
112-
new function(bytes32[] memory) internal pure returns (OperandV2)[](CONTEXT_BASE_ROWS);
113-
contextBaseHandlers[CONTEXT_BASE_ROW_SENDER] = LibParseOperand.handleOperandDisallowed;
114-
contextBaseHandlers[CONTEXT_BASE_ROW_CALLING_CONTRACT] = LibParseOperand.handleOperandDisallowed;
112+
new function(bytes32[] memory) internal pure returns (OperandV2)[](BASE_WORDS_LENGTH);
113+
contextBaseHandlers[BASE_WORD_RAINDEX] = LibParseOperand.handleOperandDisallowed;
115114

116115
function(bytes32[] memory) internal pure returns (OperandV2)[] memory contextCallingContextHandlers =
117116
new function(bytes32[] memory) internal pure returns (OperandV2)[](CONTEXT_CALLING_CONTEXT_ROWS);
118117
contextCallingContextHandlers[CONTEXT_CALLING_CONTEXT_ROW_ORDER_HASH] = LibParseOperand.handleOperandDisallowed;
119118
contextCallingContextHandlers[CONTEXT_CALLING_CONTEXT_ROW_ORDER_OWNER] = LibParseOperand.handleOperandDisallowed;
120119
contextCallingContextHandlers[CONTEXT_CALLING_CONTEXT_ROW_ORDER_COUNTERPARTY] =
121120
LibParseOperand.handleOperandDisallowed;
121+
contextCallingContextHandlers[CONTEXT_CALLING_CONTEXT_ROW_ORDER_CLEARER] =
122+
LibParseOperand.handleOperandDisallowed;
122123

123124
function(bytes32[] memory) internal pure returns (OperandV2)[] memory contextCalculationsHandlers =
124125
new function(bytes32[] memory) internal pure returns (OperandV2)[](CONTEXT_CALCULATIONS_ROWS);
@@ -167,7 +168,7 @@ contract RaindexV6SubParser is BaseRainlangSubParser {
167168
contextDepositContextHandlers[DEPOSIT_WORD_VAULT_AFTER] = LibParseOperand.handleOperandDisallowed;
168169
contextDepositContextHandlers[DEPOSIT_WORD_TOKEN_DECIMALS] = LibParseOperand.handleOperandDisallowed;
169170

170-
handlers[CONTEXT_SIGNED_CONTEXT_START_COLUMN + 1] = contextDepositContextHandlers;
171+
handlers[CONTEXT_DEPOSIT_COLUMN] = contextDepositContextHandlers;
171172

172173
function(bytes32[] memory) internal pure returns (OperandV2)[] memory contextWithdrawContextHandlers =
173174
new function(bytes32[] memory) internal pure returns (OperandV2)[](WITHDRAW_WORDS_LENGTH);
@@ -179,7 +180,7 @@ contract RaindexV6SubParser is BaseRainlangSubParser {
179180
contextWithdrawContextHandlers[WITHDRAW_WORD_TARGET_AMOUNT] = LibParseOperand.handleOperandDisallowed;
180181
contextWithdrawContextHandlers[WITHDRAW_WORD_TOKEN_DECIMALS] = LibParseOperand.handleOperandDisallowed;
181182

182-
handlers[CONTEXT_SIGNED_CONTEXT_START_COLUMN + 2] = contextWithdrawContextHandlers;
183+
handlers[CONTEXT_WITHDRAW_COLUMN] = contextWithdrawContextHandlers;
183184

184185
uint256[][] memory handlersUint256;
185186
assembly ("memory-safe") {
@@ -201,9 +202,8 @@ contract RaindexV6SubParser is BaseRainlangSubParser {
201202
contextBaseParsers =
202203
new function(uint256, uint256, OperandV2)
203204
internal
204-
view returns (bool, bytes memory, bytes32[] memory)[](CONTEXT_BASE_ROWS);
205-
contextBaseParsers[CONTEXT_BASE_ROW_SENDER] = LibRaindexSubParser.subParserSender;
206-
contextBaseParsers[CONTEXT_BASE_ROW_CALLING_CONTRACT] = LibRaindexSubParser.subParserCallingContract;
205+
view returns (bool, bytes memory, bytes32[] memory)[](BASE_WORDS_LENGTH);
206+
contextBaseParsers[BASE_WORD_RAINDEX] = LibRaindexSubParser.subParserCallingContract;
207207

208208
function(uint256, uint256, OperandV2) internal view returns (bool, bytes memory, bytes32[] memory)[] memory
209209
contextCallingContextParsers =
@@ -214,6 +214,8 @@ contract RaindexV6SubParser is BaseRainlangSubParser {
214214
contextCallingContextParsers[CONTEXT_CALLING_CONTEXT_ROW_ORDER_OWNER] = LibRaindexSubParser.subParserOrderOwner;
215215
contextCallingContextParsers[CONTEXT_CALLING_CONTEXT_ROW_ORDER_COUNTERPARTY] =
216216
LibRaindexSubParser.subParserOrderCounterparty;
217+
contextCallingContextParsers[CONTEXT_CALLING_CONTEXT_ROW_ORDER_CLEARER] =
218+
LibRaindexSubParser.subParserOrderClearer;
217219

218220
function(uint256, uint256, OperandV2) internal view returns (bool, bytes memory, bytes32[] memory)[] memory
219221
contextCalculationsParsers =
@@ -275,14 +277,14 @@ contract RaindexV6SubParser is BaseRainlangSubParser {
275277
internal
276278
view returns (bool, bytes memory, bytes32[] memory)[](DEPOSIT_WORDS_LENGTH);
277279

278-
depositParsers[DEPOSIT_WORD_DEPOSITOR] = LibRaindexSubParser.subParserSender;
280+
depositParsers[DEPOSIT_WORD_DEPOSITOR] = LibRaindexSubParser.subParserDepositor;
279281
depositParsers[DEPOSIT_WORD_TOKEN] = LibRaindexSubParser.subParserDepositToken;
280282
depositParsers[DEPOSIT_WORD_VAULT_ID] = LibRaindexSubParser.subParserDepositVaultId;
281283
depositParsers[DEPOSIT_WORD_VAULT_BEFORE] = LibRaindexSubParser.subParserDepositVaultBalanceBefore;
282284
depositParsers[DEPOSIT_WORD_VAULT_AFTER] = LibRaindexSubParser.subParserDepositVaultBalanceAfter;
283285
depositParsers[DEPOSIT_WORD_TOKEN_DECIMALS] = LibRaindexSubParser.subParserDepositTokenDecimals;
284286

285-
parsers[CONTEXT_SIGNED_CONTEXT_START_COLUMN + 1] = depositParsers;
287+
parsers[CONTEXT_DEPOSIT_COLUMN] = depositParsers;
286288

287289
// Withdraws
288290

@@ -292,15 +294,15 @@ contract RaindexV6SubParser is BaseRainlangSubParser {
292294
internal
293295
view returns (bool, bytes memory, bytes32[] memory)[](WITHDRAW_WORDS_LENGTH);
294296

295-
withdrawParsers[WITHDRAW_WORD_WITHDRAWER] = LibRaindexSubParser.subParserSender;
297+
withdrawParsers[WITHDRAW_WORD_WITHDRAWER] = LibRaindexSubParser.subParserWithdrawer;
296298
withdrawParsers[WITHDRAW_WORD_TOKEN] = LibRaindexSubParser.subParserWithdrawToken;
297299
withdrawParsers[WITHDRAW_WORD_VAULT_ID] = LibRaindexSubParser.subParserWithdrawVaultId;
298300
withdrawParsers[WITHDRAW_WORD_VAULT_BEFORE] = LibRaindexSubParser.subParserWithdrawVaultBalanceBefore;
299301
withdrawParsers[WITHDRAW_WORD_VAULT_AFTER] = LibRaindexSubParser.subParserWithdrawVaultBalanceAfter;
300302
withdrawParsers[WITHDRAW_WORD_TARGET_AMOUNT] = LibRaindexSubParser.subParserWithdrawTargetAmount;
301303
withdrawParsers[WITHDRAW_WORD_TOKEN_DECIMALS] = LibRaindexSubParser.subParserWithdrawTokenDecimals;
302304

303-
parsers[CONTEXT_SIGNED_CONTEXT_START_COLUMN + 2] = withdrawParsers;
305+
parsers[CONTEXT_WITHDRAW_COLUMN] = withdrawParsers;
304306

305307
uint256[][] memory parsersUint256;
306308
assembly ("memory-safe") {

‎src/concrete/raindex/RaindexV6.sol‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ contract RaindexV6 is IRaindexV6, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
314314
function _doOrderPost(bytes32 orderHash, TaskV2[] calldata post) internal {
315315
LibRaindex.doPost(
316316
LibRaindex.callingContextColumn(
317-
CONTEXT_CALLING_CONTEXT_COLUMN, LibBytes32Array.arrayFrom(orderHash, bytes32(uint256(uint160(msg.sender))))
317+
CONTEXT_CALLING_CONTEXT_COLUMN,
318+
LibBytes32Array.arrayFrom(orderHash, bytes32(uint256(uint160(msg.sender))))
318319
),
319320
post
320321
);

‎src/generated/RaindexV6SubParserPointers.sol‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ pragma solidity ^0.8.25;
55
// THIS FILE IS AUTOGENERATED BY THE BUILD SCRIPT. DO NOT EDIT BY HAND.
66

77
/// @dev Hash of the known bytecode.
8-
bytes32 constant BYTECODE_HASH = bytes32(0xb5f18596862c369ecb1bc3cf69399785a578427214d9372d94d0fde2ed0ecaeb);
8+
bytes32 constant BYTECODE_HASH = bytes32(0xb1b4649132a7ad03265562c1a423ea9c47c1c19d24882c98827e8f5c9b3fd439);
99

1010
/// @dev The hash of the meta that describes the contract.
11-
bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xf2d0eca454c544ab10f9991c019349475a416e38494f112a50807174c3000d0b);
11+
bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xe43208b51e17b3d887e8f3535d75526c0744eee6a200dac603462c6b3ca46511);
1212

1313
/// @dev The parse meta that is used to lookup word definitions.
1414
/// The structure of the parse meta is:
@@ -27,7 +27,7 @@ bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xf2d0eca454c544ab10f9991c0193
2727
/// bit count of the previous bloom filter. If we reach the end of the bloom
2828
/// filters then we have a miss.
2929
bytes constant PARSE_META =
30-
hex"0101180010800082000100010480300038412a001810000010020004200004002038038ff54900cc66c61ff3dcab0616592209895f0b16fec9301b02e0920c5bfe561d21609201e959460b1974270f844db208bcd3bf1e989376111049db13b934301a0ae9a00af82a7805c138f40d28083f0742ef2104d561fd1415a13317716a6119d260cc107b9bfc0eec7ade15cba2891c6b14a512792bdb02e0f14718565589";
30+
hex"0101180010800082000100010480300038412a001810000010020004200004002038028ff54904cc66c61df3dcab0616592209895f0b14fec9301902e0920c5bfe561b21609200e959460b1974270f844db208bcd3bf1c9893761e1049db11b93430180ae9a00af82a7805c138f40d28083f0742ef2103d561fd1215a13315716a6117d260cc107b9bfc0eec7ade13cba2891a6b14a51f792bdb01e0f14716565589";
3131

3232
/// @dev The build depth of the parser meta.
3333

@@ -39,13 +39,13 @@ uint8 constant PARSE_META_BUILD_DEPTH = 1;
3939
/// to things that happen entirely on the interpreter such as well known
4040
/// constants and references to the context grid.
4141
bytes constant SUB_PARSER_WORD_PARSERS =
42-
hex"16cc16e916f8170717161726173517451754176417741783179317a217b217c217d217e117f016cc16f8170717161825183516cc16f817071716182518351845";
42+
hex"168216a016af16be16ce16de16ed16fd170c171c172c173b174b175a176a177a178a17da17e917f81808181818281838184718561866187618861896179917a8";
4343

4444
/// @dev Every two bytes is a function pointer for an operand handler.
4545
/// These positional indexes all map to the same indexes looked up in the parse
4646
/// meta.
4747
bytes constant OPERAND_HANDLER_FUNCTION_POINTERS =
48-
hex"1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1c151cb11bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec1bec";
48+
hex"1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c3d1c661d02";
4949

5050
/// @dev Every two bytes is a function pointer for a literal parser.
5151
/// Literal dispatches are determined by the first byte(s) of the literal

‎src/generated/candidate/GenericPoolRaindexV6ArbOrderTaker.sol‎

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

‎src/generated/candidate/GenericPoolRaindexV6FlashBorrower.sol‎

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

‎src/generated/candidate/RaindexV6.sol‎

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)