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

node: generalised governance #3895

Merged
merged 6 commits into from
Apr 23, 2024
Merged

node: generalised governance #3895

merged 6 commits into from
Apr 23, 2024

Conversation

kcsongor
Copy link
Contributor

@kcsongor kcsongor commented Apr 22, 2024

The EVM implementation handles governance requests of the form:

current_set_index: 4
# generic evm call
messages: {
  sequence: 4513077582118919631
  nonce: 2809988562
  evm_call: {
    chain_id: 3
    governance_contract: "0xD8E4C2DbDd2e2bd8F1336EA691dBFF6952B1a6eB"
    target_contract: "0xF890982f9310df57d00f659cf4fd87e65adEd8d7"
    abi_encoded_call: "BEEFFACE"
  }
}

The solana implementation handles governance requests of the form:

current_set_index: 4
# generic solana call
messages: {
  sequence: 4513077582118919631
  nonce: 2809988562
  solana_call: {
    chain_id: 3
    governance_contract: "3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5"
    encoded_instruction: "BEEFFACE"
  }
}

The expectation is for the abi_encoded_call and encoded_instruction calls to be generated (and verified) via external tools.

Copy link
Contributor

@bruce-riley bruce-riley left a comment

Choose a reason for hiding this comment

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

This looks really good! But I think you also have to make a change to node/cmd/guardiand/admintemplate.go.

@kcsongor kcsongor force-pushed the guardiand/generalised-gov branch 2 times, most recently from c4d25ca to dc65642 Compare April 22, 2024 19:27
Handles governance requests of the form:

```
current_set_index: 4
messages: {
  sequence: 4513077582118919631
  nonce: 2809988562
  evm_call: {
    chain_id: 3
    governance_contract: "0xD8E4C2DbDd2e2bd8F1336EA691dBFF6952B1a6eB"
    target_contract: "0xF890982f9310df57d00f659cf4fd87e65adEd8d7"
    abi_encoded_call: "6497f75a000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000f890982f9310df57d00f659cf4fd87e65aded8d70000000000000000000000000000000000000000000000000000000000000140bebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebe000000000000000000000000000000000000000000000000000000000000000268690000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004beefface00000000000000000000000000000000000000000000000000000000"
  }
}
```
@kcsongor kcsongor force-pushed the guardiand/generalised-gov branch from dc65642 to 1fc0df9 Compare April 22, 2024 19:32
bruce-riley
bruce-riley previously approved these changes Apr 22, 2024
handles governance requests of the form

```
current_set_index: 4
messages: {
  sequence: 4513077582118919631
  nonce: 2809988562
  solana_call: {
    chain_id: 3
    governance_contract: "3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5"
    encoded_instruction: "BEEFFACE"
  }
}
```
@kcsongor kcsongor marked this pull request as ready for review April 22, 2024 20:48
evan-gray
evan-gray previously approved these changes Apr 22, 2024
Copy link
Contributor

@evan-gray evan-gray left a comment

Choose a reason for hiding this comment

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

Approved but had a couple questions.

bruce-riley
bruce-riley previously approved these changes Apr 22, 2024
@kcsongor kcsongor dismissed stale reviews from bruce-riley and evan-gray via 005bbd6 April 22, 2024 21:21
@kcsongor kcsongor force-pushed the guardiand/generalised-gov branch 3 times, most recently from 8986124 to b7f4adb Compare April 22, 2024 21:32
bruce-riley
bruce-riley previously approved these changes Apr 22, 2024
evan-gray
evan-gray previously approved these changes Apr 23, 2024
Copy link
Contributor

@evan-gray evan-gray left a comment

Choose a reason for hiding this comment

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

Approving pending clarification.

@kcsongor kcsongor dismissed stale reviews from evan-gray and bruce-riley via e1c8bc8 April 23, 2024 11:54
@kcsongor kcsongor force-pushed the guardiand/generalised-gov branch from b7f4adb to e1c8bc8 Compare April 23, 2024 11:54
@kcsongor kcsongor force-pushed the guardiand/generalised-gov branch from 13058bb to 51d34bf Compare April 23, 2024 13:58
Copy link
Contributor

@evan-gray evan-gray left a comment

Choose a reason for hiding this comment

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

agree with reworking checks in Serialize to return errors in a future PR #3897

@evan-gray evan-gray merged commit 9620fca into main Apr 23, 2024
24 checks passed
@evan-gray evan-gray deleted the guardiand/generalised-gov branch April 23, 2024 15:28
Comment on lines +966 to +972
if *governanceTargetAddress == "" {
log.Fatal("--target-address must be specified")
}
if !common.IsHexAddress(*governanceTargetAddress) {
log.Fatal("invalid target address")
}
governanceTargetAddress := common.HexToAddress(*governanceTargetAddress).Hex()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we not using parseAddress in these templates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because parseAddress attempts to parse any 32 byte address-like thing into a (left-padded) 32 byte address

func parseAddress(s string) (string, error) {
// try base58
b, err := base58.Decode(s)
if err == nil {
return leftPadAddress(b)
}
// try bech32
_, b, err = bech32.Decode(s)
if err == nil {
return leftPadAddress(b)
}
// try hex
if len(s) > 2 && strings.ToLower(s[:2]) == "0x" {
s = s[2:]
}
a, err := hex.DecodeString(s)
if err != nil {
return "", fmt.Errorf("invalid hex address: %v", err)
}
return leftPadAddress(a)
}

in this case, we only care about EVM addresses, so we can be a bit more specific

@@ -577,6 +577,58 @@ func wormholeRelayerSetDefaultDeliveryProvider(req *nodev1.WormholeRelayerSetDef
return v, nil
}

func evmCallToVaa(evmCall *nodev1.EvmCall, timestamp time.Time, guardianSetIndex, nonce uint32, sequence uint64) (*vaa.VAA, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a check in here to enforce that chain id doesn't exceed max uint16?

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.

5 participants