-
Notifications
You must be signed in to change notification settings - Fork 2
Solana devenv support #1023
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
Solana devenv support #1023
Changes from 11 commits
49c2674
5bcd368
9da771b
9b30aaa
63cc1e7
27f600c
dc8bdd1
11da650
ff42e70
f5483e3
a408082
7b0e08f
dbf7c42
21c9c4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,7 @@ func init() { | |
| // provides backward compatibility with the previous FamilyEVM/FamilyCanton | ||
| // combined switch case. | ||
| cciptestinterfaces.RegisterExtraArgsSerializer(chainsel.FamilyCanton, SerializeEVMExtraArgs) | ||
| cciptestinterfaces.RegisterExtraArgsSerializer(chainsel.FamilySolana, SerializeSVMExtraArgs) | ||
| } | ||
|
|
||
| type CCIP17EVMConfig struct { | ||
|
|
@@ -790,6 +791,16 @@ func SerializeEVMExtraArgs(opts cciptestinterfaces.MessageOptions) []byte { | |
| } | ||
| } | ||
|
|
||
| // SerializeSVMExtraArgs is the Solana family's ExtraArgsSerializer, handling versions 1. | ||
| func SerializeSVMExtraArgs(opts cciptestinterfaces.MessageOptions) []byte { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is 1.6 though, right? From 2.0 onwards the extra args are encoded by the destination chain format
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally yes, but devenv uses these chain-family serializer registries, it needs to be abi encoded otherwise fq cannot decode it. I spoke to Terry, the Devenv is still evolving, and this is just for unblocking us. CC @tt-cll
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think ideally the registration we're doing above happens in the integrating repo, Solana in this instance.
That repo impl would return something to the EVM (or whoever calls it) like a byte array and anything else required for serialization to occur. fyi @winder @makramkd |
||
| switch opts.Version { | ||
| case 1: | ||
| return serializeExtraArgsSVMV1(opts) | ||
| default: | ||
| panic(fmt.Sprintf("unsupported EVM message extra args version: %d", opts.Version)) | ||
|
huangzhen1997 marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| func serializeExtraArgsV1(opts cciptestinterfaces.MessageOptions) []byte { | ||
| evmExtraArgsV1Type, err := abi.NewType("tuple", "EVMExtraArgsV1", []abi.ArgumentMarshaling{ | ||
| {Name: "gasLimit", Type: "uint256"}, | ||
|
|
@@ -866,6 +877,44 @@ func serializeExtraArgsV3(opts cciptestinterfaces.MessageOptions) []byte { | |
| return extraArgs | ||
| } | ||
|
|
||
| func serializeExtraArgsSVMV1(opts cciptestinterfaces.MessageOptions) []byte { | ||
| svmExtraArgsV1Type, err := abi.NewType("tuple", "SVMExtraArgsV1", []abi.ArgumentMarshaling{ | ||
| {Name: "computeUnits", Type: "uint32"}, | ||
| {Name: "accountIsWritableBitmap", Type: "uint64"}, | ||
| {Name: "allowOutOfOrderExecution", Type: "bool"}, | ||
| {Name: "tokenReceiver", Type: "bytes32"}, | ||
| {Name: "accounts", Type: "bytes32[]"}, | ||
| }) | ||
| if err != nil { | ||
| panic(fmt.Sprintf("failed to create SVMExtraArgsV1 tuple type: %v", err)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we not panic here? I don't see a clear path to adding test, asserting valid/intended errors from upstream caller
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is supposed to be running in devenv test via a call with SendMessage. And that's the pattern with all other serialize functions |
||
| } | ||
|
|
||
| arguments := abi.Arguments{{Type: svmExtraArgsV1Type, Name: "extraArgs"}} | ||
|
|
||
| type SVMExtraArgsV1 struct { | ||
| ComputeUnits uint32 | ||
| AccountIsWritableBitmap uint64 | ||
| AllowOutOfOrderExecution bool | ||
| TokenReceiver [32]byte | ||
| Accounts [][32]byte | ||
| } | ||
|
|
||
| packed, err := arguments.Pack(SVMExtraArgsV1{ | ||
| ComputeUnits: opts.ExecutionGasLimit, | ||
| AccountIsWritableBitmap: 0, | ||
| AllowOutOfOrderExecution: opts.OutOfOrderExecution, | ||
| TokenReceiver: [32]byte{}, | ||
| Accounts: [][32]byte{}, | ||
|
huangzhen1997 marked this conversation as resolved.
|
||
| }) | ||
| if err != nil { | ||
| panic(fmt.Sprintf("failed to pack SVMExtraArgsV1: %v", err)) | ||
| } | ||
|
|
||
| // bytes4 public constant SVM_EXTRA_ARGS_V1_TAG = 0x1f3b3aba; | ||
| tag, _ := hexutil.Decode("0x1f3b3aba") | ||
| return append(tag, packed...) | ||
| } | ||
|
huangzhen1997 marked this conversation as resolved.
|
||
|
|
||
| func (m *CCIP17EVM) ExposeMetrics( | ||
| ctx context.Context, | ||
| source, dest uint64, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be necessary, you can filter in the implementation and the GenericConfig object has a helper for that: