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

Implementation of 'Flow Cancel' modifications to Governor calculations #3798

Merged
merged 38 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4d226c7
Add allow list of tokens, and tests
johnsaigle Feb 16, 2024
b0479e4
Flow cancel implementation
johnsaigle Feb 19, 2024
c660f00
Add more unit tests for flow cancelling
johnsaigle Feb 19, 2024
7a00310
Remove artifacts from earlier implementation
johnsaigle Feb 19, 2024
801169d
remove TODOs
johnsaigle Feb 19, 2024
03347aa
fix incorrect comment
johnsaigle Feb 19, 2024
e579e59
formatting with goimports
johnsaigle Feb 19, 2024
e466efb
Add unit test for sum invariant
johnsaigle Feb 20, 2024
c2a5bc5
Fix comment on function
johnsaigle Feb 20, 2024
a1cc70f
Cleanup and clarity
johnsaigle Feb 20, 2024
e5bdb34
gosimple fixes
johnsaigle Feb 20, 2024
07f4d77
Improve readability and fix spelling and style
johnsaigle Feb 21, 2024
34282a9
Restore comment
johnsaigle Feb 21, 2024
40ee150
fix casing on hard-coded error strings
johnsaigle Feb 21, 2024
256983f
Fix governor unit test
johnsaigle Feb 21, 2024
b332205
Remove code mistakenly added during rebase
johnsaigle Apr 15, 2024
eab717b
node: rewrite flow cancel logic
johnsaigle Apr 30, 2024
88c8940
node: documentation and cleanup
johnsaigle Apr 30, 2024
a1b9919
node: revert changes to unit test values
johnsaigle Apr 30, 2024
aba0cbf
node: goimports linting
johnsaigle Apr 30, 2024
2eab92c
node: add unit tests for checkedadd functions
johnsaigle Apr 30, 2024
f39268a
node: goimports for flow_cancel_tokens
johnsaigle Apr 30, 2024
63fd38e
node: Check return value for reloadTransfer
johnsaigle Apr 30, 2024
7aa3b8e
node: More happy path checkedadd tests
johnsaigle May 1, 2024
e99454c
node: goimports on governor
johnsaigle May 1, 2024
1d5c6e1
node: add Timestamp comments to governor
johnsaigle May 3, 2024
31967f4
node: Warn when flow cancel token is not in main list
johnsaigle May 3, 2024
6d8a29c
node: Comment flow cancel verification
johnsaigle May 3, 2024
28f7a34
node: fix ineffassign in unit test
johnsaigle May 3, 2024
e941590
node: Use only Eth and Sol assets for flow cancel
johnsaigle May 6, 2024
d33f063
node: fix function comments
johnsaigle May 6, 2024
7936c03
node: Improve error handling and fix comments
johnsaigle May 8, 2024
a2796dc
node: fix godoc
johnsaigle May 9, 2024
4853448
node: Change err handling for sumValue overflow
johnsaigle May 15, 2024
30bcf93
node: revert change to GetAvailableNotionalByChain function sig
johnsaigle May 15, 2024
62512d2
node: Add flow cancel to dst chain when retrieving from db
johnsaigle May 16, 2024
32b3cb0
node: Add flow cancel tokens to devnet and testnet
johnsaigle May 17, 2024
a02393c
node: fix incorrect comment
johnsaigle May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions node/pkg/db/governor.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ func (d *MockGovernorDB) GetChainGovernorData(logger *zap.Logger) (transfers []*
}

