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

Implement EIP-2718 #359

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
8253211
implements RLP encoding/decoding processing for structs
trinhdn2 Jun 16, 2023
fa67be8
Update RLP lib
trinhdn2 Jun 16, 2023
9b5dadb
Implement RLP encoder code generation tool
trinhdn2 Jun 16, 2023
ddf35f8
Update unit tests and benchmark
trinhdn2 Jun 16, 2023
17e4876
Include RLPgen tool to CI
trinhdn2 Jun 20, 2023
aa7c4b4
Add benchmarks for types RLP encoding/decoding
trinhdn2 Jun 21, 2023
ac89cd3
Generate RLP encoder for some structs
trinhdn2 Jun 21, 2023
060f4ce
Convert status of receipts from uint to uint64
trinhdn2 Jun 21, 2023
eb9b6c5
Move Message from package types to core
trinhdn2 Jun 20, 2023
71c3cfe
Add BaseFee to block and header struct
trinhdn2 Jun 20, 2023
d32c96d
Implement EIP-2718 base structure
trinhdn2 Jun 20, 2023
2b9b5e1
Fix unit tests
trinhdn2 Jun 20, 2023
47a5cee
Add transaction types to receipts
trinhdn2 Jun 21, 2023
2746f63
Generate JSON codec of AccessList
trinhdn2 Jun 21, 2023
a08a0e4
Regen gencodec of some structs
trinhdn2 Jun 21, 2023
ccdd83d
Implement eip2930Signer as a wrapper to handle all transaction types
trinhdn2 Jun 22, 2023
112df1f
Add Berlin fork block to chain config to indicate EIP-2930 signer
trinhdn2 Jun 23, 2023
baf7713
Implement londonSigner to handle dynamicFeeTx
trinhdn2 Jun 23, 2023
e5f3390
Check fork block
trinhdn2 Jun 23, 2023
b78e67e
Fix comparing TxByPriceAndTime
trinhdn2 Jun 23, 2023
fc3d7cf
Add block unit tests
trinhdn2 Jun 23, 2023
e5ee2d0
Fix storage size of transactions
trinhdn2 Jun 26, 2023
0ea51ca
Add London signer to MakeSigner function
trinhdn2 Jun 26, 2023
83ff4fa
Fix balanceToFee
trinhdn2 Jun 26, 2023
529a6f4
Add support for EIP-2718 in abi/bind package
trinhdn2 Jun 27, 2023
5e0ffdc
Modify gas price oracle and API backend interface
trinhdn2 Jun 27, 2023
6098691
Fix balanceTokenFee in doCall
trinhdn2 Jun 27, 2023
5179223
Calculate header BaseFee in worker and chain maker
trinhdn2 Jun 27, 2023
4980fca
CalBaseFee
trinhdn2 Jun 27, 2023
989bb51
Modify puppeth tool to adapt London hardfork
trinhdn2 Jun 28, 2023
314a965
Let sendRawTransaction API accept new tx types
trinhdn2 Jun 28, 2023
3c89cb1
Implement BASEFEE opcode and include it in EVM context
trinhdn2 Jun 28, 2023
83f9500
Remove legacy callMsg struct in simulated backend
trinhdn2 Jun 28, 2023
bf66ac1
Modify RPC APIs to adapt new formats
trinhdn2 Jun 28, 2023
9ed5d30
Test calBaseFee and gasLimit for new London blocks
trinhdn2 Jun 28, 2023
ecee2f1
Txpool validate new tx types
trinhdn2 Jun 30, 2023
eee5851
Calculate intrinsic gas of access list tx
trinhdn2 Jun 30, 2023
4ccb1ca
Fix hashing transactions
trinhdn2 Jun 30, 2023
0d54f0d
Fix transactions' size
trinhdn2 Jun 30, 2023
b122c91
Specify EIP-1559 gas field when call contract in simulatedBackend
trinhdn2 Jul 3, 2023
25d7be8
Fix mobile
trinhdn2 Jul 3, 2023
1218d2c
Implement BlockNumberOrHash and some api backend methods
trinhdn2 Jul 3, 2023
7d492e2
[WIP] Fix sorting txs by nonce and price
trinhdn2 Jul 4, 2023
1b1f5f8
Fix some RPC APIs to adapt Hardhat
trinhdn2 Jul 4, 2023
f659ea0
Fix eth_estimate Gas API
trinhdn2 Jul 4, 2023
58f1d13
Derive more external field for receipts
trinhdn2 Jul 4, 2023
43a5a97
Optimize getStorageAt API
trinhdn2 Jul 5, 2023
78f392b
Fix NewTransactionsByPriceAndNonce
trinhdn2 Jul 5, 2023
56fd5d4
Force not ignoring special txs
trinhdn2 Jul 5, 2023
59ffc82
Fix wrapping first normal tx in Fix NewTransactionsByPriceAndNonce
trinhdn2 Jul 5, 2023
bcb96bf
Implement gas cap and eth_call timeout to prevent DoS
trinhdn2 Jul 5, 2023
a399863
Add more RPC flags
trinhdn2 Jul 5, 2023
b8de2d7
Fix receipt RLP panic
trinhdn2 Jul 5, 2023
938ab4b
Minor fix
trinhdn2 Jul 6, 2023
a8e89d9
Revert GetBlockReceipts interface and some minor fixes
trinhdn2 Jul 6, 2023
f6d5a58
Fix eth and les unit tests
trinhdn2 Jul 6, 2023
f9db4df
Fix light package unit tests
trinhdn2 Jul 6, 2023
9dc9ae5
Fix core package unit tests
trinhdn2 Jul 6, 2023
281251e
Fix main cmd package unit tests
trinhdn2 Jul 6, 2023
4e9ac23
Fix unit tests cont.
trinhdn2 Jul 7, 2023
cb7f8ee
Fix unit tests cont.
trinhdn2 Jul 7, 2023
dbcb9fb
[WIP] Update simulated backend to test special transactions
trinhdn2 Jul 7, 2023
127fa6c
[WIP] Special contracts test units
trinhdn2 Jul 7, 2023
d5beefc
[WIP] Special contracts test units
trinhdn2 Jul 7, 2023
482df9a
[WIP] Fix eth downloader unit tests
trinhdn2 Jul 7, 2023
25a4ac2
[WIP] Fix puppeth
trinhdn2 Jul 9, 2023
4a5b98c
Fix puppeth
trinhdn2 Jul 10, 2023
76627c8
[WIP] Fix contracts unit tests
trinhdn2 Jul 11, 2023
4aa9718
Fix special contracts unit tests
trinhdn2 Jul 11, 2023
f8a0de9
Fix simulated EstimateGas
trinhdn2 Jul 11, 2023
4105a20
Merge pull request #1 from trinhdn2/fix/london-unit-tests
trinhdn2 Jul 11, 2023
57eb63a
Fix preState tracer unit tests
trinhdn2 Jul 11, 2023
8e7cf69
Fix call tracer tests
trinhdn2 Jul 12, 2023
6ce00c8
Implement LRU common package
trinhdn2 Jul 12, 2023
df825bb
Add CacheLogSizeFlag
trinhdn2 Jul 12, 2023
242c5eb
Update filters package and unit tests
trinhdn2 Jul 12, 2023
e0749ce
Fix filter unit tests
trinhdn2 Jul 12, 2023
d213640
Fix downloader unit tests
trinhdn2 Jul 12, 2023
6ecbedf
Fix eth fetcher unit tests
trinhdn2 Jul 12, 2023
4f0d9bd
Expose StoredReceiptRLP struct
trinhdn2 Jul 12, 2023
71341a0
Fix backwards compatibility with receipts
trinhdn2 Jul 13, 2023
b5ff4fc
Decode legacy receipts with legacy LogForStorage struct
trinhdn2 Jul 13, 2023
6859a4f
Use the correct chainConfig when getEVM
trinhdn2 Jul 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 54 additions & 2 deletions accounts/abi/bind/auth.go
Expand Up @@ -17,17 +17,26 @@
package bind

