Skip to content

Commit

Permalink
feat: adding an option for call-data-file (#474)
Browse files Browse the repository at this point in the history
* 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 aebc9ed.
  • Loading branch information
praetoriansentry authored Jan 14, 2025
1 parent e6526b6 commit 55b2659
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 27 additions & 12 deletions cmd/ulxly/ulxly.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -1200,6 +1200,7 @@ type ulxlyArgs struct {
tokenAddress *string
forceUpdate *bool
callData *string
callDataFile *string
timeout *uint64
depositCount *uint64
depositNetwork *uint64
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions doc/polycli_ulxly__bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/polycli_ulxly__bridge_asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/polycli_ulxly__bridge_message.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/polycli_ulxly__bridge_weth.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 55b2659

Please sign in to comment.