Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
add change legacetx as default evm to accesslist tx
Browse files Browse the repository at this point in the history
  • Loading branch information
P1sar committed Jul 8, 2021
1 parent 126d6ac commit 5a65432
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions chains/evm/evmclient/evm-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ func (c *EVMClient) PendingCallContract(ctx context.Context, callArgs map[string
return hex, nil
}

//func (c *EVMClient) ChainID()

func (c *EVMClient) SignAndSendTransaction(ctx context.Context, tx CommonTransaction) (common.Hash, error) {
id, err := c.ChainID(ctx)
if err != nil {
Expand Down
12 changes: 10 additions & 2 deletions chains/evm/evmtransaction/evm-tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@ func (a *TX) RawWithSignature(key *ecdsa.PrivateKey, chainID *big.Int) ([]byte,
return rawTX, nil
}

func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *TX {
tx := types.NewTransaction(nonce, to, amount, gasLimit, gasPrice, data)
func NewTransaction(chainID *big.Int, nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *TX {
tx := types.NewTx(&types.AccessListTx{
ChainID: chainID,
Nonce: nonce,
To: &to,
Value: amount,
Gas: gasLimit,
GasPrice: gasPrice,
Data: data})
//_ = types.NewTransaction(nonce, to, amount, gasLimit, gasPrice, data)
return &TX{tx}
}

Expand Down
12 changes: 8 additions & 4 deletions chains/evm/voter/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ func (p *Proposal) Execute(client ChainClient) error {
if err != nil {
return err
}
log.Debug().Str("hash", h.Hex()).Uint64("nonce", n.Uint64()).Msgf("Executed")
err = client.UnsafeIncreaseNonce()
if err != nil {
return err
}
client.UnlockNonce()
log.Debug().Str("hash", h.Hex()).Uint64("nonce", n.Uint64()).Msgf("Executed")
return nil
}

Expand All @@ -132,17 +132,21 @@ func (p *Proposal) Vote(client ChainClient) error {
if err != nil {
return err
}
tx := evmtransaction.NewTransaction(n.Uint64(), p.BridgeAddress, big.NewInt(0), gasLimit, gp, input)
h, err := client.SignAndSendTransaction(context.TODO(), tx)
cid, err := client.ChainID(context.Background())
if err != nil {
return err
}
tx := evmtransaction.NewTransaction(cid, n.Uint64(), p.BridgeAddress, big.NewInt(0), gasLimit, gp, input)
_, err = client.SignAndSendTransaction(context.TODO(), tx)
if err != nil {
return err
}
log.Debug().Str("hash", tx.Hash().String()).Uint64("nonce", n.Uint64()).Str("chainID", cid.String()).Msgf("Voted")
err = client.UnsafeIncreaseNonce()
if err != nil {
return err
}
client.UnlockNonce()
log.Debug().Str("hash", h.Hex()).Uint64("nonce", n.Uint64()).Msgf("Voted")
return nil
}

Expand Down
1 change: 1 addition & 0 deletions chains/evm/voter/voter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ChainClient interface {
UnlockNonce()
UnsafeIncreaseNonce() error
GasPrice() (*big.Int, error)
ChainID(ctx context.Context) (*big.Int, error)
}

type Proposer interface {
Expand Down

0 comments on commit 5a65432

Please sign in to comment.