diff --git a/README.md b/README.md index edabbd4..90c50c3 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,9 @@ It encodes a single call to a contract, the subcommands are: - `call-return` Generates a payload that, when sent to the `decompressor.huff` contract, will decompress the calldata and perform the call, returning the return value. ```cmd -czip-compressor encode_call decode 0xa9059cbb0000000000000000000000008bf74fb902cdad5d2d8ca0d3bbc7bb16894b9c350000000000000 -000000000000000000000000000000000000000000006052340 0xdAC17F958D2ee523a2206206994597C13D831 -ec7 +czip-compressor encode-call decode 0xa9059cbb0000000000000000000000008bf74fb902cdad5d2d8ca0d3bbc7bb16894b9c350000000000000000000000000000000000000000000000000000000006052340 0xdAC17F958D2ee523a2206206994597C13D831ec7 -> 0x0b3700a9059cbb268bf74fb902cdad5d2d8ca0d3bbc7bb16894b9c35332bf226dac17f958d2ee523a2206206994597c13d831ec7 +> 0x0b3701148bf74fb902cdad5d2d8ca0d3bbc7bb16894b9c35332bf214dac17f958d2ee523a2206206994597c13d831ec7 ``` ### Encode Calls @@ -75,9 +73,9 @@ It encodes multiple calls to contracts, the subcommands are: Notice that the `call-return` subcommand is not available in this mode. ```cmd -czip-compressor encode_calls decode 0xa9059cbb0000000000000000000000009813d80d0686406b79c29b2b8a672a13725facb300000000000000000000000000000000000000000000000ae56f730e6d840000 0xdac17f958d2ee523a2206206994597c13d831ec7 0x095ea7b30000000000000000000000007c56be0ad3128acc33190484cd1badebc8c76240ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xdac17f958d2ee523a2206206994597c13d831ec7 +czip-compressor encode-calls decode 0xa9059cbb0000000000000000000000009813d80d0686406b79c29b2b8a672a13725facb300000000000000000000000000000000000000000000000ae56f730e6d840000 0xdac17f958d2ee523a2206206994597c13d831ec7 0x095ea7b30000000000000000000000007c56be0ad3128acc33190484cd1badebc8c76240ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xdac17f958d2ee523a2206206994597c13d831ec7 -> 0x0c023700a9059cbb269813d80d0686406b79c29b2b8a672a13725facb3338fda26dac17f958d2ee523a2206206994597c13d831ec73700095ea7b3267c56be0ad3128acc33190484cd1badebc8c7624031ff2e0020 +> 0x0c023701149813d80d0686406b79c29b2b8a672a13725facb3338fda14dac17f958d2ee523a2206206994597c13d831ec73702147c56be0ad3128acc33190484cd1badebc8c7624031ff3d001c ``` > Compressing multiple calls into one payload is more efficient than compressing each call individually, as data can be de-duplicated and the overhead of the decompressor is amortized over multiple calls. @@ -87,14 +85,14 @@ czip-compressor encode_calls decode 0xa9059cbb0000000000000000000000009813d80d06 It encodes any data into a compressed representation. Sending the payload to the `decompressor.huff` contract will return the original data. ```cmd -czip-compressor encode_any 0x0000000000000000000000000000000000000000000000012a5f58168ee60000 +czip-compressor encode-any 0x0000000000000000000000000000000000000000000000012a5f58168ee60000 > 0x0d3388d7 ``` ### Encode Sequence Transaction -It works similarly to `encode_calls`, but it is specifically designed to compress a Sequence wallet transaction. It expects the data to be a Sequence Transaction ABI-encoded. +It works similarly to `encode-calls`, but it is specifically designed to compress a Sequence wallet transaction. It expects the data to be a Sequence Transaction ABI-encoded. ## Using storage indexes @@ -111,15 +109,17 @@ Notice that a cache on `/tmp/czip-cache/czip-indexes-.json` is automat ### Example ```cmd -./compressor/bin/czip-compressor encode_call 0x963752cac40E583Dea143D6262e24f89c9E1F911 call 0xa9059cbb000000000000000000000000963752cac40e583dea143d6262e24f89c9e1f91100000000000000000000000000000000000000000000000000000000000003fc 0x750ba8b76187092B0D1E87E28daaf484d1b5273b +czip-compressor encode-call call 0xa9059cbb000000000000000000000000963752cac40e583dea143d6262e24f89c9e1f91100000000000000000000000000000000000000000000000000000000000003fc 0x750ba8b76187092B0D1E87E28daaf484d1b5273b > 0x08370114963752cac40e583dea143d6262e24f89c9e1f9110203fc14750ba8b76187092b0d1e87e28daaf484d1b5273b -./compressor/bin/czip-compressor encode_call --provider https://nodes.sequence.app/arbitrum-nova --contract 0x963752cac40E583Dea143D6262e24f89c9E1F911 call 0xa9059cbb000000000000000000000000963752cac40e583dea143d6262e24f89c9e1f91100000000000000000000000000000000000000000000000000000000000003fc 0x750ba8b76187092B0D1E87E28daaf484d1b5273b --use-storage true +czip-compressor encode-call call --contract 0x8C5CF0a201C1F0C1517a23699BE48070724e7a70 --provider https://nodes.sequence.app/arbitrum-nova --use-storage 0xa9059cbb000000000000000000000000963752cac40e583dea143d6262e24f89c9e1f91100000000000000000000000000000000000000000000000000000000000003fc 0x750ba8b76187092B0D1E87E28daaf484d1b5273b -> 0x0837012700020203fc270003 +> 0x0837012700010203fc270002 ``` +See it in action: https://nova.arbiscan.io/tx/0x86e7b4177c0d219a87cc58f93ae2ecf2f490a719119c283f61cdc88585cc7c7b + ## Compression gains The compression gains are highly dependent on the ratio of computation cost to calldata cost of a given network. It is most effective on "rollup" style L2s, but it can also achieve some small gains on some other networks. diff --git a/compressor/cmd/czip-compressor/indexes.go b/compressor/cmd/czip-compressor/indexes.go index b1c8a29..36e6ad1 100644 --- a/compressor/cmd/czip-compressor/indexes.go +++ b/compressor/cmd/czip-compressor/indexes.go @@ -139,7 +139,7 @@ func UseIndexes(ctx context.Context, cmd *cobra.Command) (*compressor.Indexes, e contract := common.HexToAddress(contractAddr) if contract == (common.Address{}) { - return nil, fmt.Errorf("contract address is required") + return nil, fmt.Errorf("contract address is required, use --contract") } // Get the highest indexes for addresses and bytes32 diff --git a/compressor/cmd/czip-compressor/main.go b/compressor/cmd/czip-compressor/main.go index c5ec748..0ed0800 100644 --- a/compressor/cmd/czip-compressor/main.go +++ b/compressor/cmd/czip-compressor/main.go @@ -31,7 +31,7 @@ func init() { rootCmd.PersistentFlags().StringP("provider", "p", "", "Ethereum RPC provider URL.") rootCmd.PersistentFlags().StringP("contract", "c", "", "Contract address of the decompressor contract.") rootCmd.PersistentFlags().String("cache-dir", "/tmp/czip-cache", "Path to the cache dir for indexes.") - rootCmd.MarkFlagsRequiredTogether("provider", "contract", "use-storage") + rootCmd.MarkFlagsRequiredTogether("provider", "contract") rootCmd.PersistentFlags().StringSlice("allow-opcodes", []string{}, "Will only encode using these operations, separated by commas.") rootCmd.PersistentFlags().StringSlice("disallow-opcodes", []string{}, "Will not encode using these operations, separated by commas.")