import (
"context"
"crypto/ecdsa"
"errors"
"io"
"io/ioutil"
"math/big"

"github.com/tomochain/tomochain/accounts/keystore"
"github.com/tomochain/tomochain/common"
"github.com/tomochain/tomochain/core/types"
"github.com/tomochain/tomochain/crypto"
"github.com/tomochain/tomochain/log"
)

// ErrNoChainID is returned whenever the user failed to specify a chain id.
var ErrNoChainID = errors.New("no chain id specified")

// ErrNotAuthorized is returned when an account is not properly unlocked.
var ErrNotAuthorized = errors.New("not authorized to sign this account")

// NewTransactor is a utility method to easily create a transaction signer from
// an encrypted json key stream and the associated passphrase.
func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
Expand All @@ -42,21 +51,64 @@ func NewTransactor(keyin io.Reader, passphrase string) (*TransactOpts, error) {
return NewKeyedTransactor(key.PrivateKey), nil
}

// NewTransactorWithChainID is a utility method to easily create a transaction signer from
// an encrypted json key stream and the associated passphrase.
func NewTransactorWithChainID(keyin io.Reader, passphrase string, chainID *big.Int) (*TransactOpts, error) {
json, err := io.ReadAll(keyin)
if err != nil {
return nil, err
}
key, err := keystore.DecryptKey(json, passphrase)
if err != nil {
return nil, err
}
return NewKeyedTransactorWithChainID(key.PrivateKey, chainID)
}

