Skip to content

Commit

Permalink
Clean huff files
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusx1211 committed Feb 11, 2024
1 parent f8ad055 commit 18a3a58
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 245 deletions.
12 changes: 6 additions & 6 deletions compressor/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ const (
FLAG_READ_WORD_INV
FLAG_READ_N_BYTES
FLAG_WRITE_ZEROS
FLAG_SEQUENCE_NESTED_N_FLAGS_S
FLAG_SEQUENCE_NESTED_N_FLAGS_L
FLAG_NESTED_N_FLAGS_S
FLAG_NESTED_N_FLAGS_L
FLAG_SAVE_ADDRESS
FLAG_READ_ADDRESS_2
FLAG_READ_ADDRESS_3
Expand Down Expand Up @@ -233,10 +233,10 @@ func FlagNames() map[string]uint {
names["FLAG_ABI_5_PARAMS"] = i
case FLAG_ABI_6_PARAMS:
names["FLAG_ABI_6_PARAMS"] = i
case FLAG_SEQUENCE_NESTED_N_FLAGS_S:
names["FLAG_SEQUENCE_NESTED_N_FLAGS_S"] = i
case FLAG_SEQUENCE_NESTED_N_FLAGS_L:
names["FLAG_SEQUENCE_NESTED_N_FLAGS_L"] = i
case FLAG_NESTED_N_FLAGS_S:
names["FLAG_NESTED_N_FLAGS_S"] = i
case FLAG_NESTED_N_FLAGS_L:
names["FLAG_NESTED_N_FLAGS_L"] = i
case FLAG_SEQUENCE_SIGNATURE_W0:
names["FLAG_SEQUENCE_SIGNATURE_W0"] = i
case FLAG_SEQUENCE_SIGNATURE_W1:
Expand Down
8 changes: 4 additions & 4 deletions compressor/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ func (buf *Buffer) WriteNWords(words []byte) (EncodeType, error) {
}

if count <= 255 {
buf.commitUint(FLAG_SEQUENCE_NESTED_N_FLAGS_S)
buf.commitUint(FLAG_NESTED_N_FLAGS_S)
buf.commitByte(byte(count))
} else if count <= 65535 {
buf.commitUint(FLAG_SEQUENCE_NESTED_N_FLAGS_L)
buf.commitUint(FLAG_NESTED_N_FLAGS_L)
buf.commitByte(byte(count >> 8))
buf.commitByte(byte(count))
} else {
Expand Down Expand Up @@ -646,11 +646,11 @@ func (buf *Buffer) WriteSequenceSignatureTree(tree []byte) (EncodeType, error) {

if totalParts > 1 {
if totalParts > 255 {
buf.commitUint(FLAG_SEQUENCE_NESTED_N_FLAGS_L)
buf.commitUint(FLAG_NESTED_N_FLAGS_L)
buf.commitByte(byte(totalParts >> 8))
buf.commitByte(byte(totalParts))
} else {
buf.commitUint(FLAG_SEQUENCE_NESTED_N_FLAGS_S)
buf.commitUint(FLAG_NESTED_N_FLAGS_S)
buf.commitByte(byte(totalParts))
}
}
Expand Down
56 changes: 28 additions & 28 deletions src/decompressor.huff
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
// all this memory will be reused anyway
__tablesize(SELECTORS_TABLE) // [table_size]
__tablestart(SELECTORS_TABLE) // [table_start, table_size]
0x20 // [0x20, table_start, table_size]
codecopy // []
0x20 // [0x20, table_start, table_size]
codecopy // []

callvalue // [0x00]
calldataload // [data[0x00]]
callvalue // [0x00, data[0x00]]
byte // [method]
callvalue // [0x00]
calldataload // [data[0x00]]
callvalue // [0x00, data[0x00]]
byte // [method]

0x05 // [0x05, method]
shl // [(method << 0x05)]
0x20 add // [method + 0x20]
mload // [mload[method]]
jump // []
0x05 // [0x05, method]
shl // [(method << 0x05)]
0x20 add // [method + 0x20]
mload // [mload[method]]
jump // []

execute_transaction:
0x01 // [rindex]
Expand All @@ -64,13 +64,13 @@
0x20 callvalue return

read_storage_slots:
PERFORM_READ_SLOTS() // [size]
callvalue // [0x00, size]
PERFORM_READ_SLOTS() // [size]
callvalue // [0x00, size]
return

decompress_transaction:
PRE_DECODE_ONLY() // [windex, rindex]
DECODE_FULL_EXECUTE(nrfs) // [windex, rindex]
PRE_DECODE_ONLY() // [windex, rindex]
DECODE_FULL_EXECUTE(nrfs) // [windex, rindex]
POST_DECODE_ONLY()

decompress_many_transactions:
Expand All @@ -79,24 +79,24 @@
POST_DECODE_ONLY()

execute_call:
0x01 // [rindex]
PERFORM_CALL(nrfs) // [rindex]
0x01 // [rindex]
PERFORM_CALL(nrfs) // [rindex]
callvalue callvalue return

execute_call_return:
0x01 // [rindex]
PERFORM_CALL(nrfs) // [rindex]
0x01 // [rindex]
PERFORM_CALL(nrfs) // [rindex]

returndatasize // [returnDataSize, rindex]
callvalue // [0, returnDataSize, rindex]
callvalue // [0, 0, returnDataSize, rindex]
returndatacopy // [rindex]
returndatasize // [returnDataSize, rindex]
callvalue // [0, returnDataSize, rindex]
callvalue // [0, 0, returnDataSize, rindex]
returndatacopy // [rindex]

returndatasize callvalue return

execute_many_calls:
0x01 // [rindex]
PERFORM_MANY_CALLS(nrfs) // [rindex, size, i]
0x01 // [rindex]
PERFORM_MANY_CALLS(nrfs) // [rindex, size, i]
callvalue callvalue return

decode_call:
Expand Down Expand Up @@ -146,9 +146,9 @@
#define macro PERFORM_READ_SLOTS() = takes (0) returns (1) {
// input stack: []

0x01 // [0x01]
dup1 // [rindex, 0x01]
callvalue // [windex, rindex, 0x01]
0x01 // [0x01]
dup1 // [rindex, 0x01]
callvalue // [windex, rindex, 0x01]

read_another:
dup2 // [rindex, windex, rindex]
Expand Down
Loading

0 comments on commit 18a3a58

Please sign in to comment.