From 119ddc3ffe9eb38af10fa0dcabe03c65a59cebe4 Mon Sep 17 00:00:00 2001 From: Vinh Date: Wed, 26 Feb 2025 05:49:08 -0800 Subject: [PATCH 1/2] preprocess contract write {{ }} block to make contract write dynamic, we can pre-process the address/calldata with {{ }} similar to retool. --- core/taskengine/vm_runner_contract_write.go | 36 ++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/core/taskengine/vm_runner_contract_write.go b/core/taskengine/vm_runner_contract_write.go index 49549669..19ca3cec 100644 --- a/core/taskengine/vm_runner_contract_write.go +++ b/core/taskengine/vm_runner_contract_write.go @@ -53,21 +53,28 @@ func (r *ContractWriteProcessor) Execute(stepID string, node *avsproto.ContractW s.Success = err == nil }() - contractAddress := common.HexToAddress(node.ContractAddress) - calldata := common.FromHex(node.CallData) + contractAddressHex := strings.Clone(node.ContractAddress) + callDataHex := strings.Clone(node.CallData) + + if strings.Contains(contractAddressHex, "{{") { + contractAddressHex = r.vm.preprocessText(contractAddressHex) + } + if strings.Contains(callDataHex, "{{") { + callDataHex = r.vm.preprocessText(callDataHex) + } + + fmt.Println("EVALUATE TO", contractAddressHex, callDataHex) + + contractAddress := common.HexToAddress(contractAddressHex) + calldata := common.FromHex(callDataHex) + userOpCalldata, err := aa.PackExecute( contractAddress, big.NewInt(0), // TODO: load correct salt from the task calldata, ) - log.WriteString(fmt.Sprintf("\nprepare to send userops target contract %s\ninitialize bundler client\n", node.ContractAddress)) - // bundlerClient, err := bundler.NewBundlerClient(r.smartWalletConfig.BundlerURL) - - // if err != nil { - // log.WriteString(fmt.Sprintf("error creating bundle client: %s", err)) - // s.Error = fmt.Sprintf("error creating bundler client : %s", err) - // return s, err - // } + log.WriteString(fmt.Sprintf("\nwill send message %s to contract %s\n", callDataHex, contractAddressHex)) + log.WriteString(fmt.Sprintf("\nprepare to send userops to target contract %s\ninitialize bundler client\n", contractAddress.Hex())) log.WriteString("\nsend userops to bundler rpc\n") @@ -83,6 +90,13 @@ func (r *ContractWriteProcessor) Execute(stepID string, node *avsproto.ContractW } bloom, _ := txReceipt.Bloom.MarshalText() + + blobGasPrice := uint64(0) + + if txReceipt.BlobGasPrice != nil { + blobGasPrice = uint64(txReceipt.BlobGasPrice.Int64()) + } + outputData := &avsproto.Execution_Step_ContractWrite{ ContractWrite: &avsproto.ContractWriteNode_Output{ UserOp: &avsproto.Evm_UserOp{ @@ -118,7 +132,7 @@ func (r *ContractWriteProcessor) Execute(stepID string, node *avsproto.ContractW Root: common.Bytes2Hex(txReceipt.PostState), Status: uint32(txReceipt.Status), Type: uint32(txReceipt.Type), - BlobGasPrice: uint64(txReceipt.BlobGasPrice.Int64()), + BlobGasPrice: blobGasPrice, BlobGasUsed: uint64(txReceipt.BlobGasUsed), }, }, From 1b84e711c47a17914a1066a2c2b6ec095601b9b4 Mon Sep 17 00:00:00 2001 From: Vinh Date: Wed, 26 Feb 2025 05:50:55 -0800 Subject: [PATCH 2/2] remove log --- core/taskengine/vm_runner_contract_write.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/taskengine/vm_runner_contract_write.go b/core/taskengine/vm_runner_contract_write.go index 19ca3cec..acf9d6ea 100644 --- a/core/taskengine/vm_runner_contract_write.go +++ b/core/taskengine/vm_runner_contract_write.go @@ -63,8 +63,6 @@ func (r *ContractWriteProcessor) Execute(stepID string, node *avsproto.ContractW callDataHex = r.vm.preprocessText(callDataHex) } - fmt.Println("EVALUATE TO", contractAddressHex, callDataHex) - contractAddress := common.HexToAddress(contractAddressHex) calldata := common.FromHex(callDataHex)