type Transfer struct {
Timestamp time.Time
Value uint64
OriginChain vaa.ChainID
OriginAddress vaa.Address
// This value is generated by the Governor. It is not read from the blockchain transaction. It represents the
// time at which it was observed and evaluated by the Governor.
Timestamp time.Time
// Notional USD value of the transfer
Value uint64
// Where the asset was minted
OriginChain vaa.ChainID
OriginAddress vaa.Address
// Where the transfer was emitted. Not necessarily equal to OriginChain
SEJeff marked this conversation as resolved.
Show resolved Hide resolved
EmitterChain vaa.ChainID
EmitterAddress vaa.Address
MsgID string
Expand Down
17 changes: 11 additions & 6 deletions node/pkg/governor/devnet_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ import (
"github.com/wormhole-foundation/wormhole/sdk/vaa"
)

func (gov *ChainGovernor) initDevnetConfig() ([]tokenConfigEntry, []chainConfigEntry) {
func (gov *ChainGovernor) initDevnetConfig() ([]tokenConfigEntry, []tokenConfigEntry, []chainConfigEntry) {
gov.logger.Info("setting up devnet config")

gov.dayLengthInMinutes = 5

tokens := []tokenConfigEntry{
tokenConfigEntry{chain: 1, addr: "069b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f00000000001", symbol: "SOL", coinGeckoId: "wrapped-solana", decimals: 8, price: 34.94}, // Addr: So11111111111111111111111111111111111111112, Notional: 4145006
tokenConfigEntry{chain: 2, addr: "000000000000000000000000DDb64fE46a91D46ee29420539FC25FD07c5FEa3E", symbol: "WETH", coinGeckoId: "weth", decimals: 8, price: 1174},
{chain: 1, addr: "069b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f00000000001", symbol: "SOL", coinGeckoId: "wrapped-solana", decimals: 8, price: 34.94}, // Addr: So11111111111111111111111111111111111111112, Notional: 4145006
{chain: 1, addr: "3b442cb3912157f13a933d0134282d032b5ffecd01a2dbf1b7790608df002ea7", symbol: "USDC", coinGeckoId: "usdc", decimals: 6, price: 1}, // Addr: 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU, Notional: 1
{chain: 2, addr: "000000000000000000000000DDb64fE46a91D46ee29420539FC25FD07c5FEa3E", symbol: "WETH", coinGeckoId: "weth", decimals: 8, price: 1174},
}

flowCancelTokens := []tokenConfigEntry{
{chain: 1, addr: "3b442cb3912157f13a933d0134282d032b5ffecd01a2dbf1b7790608df002ea7", symbol: "USDC", coinGeckoId: "usdc", decimals: 6, price: 1}, // Addr: 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU, Notional: 1
}

chains := []chainConfigEntry{
chainConfigEntry{emitterChainID: vaa.ChainIDSolana, dailyLimit: 100, bigTransactionSize: 75},
chainConfigEntry{emitterChainID: vaa.ChainIDEthereum, dailyLimit: 100000},
{emitterChainID: vaa.ChainIDSolana, dailyLimit: 100, bigTransactionSize: 75},
{emitterChainID: vaa.ChainIDEthereum, dailyLimit: 100000},
}

return tokens, chains
return tokens, flowCancelTokens, chains
}
24 changes: 24 additions & 0 deletions node/pkg/governor/flow_cancel_tokens.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package governor

// FlowCancelTokenList returns a list of `tokenConfigEntry`s representing tokens that can 'Flow Cancel'. This means that incoming transfers
// that use these tokens can reduce the 'daily usage' of the Governor configured for the destination chain.
// The list of tokens was generated by grepping the file `generated_mainnet_tokens.go` for "USDC", "USDT", and "DAI".
//
// Only tokens that are configured in the mainnet token list should be able to flow cancel. That is, if a token is
// present in this list but not in the mainnet token lists, it should not flow cancel.
//
// Note that the field `symbol` is unused. It is retained in this file only for convenience.
func FlowCancelTokenList() []tokenConfigEntry {
johnsaigle marked this conversation as resolved.
Show resolved Hide resolved
return []tokenConfigEntry{
// USDC variants
{chain: 2, addr: "000000000000000000000000bcca60bb61934080951369a648fb03df4f96263c", symbol: "aUSDC"},

// USDT variants
{chain: 1, addr: "b7db4e83eb727f1187bd7a50303f5b4e4e943503da8571ad6564a51131504792", symbol: ""},
{chain: 1, addr: "ce010e60afedb22717bd63192f54145a3f965a33bb82d2c7029eb2ce1e208264", symbol: "USDT"},
{chain: 2, addr: "000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7", symbol: "USDT"},

// DAI variants
{chain: 2, addr: "0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", symbol: "DAI"},
}
}
Loading
Loading