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: Add safe flag #71

Merged
merged 22 commits into from
Oct 1, 2024
Merged

Feat: Add safe flag #71

merged 22 commits into from
Oct 1, 2024

Conversation

karacurt
Copy link
Contributor

This PR adds safe functionality to seer. Details:

  • When an address is passed with --safe flag, it will propose a transaction to the safe.
  • When safe flag is used along with deploy, it will propose a DELEGATECALL calling performCreate2 function in the CreateCall contract.

@karacurt karacurt requested a review from zomglings September 26, 2024 13:41
Copy link
Contributor

@zomglings zomglings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karacurt : Left several suggestions, and asked for a few changes.

bindings/GnosisSafe/GnosisSafe.go Show resolved Hide resolved
evm/generators.go Show resolved Hide resolved
code = string(generatedCode)
}

return code, nil
codeImportsFixed := strings.ReplaceAll(code, "github.com/quan8/go-ethereum", "github.com/ethereum/go-ethereum")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? This looks like a problem in your local development environment that you are pushing a fix for to all users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are totally right, this is not necessary. It was introduced in early stage of development to make it work. Removing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zomglings: I've updated the code to remove this import. But it keeps importing the wrong ones:

"github.com/quan8/go-ethereum/common/math"
	"github.com/quan8/go-ethereum/crypto"
	

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I wonder why that is. Could it be an LLM issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports fixed! It was missing from appending to t.Specs struct 😄

evm/generators.go Outdated Show resolved Hide resolved
return CreateSafeProposal(client, key, safeAddress, factoryAddress, safeCreateCallTxData, value, txServiceBaseUrl, OperationType(safeOperation))
}

func GenerateProperSalt(from common.Address) ([32]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this anymore, since we are not using the ImmutableCreate2Factory anymore?

Copy link
Contributor Author

@karacurt karacurt Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to pass a salt to call safeCreate2 on the CreateCall contract. But you are right; to simplify this function, we no longer need to append the caller's address at the beginning of the salt.

Would you like to update it, or can we keep it with ImmutableCreate2Factory compatibility if we want to use it in the future?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather just take a --salt on the deploy --safe command.

Take salt as an argument from the caller, basically.

I don't like to force a particular salt generation strategy on the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, do you think it is a problem to keep it that way?

Because in the actual implementation, if you use --salt, it will override this one.

The autogeneration only happens if the users do not specify a --salt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karacurt : I prefer to remove it - the requirement that the salt be prefixed with the caller address is an optional constraint implemented by that particular CREATE2 factory. Other CREATE2 factories will have other means to prevent spoofs, and some may not even put any protections in place. Using that as a default salt just feelds weird to me - and it actually makes it harder to use Safe with ImmutableCreate2Factory!

I would have one of two expectations for --salt. Either:

  1. Use a random salt, or
  2. Make --salt a required argument

I prefer to make it required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do we need to make a CLI to generate a random salt? I think I didn't get this part.

I am ok with removing the salt standard, but I think it would be useful to have a autogenerated salt if --salt not passed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

evm/generators.go Outdated Show resolved Hide resolved
if err != nil {
return fmt.Errorf("failed to get ABI: %v", err)
}
// TODO: this is a workaround to match the original method name in the ABI, need to fix to work with every method name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the issue here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try my best to explain here. If it's not clear, maybe we should pair for a better understanding:

I found out that abi.Pack("methodName", args...) is case sensitive. It only works if the methodName has the exact case-sensitive name as in the abi. Unfortunately, the parser modifies the method name to UpperCamelCase.

I've tried a similar method of calling the transactor with NoSend flag equal to true. However, it does not work because it simulates the transaction against the blockchain. In this case, the dev wallet is the from address, and it needs to be the safeAddress. I couldn't find an option to the the from address as a different address from the caller.

I think there is probably a more straightforward solution, so I left this TODO: comment so we could work together on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we put the original method name into the object that gets sent to the template?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixed the problem using session. object. It create the calldata without sending it

evm/generators.go Outdated Show resolved Hide resolved
evm/generators.go Show resolved Hide resolved
version/version.go Outdated Show resolved Hide resolved
Copy link
Contributor

@zomglings zomglings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Few small changes required, but they don't need re-approval. Just merge after you make them.

README.md Outdated Show resolved Hide resolved
evm/generators.go Show resolved Hide resolved
@karacurt karacurt merged commit 8aec2aa into G7DAO:main Oct 1, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants