-
Notifications
You must be signed in to change notification settings - Fork 12
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(erc20signersvc): add erc20 reward signer svc #1346
Open
Yaiba
wants to merge
30
commits into
kwilteam:main
Choose a base branch
from
Yaiba:feature/erc20-signersvc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
8f1a7da
feat(erc20signersvc): add erc20 reward signer svc
Yaiba 3089f83
return votes
Yaiba 6bdc421
fix event sync wrong topic
Yaiba 2def39f
fix wrong sql
Yaiba b8c5805
fix epoch finaliz/confirm
Yaiba f931a7a
list wallet rewards
Yaiba c94ea66
fix erc20 signer config
Yaiba 5115e34
fix extension flags parsing
Yaiba b1a40c6
udpate api
Yaiba 6d5f18f
update taskfile
Yaiba f60ca9d
remove sleep before start signerSvc
Yaiba f644782
cleanup
Yaiba 887ce2c
lint
Yaiba 55bcc0f
update erc20 signer config name
Yaiba 0fd3195
use empty array instead of JOIN in list_wallet_epoch
Yaiba 9806648
re-org erc20 and signersvc pkg
Yaiba 6bbe794
return uint256NumericArray instead of TextArray
Yaiba da36253
fix epochConfirmed, use canVoteEpoch instead
Yaiba fba0ec0
change erc20-bridge confiog
Yaiba b0ee050
fix lint
Yaiba 7a97e74
force using websocket rpc provider
Yaiba eb9af22
fix erc20_bridge config
Yaiba cd91dc4
fix erc20 bridge signer config
Yaiba 08c8eeb
remove amount in vote table
Yaiba b63ab7b
fix taskfile
Yaiba 154900e
fix typo
Yaiba bfbca16
use internal ext client
Yaiba 137b281
fix typos
Yaiba 7d03ec7
add bridge method to withdraw balance
Yaiba c5d58a6
remove trivials
Yaiba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,14 @@ import ( | |
"strings" | ||
"time" | ||
|
||
"github.com/pelletier/go-toml/v2" | ||
|
||
ethCommon "github.com/ethereum/go-ethereum/common" | ||
"github.com/kwilteam/kwil-db/core/crypto" | ||
"github.com/kwilteam/kwil-db/core/crypto/auth" | ||
"github.com/kwilteam/kwil-db/core/log" | ||
"github.com/kwilteam/kwil-db/core/types" | ||
|
||
"github.com/pelletier/go-toml/v2" | ||
"github.com/kwilteam/kwil-db/node/exts/evm-sync/chains" | ||
) | ||
|
||
var ( | ||
|
@@ -311,6 +313,11 @@ func DefaultConfig() *Config { | |
Height: 0, | ||
Hash: types.Hash{}, | ||
}, | ||
Erc20Bridge: ERC20BridgeConfig{ | ||
RPC: make(map[string]string), | ||
BlockSyncChuckSize: make(map[string]string), | ||
Signer: make(map[string]string), | ||
}, | ||
} | ||
} | ||
|
||
|
@@ -335,6 +342,7 @@ type Config struct { | |
GenesisState string `toml:"genesis_state" comment:"path to the genesis state file, relative to the root directory"` | ||
Migrations MigrationConfig `toml:"migrations" comment:"zero downtime migration configuration"` | ||
Checkpoint Checkpoint `toml:"checkpoint" comment:"checkpoint info for the leader to sync to before proposing a new block"` | ||
Erc20Bridge ERC20BridgeConfig `toml:"erc20_bridge" comment:"ERC20 bridge configuration"` | ||
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 config is used in two places:
There are few places like oracle still use the general extension config, which I'm not sure if we should move them under |
||
} | ||
|
||
// PeerConfig corresponds to the [p2p] section of the config. | ||
|
@@ -443,6 +451,37 @@ type Checkpoint struct { | |
Hash types.Hash `toml:"hash" comment:"checkpoint block hash."` | ||
} | ||
|
||
type ERC20BridgeConfig struct { | ||
RPC map[string]string `toml:"rpc" comment:"evm websocket RPC; format: chain_name='rpc_url'"` | ||
BlockSyncChuckSize map[string]string `toml:"block_sync_chuck_size" comment:"rpc option block sync chunk size; format: chain_name='chunk_size'"` | ||
Signer map[string]string `toml:"signer" comment:"signer service configuration; format: ext_alias='file_path_to_private_key'"` | ||
} | ||
|
||
// Validate validates the bridge general config, other validations will be performed | ||
// when correspond components derive config from it. | ||
// BlockSyncChuckSize config will be validated by evm-sync listener. | ||
// Signer config will be validated by erc20 signerSvc. | ||
func (cfg ERC20BridgeConfig) Validate() error { | ||
for chain, rpc := range cfg.RPC { | ||
if err := chains.Chain(strings.ToLower(chain)).Valid(); err != nil { | ||
return fmt.Errorf("erc20_bridge.rpc: %s", chain) | ||
} | ||
|
||
// enforce websocket | ||
if !strings.HasPrefix(rpc, "wss://") && !strings.HasPrefix(rpc, "ws://") { | ||
return fmt.Errorf("erc20_bridge.rpc: must start with wss:// or ws://") | ||
} | ||
} | ||
|
||
for _, pkPath := range cfg.Signer { | ||
if !ethCommon.FileExist(pkPath) { | ||
return fmt.Errorf("erc20_bridge.signer: private key file %s not found", pkPath) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// ToTOML marshals the config to TOML. The `toml` struct field tag | ||
// specifies the field names. For example: | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
the 3rd part can have values like URL
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.
good catch