// NewKeyedTransactor is a utility method to easily create a transaction signer
// from a single private key.
//
// Deprecated: Use NewKeyedTransactorWithChainID instead.
func NewKeyedTransactor(key *ecdsa.PrivateKey) *TransactOpts {
log.Warn("WARNING: NewKeyedTransactor has been deprecated in favour of NewKeyedTransactorWithChainID")
keyAddr := crypto.PubkeyToAddress(key.PublicKey)
signer := types.HomesteadSigner{}
return &TransactOpts{
From: keyAddr,
Signer: func(signer types.Signer, address common.Address, tx *types.Transaction) (*types.Transaction, error) {
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
if address != keyAddr {
return nil, errors.New("not authorized to sign this account")
return nil, ErrNotAuthorized
}
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), key)
if err != nil {
return nil, err
}
return tx.WithSignature(signer, signature)
},
Context: context.Background(),
}
}

// NewKeyedTransactorWithChainID is a utility method to easily create a transaction signer
// from a single private key.
func NewKeyedTransactorWithChainID(key *ecdsa.PrivateKey, chainID *big.Int) (*TransactOpts, error) {
keyAddr := crypto.PubkeyToAddress(key.PublicKey)
if chainID == nil {
return nil, ErrNoChainID
}
signer := types.LatestSignerForChainID(chainID)
return &TransactOpts{
From: keyAddr,
Signer: func(address common.Address, tx *types.Transaction) (*types.Transaction, error) {
if address != keyAddr {
return nil, ErrNotAuthorized
}
signature, err := crypto.Sign(signer.Hash(tx).Bytes(), key)
if err != nil {
return nil, err
}
return tx.WithSignature(signer, signature)
},
Context: context.Background(),
}, nil
}
6 changes: 6 additions & 0 deletions accounts/abi/bind/backend.go
Expand Up @@ -67,13 +67,19 @@ type PendingContractCaller interface {
// used when the user does not provide some needed values, but rather leaves it up
// to the transactor to decide.
type ContractTransactor interface {
// HeaderByNumber returns a block header from the current canonical chain. If
// number is nil, the latest known header is returned.
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
// PendingCodeAt returns the code of the given account in the pending state.
PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
// PendingNonceAt retrieves the current pending nonce associated with an account.
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
// SuggestGasPrice retrieves the currently suggested gas price to allow a timely
// execution of a transaction.
SuggestGasPrice(ctx context.Context) (*big.Int, error)
// SuggestGasTipCap retrieves the currently suggested 1559 priority fee to allow
// a timely execution of a transaction.
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
// EstimateGas tries to estimate the gas needed to execute a specific
// transaction based on the current pending state of the backend blockchain.
// There is no guarantee that this is the true gas limit requirement as other
Expand Down