From 55b2659847480d73f9385ef8a0fdf754001f74a4 Mon Sep 17 00:00:00 2001 From: John Hilliard Date: Tue, 14 Jan 2025 03:33:39 -0500 Subject: [PATCH] feat: adding an option for call-data-file (#474) * feat: adding an option for call-data-file The idea here is to to support large calldata where the input comes from a file rather than needing to be read as a argument. E.g ``` polycli ulxly bridge message \ --private-key $pkey \ --rpc-url http://127.0.0.1:18546 \ --bridge-address 0x1348947e282138d8f377b467F7D9c2EB0F335d1f \ --destination-network 23 \ --value 0 \ --call-data-file <(xxd -p /dev/random | tr -d "\n" | head -c 261569) ``` * fix: protoc gen * fix: switching to stable * Revert "fix: protoc gen" This reverts commit aebc9ed701b91b1c21e328c576f4bae75f8c8515. --- .github/workflows/ci.yml | 2 +- cmd/ulxly/ulxly.go | 39 +++++++++++++++++++--------- doc/polycli_ulxly__bridge.md | 1 + doc/polycli_ulxly__bridge_asset.md | 1 + doc/polycli_ulxly__bridge_message.md | 1 + doc/polycli_ulxly__bridge_weth.md | 1 + 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd96bc36..99c6f4be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: - name: Install foundry uses: foundry-rs/foundry-toolchain@v1 with: - version: nightly + version: stable - name: Get forge version run: forge --version - name: Install contract dependencies diff --git a/cmd/ulxly/ulxly.go b/cmd/ulxly/ulxly.go index 5d6f8281..17424550 100644 --- a/cmd/ulxly/ulxly.go +++ b/cmd/ulxly/ulxly.go @@ -1175,7 +1175,7 @@ var ulxlyBridgeAndClaimCmd = &cobra.Command{ Hidden: true, } -var ulxlxBridgeCmd = &cobra.Command{ +var ulxlyBridgeCmd = &cobra.Command{ Use: "bridge", Short: "Commands for moving funds and sending messages from one chain to another", Args: cobra.NoArgs, @@ -1200,6 +1200,7 @@ type ulxlyArgs struct { tokenAddress *string forceUpdate *bool callData *string + callDataFile *string timeout *uint64 depositCount *uint64 depositNetwork *uint64 @@ -1243,6 +1244,7 @@ const ( ArgDestAddress = "destination-address" ArgForceUpdate = "force-update-root" ArgCallData = "call-data" + ArgCallDataFile = "call-data-file" ArgTimeout = "transaction-receipt-timeout" ArgDepositCount = "deposit-count" ArgDepositNetwork = "deposit-network" @@ -1283,6 +1285,18 @@ func prepInputs(cmd *cobra.Command, args []string) error { *inputUlxlyArgs.destAddress = fromAddress.String() log.Info().Stringer("destAddress", fromAddress).Msg("No destination address specified. Using private key's address") } + + if *inputUlxlyArgs.callDataFile != "" { + rawCallData, err := os.ReadFile(*inputUlxlyArgs.callDataFile) + if err != nil { + return err + } + if *inputUlxlyArgs.callData != "0x" { + return fmt.Errorf("both %s and %s flags were provided", ArgCallData, ArgCallDataFile) + } + stringCallData := string(rawCallData) + inputUlxlyArgs.callData = &stringCallData + } return nil } @@ -1400,12 +1414,13 @@ or if it's actually an intermediate hash.`, fatalIfError(ulxlyBridgeAndClaimCmd.MarkPersistentFlagRequired(ArgBridgeAddress)) // bridge specific args - inputUlxlyArgs.forceUpdate = ulxlxBridgeCmd.PersistentFlags().Bool(ArgForceUpdate, true, "indicates if the new global exit root is updated or not") - inputUlxlyArgs.value = ulxlxBridgeCmd.PersistentFlags().String(ArgValue, "", "the amount in wei to be sent along with the transaction") - inputUlxlyArgs.destNetwork = ulxlxBridgeCmd.PersistentFlags().Uint32(ArgDestNetwork, 0, "the rollup id of the destination network") - inputUlxlyArgs.tokenAddress = ulxlxBridgeCmd.PersistentFlags().String(ArgTokenAddress, "0x0000000000000000000000000000000000000000", "the address of an ERC20 token to be used") - inputUlxlyArgs.callData = ulxlxBridgeCmd.PersistentFlags().String(ArgCallData, "0x", "call data to be passed directly with bridge-message or as an ERC20 Permit") - fatalIfError(ulxlxBridgeCmd.MarkPersistentFlagRequired(ArgDestNetwork)) + inputUlxlyArgs.forceUpdate = ulxlyBridgeCmd.PersistentFlags().Bool(ArgForceUpdate, true, "indicates if the new global exit root is updated or not") + inputUlxlyArgs.value = ulxlyBridgeCmd.PersistentFlags().String(ArgValue, "", "the amount in wei to be sent along with the transaction") + inputUlxlyArgs.destNetwork = ulxlyBridgeCmd.PersistentFlags().Uint32(ArgDestNetwork, 0, "the rollup id of the destination network") + inputUlxlyArgs.tokenAddress = ulxlyBridgeCmd.PersistentFlags().String(ArgTokenAddress, "0x0000000000000000000000000000000000000000", "the address of an ERC20 token to be used") + inputUlxlyArgs.callData = ulxlyBridgeCmd.PersistentFlags().String(ArgCallData, "0x", "call data to be passed directly with bridge-message or as an ERC20 Permit") + inputUlxlyArgs.callDataFile = ulxlyBridgeCmd.PersistentFlags().String(ArgCallDataFile, "", "a file containing hex encoded call data") + fatalIfError(ulxlyBridgeCmd.MarkPersistentFlagRequired(ArgDestNetwork)) // Claim specific args inputUlxlyArgs.depositCount = ulxlyClaimCmd.PersistentFlags().Uint64(ArgDepositCount, 0, "the deposit count of the bridge transaction") @@ -1443,19 +1458,19 @@ or if it's actually an intermediate hash.`, ULxLyCmd.AddCommand(proofCommand) ULxLyCmd.AddCommand(getDepositCommand) - ULxLyCmd.AddCommand(ulxlxBridgeCmd) + ULxLyCmd.AddCommand(ulxlyBridgeCmd) ULxLyCmd.AddCommand(ulxlyClaimCmd) ULxLyCmd.AddCommand(claimEverythingCommand) // Bridge and Claim - ulxlyBridgeAndClaimCmd.AddCommand(ulxlxBridgeCmd) + ulxlyBridgeAndClaimCmd.AddCommand(ulxlyBridgeCmd) ulxlyBridgeAndClaimCmd.AddCommand(ulxlyClaimCmd) ulxlyBridgeAndClaimCmd.AddCommand(claimEverythingCommand) // Bridge - ulxlxBridgeCmd.AddCommand(bridgeAssetCommand) - ulxlxBridgeCmd.AddCommand(bridgeMessageCommand) - ulxlxBridgeCmd.AddCommand(bridgeMessageWETHCommand) + ulxlyBridgeCmd.AddCommand(bridgeAssetCommand) + ulxlyBridgeCmd.AddCommand(bridgeMessageCommand) + ulxlyBridgeCmd.AddCommand(bridgeMessageWETHCommand) // Claim ulxlyClaimCmd.AddCommand(claimAssetCommand) diff --git a/doc/polycli_ulxly__bridge.md b/doc/polycli_ulxly__bridge.md index c643200e..48e3e3c5 100644 --- a/doc/polycli_ulxly__bridge.md +++ b/doc/polycli_ulxly__bridge.md @@ -17,6 +17,7 @@ Commands for moving funds and sending messages from one chain to another ```bash --call-data string call data to be passed directly with bridge-message or as an ERC20 Permit (default "0x") + --call-data-file string a file containing hex encoded call data --destination-network uint32 the rollup id of the destination network --force-update-root indicates if the new global exit root is updated or not (default true) -h, --help help for bridge diff --git a/doc/polycli_ulxly__bridge_asset.md b/doc/polycli_ulxly__bridge_asset.md index c8670fd8..9ea3f848 100644 --- a/doc/polycli_ulxly__bridge_asset.md +++ b/doc/polycli_ulxly__bridge_asset.md @@ -100,6 +100,7 @@ The command also inherits flags from parent commands. ```bash --bridge-address string the address of the lxly bridge --call-data string call data to be passed directly with bridge-message or as an ERC20 Permit (default "0x") + --call-data-file string a file containing hex encoded call data --chain-id string set the chain id to be used in the transaction --config string config file (default is $HOME/.polygon-cli.yaml) --destination-address string the address where the bridge will be sent to diff --git a/doc/polycli_ulxly__bridge_message.md b/doc/polycli_ulxly__bridge_message.md index 16a8d63c..dfa0bb05 100644 --- a/doc/polycli_ulxly__bridge_message.md +++ b/doc/polycli_ulxly__bridge_message.md @@ -97,6 +97,7 @@ The command also inherits flags from parent commands. ```bash --bridge-address string the address of the lxly bridge --call-data string call data to be passed directly with bridge-message or as an ERC20 Permit (default "0x") + --call-data-file string a file containing hex encoded call data --chain-id string set the chain id to be used in the transaction --config string config file (default is $HOME/.polygon-cli.yaml) --destination-address string the address where the bridge will be sent to diff --git a/doc/polycli_ulxly__bridge_weth.md b/doc/polycli_ulxly__bridge_weth.md index d0011bb5..ff33611f 100644 --- a/doc/polycli_ulxly__bridge_weth.md +++ b/doc/polycli_ulxly__bridge_weth.md @@ -66,6 +66,7 @@ The command also inherits flags from parent commands. ```bash --bridge-address string the address of the lxly bridge --call-data string call data to be passed directly with bridge-message or as an ERC20 Permit (default "0x") + --call-data-file string a file containing hex encoded call data --chain-id string set the chain id to be used in the transaction --config string config file (default is $HOME/.polygon-cli.yaml) --destination-address string the address where the bridge will be sent to