Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate inversions of abi.encodePacked() for StakingMessages.unpack*() #482

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8777f88
perf: `SetSubnetValidatorWeightMessage` (un)packing gas reductions
ARR4N Aug 6, 2024
8b0557a
chore: `forge fmt`
ARR4N Aug 6, 2024
d5f52da
chore: `solhint-disable` assembly checks + some commentary
ARR4N Aug 6, 2024
1c94c27
feat: generated code for `abi.encodePacked()` inversion
ARR4N Aug 9, 2024
c89bd4a
fix: `solc` pragma `^0.8.0` unless using `mcopy` then `^0.8.25`
ARR4N Aug 9, 2024
dac07fc
fix: remove unused variable when dynamically sized at end
ARR4N Aug 9, 2024
c3ac02a
chore: add copyright notices
ARR4N Aug 9, 2024
e264572
chore: placate the linters... ssshhhhh
ARR4N Aug 9, 2024
7f0bd2e
perf: `SetSubnetValidatorWeightMessage` (un)packing gas reductions
ARR4N Aug 6, 2024
9890cca
chore: `forge fmt`
ARR4N Aug 6, 2024
721b63e
chore: `solhint-disable` assembly checks + some commentary
ARR4N Aug 6, 2024
ef87566
feat: generated code for `abi.encodePacked()` inversion
ARR4N Aug 9, 2024
c9e28b6
fix: `solc` pragma `^0.8.0` unless using `mcopy` then `^0.8.25`
ARR4N Aug 9, 2024
1c2ad1e
fix: remove unused variable when dynamically sized at end
ARR4N Aug 9, 2024
7f98e2a
chore: add copyright notices
ARR4N Aug 9, 2024
ee4bbf6
chore: placate the linters... ssshhhhh
ARR4N Aug 9, 2024
e6cf4e5
Merge branch 'arr4n/staking-messages' of github.com:ava-labs/teleport…
ARR4N Aug 9, 2024
3bb7bb6
chore: remove obsolete test of equivalence
ARR4N Aug 9, 2024
34f629f
refactor: `abi.encodePacked()` and `Unpack.unpack_...()` all the things
ARR4N Aug 9, 2024
f32bbcf
chore: make Slither keep quiet
ARR4N Aug 9, 2024
0272bde
chore: disable `line-length-limiter` on flag usage
ARR4N Aug 9, 2024
aed84c7
feat: use literal "dyn" string in `unpackgen` flag
ARR4N Aug 9, 2024
a279844
Merge branch 'staking-contract' into arr4n/staking-messages
ARR4N Aug 12, 2024
de4da9f
Merge branch 'staking-contract' into arr4n/staking-messages
ARR4N Sep 6, 2024
aab0874
feat: `pragma solidity` version override
ARR4N Sep 6, 2024
f4a773c
fix: apply explicit `solc` version to generated tests
ARR4N Sep 6, 2024
1bfcf4b
doc: clarify allowable interchange of `bytes<N>` and `uint<8N>` types
ARR4N Sep 6, 2024
78a1f47
refactor: only change `pack*()` methods to `abi.encodePacked()`
ARR4N Sep 6, 2024
e13cabc
refactor: change `unpack*()` methods to use generated code
ARR4N Sep 6, 2024
a19b841
chore: regenerate ABI bindings
ARR4N Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: remove unused variable when dynamically sized at end
  • Loading branch information
ARR4N committed Aug 9, 2024
commit dac07fc112650695ac184e4264533f6af79264a4
2 changes: 0 additions & 2 deletions contracts/staking/Unpack.sol
Original file line number Diff line number Diff line change
@@ -40,7 +40,6 @@ library Unpack {
let dynLength := sub(length, 84)
v5 := add(input, 84)
mstore(v5, dynLength)
let end := add(input, add(length, 0x20))
}
}

@@ -137,7 +136,6 @@ library Unpack {
let dynLength := sub(length, 80)
v4 := add(input, 80)
mstore(v4, dynLength)
let end := add(input, add(length, 0x20))
}
}
}
2 changes: 2 additions & 0 deletions utils/unpack/Unpack.sol.gotmpl
Original file line number Diff line number Diff line change
@@ -54,7 +54,9 @@ library Unpack {
v{{$i}} := add(input, {{.Offset}})
mstore(v{{$i}}, dynLength)
{{- end}}
{{- if not ($unpacker.IsLastVar $i)}}
let end := add(input, add(length, 0x20))
{{- end}}
{{- else}}
{{- if .Front}}
v{{$i}} := mload(add(input, {{.OffsetHex}}))
4 changes: 4 additions & 0 deletions utils/unpack/unpack.go
Original file line number Diff line number Diff line change
@@ -222,6 +222,10 @@ func (u *unpacker) FuncNameSuffix() string {
return fmt.Sprintf("%s_Destructive", base)
}

func (u *unpacker) IsLastVar(i int) bool {
return i >= len(u.Vars)-1
}

// varPrefix is the prefix of all numerically identified variables in the
// generated code; i.e. for prefix v, the variables are v0, v1, v2...
const varPrefix = "v"