Merge pull request #998 from maticnetwork/v1.0.0-beta-candidate

V1.0.0 beta candidate
This commit is contained in:
Pratik Patil 2023-09-12 21:41:19 +05:30 committed by GitHub
commit 3442c0336d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 317 additions and 107 deletions

View file

@ -38,9 +38,9 @@ syncmode = "full"
# nodekeyhex = ""
[p2p.discovery]
# v5disc = false
bootnodes = ["enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303", "enode://88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710@159.203.9.164:30303"]
bootnodes = ["enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303"]
# Uncomment below `bootnodes` field for Mumbai bootnode
# bootnodes = ["enode://095c4465fe509bd7107bbf421aea0d3ad4d4bfc3ff8f9fdc86f4f950892ae3bbc3e5c715343c4cf60c1c06e088e621d6f1b43ab9130ae56c2cacfd356a284ee4@18.213.200.99:30303"]
# bootnodes = ["enode://bdcd4786a616a853b8a041f53496d853c68d99d54ff305615cd91c03cd56895e0a7f6e9f35dbf89131044e2114a9a782b792b5661e3aff07faf125a98606a071@43.200.206.40:30303", "enode://209aaf7ed549cf4a5700fd833da25413f80a1248bd3aa7fe2a87203e3f7b236dd729579e5c8df61c97bf508281bae4969d6de76a7393bcbd04a0af70270333b3@54.216.248.9:30303"]
# bootnodesv4 = []
# bootnodesv5 = []
# static-nodes = []

View file

@ -341,10 +341,6 @@ func (api *API) GetRootHash(start uint64, end uint64) (string, error) {
return root, nil
}
func (api *API) GetVoteOnHash(starBlockNr uint64, endBlockNr uint64, hash string, milestoneId string) (bool, error) {
return false, nil
}
func (api *API) initializeRootHashCache() error {
var err error
if api.rootHashCache == nil {

View file

@ -25,7 +25,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
TxHash common.Hash `json:"transactionHash" gencodec:"required"`
ContractAddress common.Address `json:"contractAddress"`
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
EffectiveGasPrice *big.Int `json:"effectiveGasPrice"`
EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"`
BlockHash common.Hash `json:"blockHash,omitempty"`
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
TransactionIndex hexutil.Uint `json:"transactionIndex"`
@ -40,7 +40,7 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
enc.TxHash = r.TxHash
enc.ContractAddress = r.ContractAddress
enc.GasUsed = hexutil.Uint64(r.GasUsed)
enc.EffectiveGasPrice = r.EffectiveGasPrice
enc.EffectiveGasPrice = (*hexutil.Big)(r.EffectiveGasPrice)
enc.BlockHash = r.BlockHash
enc.BlockNumber = (*hexutil.Big)(r.BlockNumber)
enc.TransactionIndex = hexutil.Uint(r.TransactionIndex)
@ -59,7 +59,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
TxHash *common.Hash `json:"transactionHash" gencodec:"required"`
ContractAddress *common.Address `json:"contractAddress"`
GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
EffectiveGasPrice *big.Int `json:"effectiveGasPrice"`
EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"`
BlockHash *common.Hash `json:"blockHash,omitempty"`
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
TransactionIndex *hexutil.Uint `json:"transactionIndex"`
@ -101,7 +101,7 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
}
r.GasUsed = uint64(*dec.GasUsed)
if dec.EffectiveGasPrice != nil {
r.EffectiveGasPrice = dec.EffectiveGasPrice
r.EffectiveGasPrice = (*big.Int)(dec.EffectiveGasPrice)
}
if dec.BlockHash != nil {
r.BlockHash = *dec.BlockHash

View file

@ -76,6 +76,7 @@ type receiptMarshaling struct {
PostState hexutil.Bytes
Status hexutil.Uint64
CumulativeGasUsed hexutil.Uint64
EffectiveGasPrice *hexutil.Big
GasUsed hexutil.Uint64
BlockNumber *hexutil.Big
TransactionIndex hexutil.Uint

View file

@ -85,7 +85,7 @@ var mainnetBor = &Chain{
Alloc: readPrealloc("allocs/mainnet.json"),
},
Bootnodes: []string{
"enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303",
"enode://88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710@159.203.9.164:30303",
"enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303",
"enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303",
},
}

View file

@ -78,7 +78,7 @@ var mumbaiTestnet = &Chain{
Alloc: readPrealloc("allocs/mumbai.json"),
},
Bootnodes: []string{
"enode://320553cda00dfc003f499a3ce9598029f364fbb3ed1222fdc20a94d97dcc4d8ba0cd0bfa996579dcc6d17a534741fb0a5da303a90579431259150de66b597251@54.147.31.250:30303",
"enode://f0f48a8781629f95ff02606081e6e43e4aebd503f3d07fc931fad7dd5ca1ba52bd849a6f6c3be0e375cf13c9ae04d859c4a9ae3546dc8ed4f10aa5dbb47d4998@34.226.134.117:30303",
"enode://bdcd4786a616a853b8a041f53496d853c68d99d54ff305615cd91c03cd56895e0a7f6e9f35dbf89131044e2114a9a782b792b5661e3aff07faf125a98606a071@43.200.206.40:30303",
"enode://209aaf7ed549cf4a5700fd833da25413f80a1248bd3aa7fe2a87203e3f7b236dd729579e5c8df61c97bf508281bae4969d6de76a7393bcbd04a0af70270333b3@54.216.248.9:30303",
},
}

View file

@ -2105,6 +2105,10 @@ func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common.
"effectiveGasPrice": (*hexutil.Big)(receipt.EffectiveGasPrice),
}
if receipt.EffectiveGasPrice == nil {
fields["effectiveGasPrice"] = new(hexutil.Big)
}
// Assign receipt status or post state.
if len(receipt.PostState) > 0 {
fields["root"] = hexutil.Bytes(receipt.PostState)

View file

@ -21,12 +21,59 @@ import (
"math/big"
"testing"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
)
func testTransactionMarshal(t *testing.T, tests []txData, config *params.ChainConfig) {
t.Helper()
t.Parallel()
var (
signer = types.LatestSigner(config)
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
)
for i, tt := range tests {
var tx2 types.Transaction
tx, err := types.SignNewTx(key, signer, tt.Tx)
if err != nil {
t.Fatalf("test %d: signing failed: %v", i, err)
}
// Regular transaction
if data, err := json.Marshal(tx); err != nil {
t.Fatalf("test %d: marshalling failed; %v", i, err)
} else if err = tx2.UnmarshalJSON(data); err != nil {
t.Fatalf("test %d: sunmarshal failed: %v", i, err)
} else if want, have := tx.Hash(), tx2.Hash(); want != have {
t.Fatalf("test %d: stx changed, want %x have %x", i, want, have)
}
// rpcTransaction
rpcTx := newRPCTransaction(tx, common.Hash{}, 0, 0, big.NewInt(0), config)
if data, err := json.Marshal(rpcTx); err != nil {
t.Fatalf("test %d: marshalling failed; %v", i, err)
} else if err = tx2.UnmarshalJSON(data); err != nil {
t.Fatalf("test %d: unmarshal failed: %v", i, err)
} else if want, have := tx.Hash(), tx2.Hash(); want != have {
t.Fatalf("test %d: tx changed, want %x have %x", i, want, have)
} else {
want, have := tt.Want, string(data)
require.JSONEqf(t, want, have, "test %d: rpc json not match, want %s have %s", i, want, have)
}
}
}
type txData struct {
Tx types.TxData
Want string
}
func TestTransaction_RoundTripRpcJSON(t *testing.T) {
var (
config = params.AllEthashProtocolChanges
@ -35,12 +82,12 @@ func TestTransaction_RoundTripRpcJSON(t *testing.T) {
tests = allTransactionTypes(common.Address{0xde, 0xad}, config)
)
t.Parallel()
testTransactionMarshal(t, tests, config)
for i, tt := range tests {
var tx2 types.Transaction
tx, err := types.SignNewTx(key, signer, tt)
tx, err := types.SignNewTx(key, signer, tt.Tx)
if err != nil {
t.Fatalf("test %d: signing failed: %v", i, err)
}
@ -65,9 +112,10 @@ func TestTransaction_RoundTripRpcJSON(t *testing.T) {
}
}
func allTransactionTypes(addr common.Address, config *params.ChainConfig) []types.TxData {
return []types.TxData{
&types.LegacyTx{
func allTransactionTypes(addr common.Address, config *params.ChainConfig) []txData {
return []txData{
{
Tx: &types.LegacyTx{
Nonce: 5,
GasPrice: big.NewInt(6),
Gas: 7,
@ -78,7 +126,26 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []type
R: big.NewInt(10),
S: big.NewInt(11),
},
&types.LegacyTx{
Want: `{
"blockHash": null,
"blockNumber": null,
"from": "0x71562b71999873db5b286df957af199ec94617f7",
"gas": "0x7",
"gasPrice": "0x6",
"hash": "0x5f3240454cd09a5d8b1c5d651eefae7a339262875bcd2d0e6676f3d989967008",
"input": "0x0001020304",
"nonce": "0x5",
"to": "0xdead000000000000000000000000000000000000",
"transactionIndex": null,
"value": "0x8",
"type": "0x0",
"chainId": "0x539",
"v": "0xa96",
"r": "0xbc85e96592b95f7160825d837abb407f009df9ebe8f1b9158a4b8dd093377f75",
"s": "0x1b55ea3af5574c536967b039ba6999ef6c89cf22fc04bcb296e0e8b0b9b576f5"
}`,
}, {
Tx: &types.LegacyTx{
Nonce: 5,
GasPrice: big.NewInt(6),
Gas: 7,
@ -89,7 +156,27 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []type
R: big.NewInt(10),
S: big.NewInt(11),
},
&types.AccessListTx{
Want: `{
"blockHash": null,
"blockNumber": null,
"from": "0x71562b71999873db5b286df957af199ec94617f7",
"gas": "0x7",
"gasPrice": "0x6",
"hash": "0x806e97f9d712b6cb7e781122001380a2837531b0fc1e5f5d78174ad4cb699873",
"input": "0x0001020304",
"nonce": "0x5",
"to": null,
"transactionIndex": null,
"value": "0x8",
"type": "0x0",
"chainId": "0x539",
"v": "0xa96",
"r": "0x9dc28b267b6ad4e4af6fe9289668f9305c2eb7a3241567860699e478af06835a",
"s": "0xa0b51a071aa9bed2cd70aedea859779dff039e3630ea38497d95202e9b1fec7"
}`,
},
{
Tx: &types.AccessListTx{
ChainID: config.ChainID,
Nonce: 5,
GasPrice: big.NewInt(6),
@ -107,7 +194,34 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []type
R: big.NewInt(10),
S: big.NewInt(11),
},
&types.AccessListTx{
Want: `{
"blockHash": null,
"blockNumber": null,
"from": "0x71562b71999873db5b286df957af199ec94617f7",
"gas": "0x7",
"gasPrice": "0x6",
"hash": "0x121347468ee5fe0a29f02b49b4ffd1c8342bc4255146bb686cd07117f79e7129",
"input": "0x0001020304",
"nonce": "0x5",
"to": "0xdead000000000000000000000000000000000000",
"transactionIndex": null,
"value": "0x8",
"type": "0x1",
"accessList": [
{
"address": "0x0200000000000000000000000000000000000000",
"storageKeys": [
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
]
}
],
"chainId": "0x539",
"v": "0x0",
"r": "0xf372ad499239ae11d91d34c559ffc5dab4daffc0069e03afcabdcdf231a0c16b",
"s": "0x28573161d1f9472fa0fd4752533609e72f06414f7ab5588699a7141f65d2abf"
}`,
}, {
Tx: &types.AccessListTx{
ChainID: config.ChainID,
Nonce: 5,
GasPrice: big.NewInt(6),
@ -125,7 +239,34 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []type
R: big.NewInt(10),
S: big.NewInt(11),
},
&types.DynamicFeeTx{
Want: `{
"blockHash": null,
"blockNumber": null,
"from": "0x71562b71999873db5b286df957af199ec94617f7",
"gas": "0x7",
"gasPrice": "0x6",
"hash": "0x067c3baebede8027b0f828a9d933be545f7caaec623b00684ac0659726e2055b",
"input": "0x0001020304",
"nonce": "0x5",
"to": null,
"transactionIndex": null,
"value": "0x8",
"type": "0x1",
"accessList": [
{
"address": "0x0200000000000000000000000000000000000000",
"storageKeys": [
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
]
}
],
"chainId": "0x539",
"v": "0x1",
"r": "0x542981b5130d4613897fbab144796cb36d3cb3d7807d47d9c7f89ca7745b085c",
"s": "0x7425b9dd6c5deaa42e4ede35d0c4570c4624f68c28d812c10d806ffdf86ce63"
}`,
}, {
Tx: &types.DynamicFeeTx{
ChainID: config.ChainID,
Nonce: 5,
GasTipCap: big.NewInt(6),
@ -144,7 +285,36 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []type
R: big.NewInt(10),
S: big.NewInt(11),
},
&types.DynamicFeeTx{
Want: `{
"blockHash": null,
"blockNumber": null,
"from": "0x71562b71999873db5b286df957af199ec94617f7",
"gas": "0x7",
"gasPrice": "0x9",
"maxFeePerGas": "0x9",
"maxPriorityFeePerGas": "0x6",
"hash": "0xb63e0b146b34c3e9cb7fbabb5b3c081254a7ded6f1b65324b5898cc0545d79ff",
"input": "0x0001020304",
"nonce": "0x5",
"to": "0xdead000000000000000000000000000000000000",
"transactionIndex": null,
"value": "0x8",
"type": "0x2",
"accessList": [
{
"address": "0x0200000000000000000000000000000000000000",
"storageKeys": [
"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
]
}
],
"chainId": "0x539",
"v": "0x1",
"r": "0x3b167e05418a8932cd53d7578711fe1a76b9b96c48642402bb94978b7a107e80",
"s": "0x22f98a332d15ea2cc80386c1ebaa31b0afebfa79ebc7d039a1e0074418301fef"
}`,
}, {
Tx: &types.DynamicFeeTx{
ChainID: config.ChainID,
Nonce: 5,
GasTipCap: big.NewInt(6),
@ -158,5 +328,27 @@ func allTransactionTypes(addr common.Address, config *params.ChainConfig) []type
R: big.NewInt(10),
S: big.NewInt(11),
},
Want: `{
"blockHash": null,
"blockNumber": null,
"from": "0x71562b71999873db5b286df957af199ec94617f7",
"gas": "0x7",
"gasPrice": "0x9",
"maxFeePerGas": "0x9",
"maxPriorityFeePerGas": "0x6",
"hash": "0xcbab17ee031a9d5b5a09dff909f0a28aedb9b295ac0635d8710d11c7b806ec68",
"input": "0x0001020304",
"nonce": "0x5",
"to": null,
"transactionIndex": null,
"value": "0x8",
"type": "0x2",
"accessList": [],
"chainId": "0x539",
"v": "0x0",
"r": "0x6446b8a682db7e619fc6b4f6d1f708f6a17351a41c7fbd63665f469bc78b41b9",
"s": "0x7626abc15834f391a117c63450047309dbf84c5ce3e8e609b607062641e2de43"
}`,
},
}
}

View file

@ -139,6 +139,9 @@ func GetAPIs(apiBackend Backend) []rpc.API {
}, {
Namespace: "personal",
Service: NewPersonalAccountAPI(apiBackend, nonceLock),
}, {
Namespace: "bor",
Service: NewBorAPI(apiBackend),
},
}
}

View file

@ -51,3 +51,17 @@ func (s *BlockChainAPI) appendRPCMarshalBorTransaction(ctx context.Context, bloc
return fields
}
// EthereumAPI provides an API to access Ethereum related information.
type BorAPI struct {
b Backend
}
// NewEthereumAPI creates a new Ethereum protocol API.
func NewBorAPI(b Backend) *BorAPI {
return &BorAPI{b}
}
func (api *BorAPI) GetVoteOnHash(ctx context.Context, starBlockNr uint64, endBlockNr uint64, hash string, milestoneId string) (bool, error) {
return api.b.GetVoteOnHash(ctx, starBlockNr, endBlockNr, hash, milestoneId)
}

View file

@ -70,15 +70,15 @@ var GoerliBootnodes = []string{
// MumbaiBootnodes are the enode URLs of the P2P bootstrap nodes running on the
// Mumbai test network.
var MumbaiBootnodes = []string{
"enode://320553cda00dfc003f499a3ce9598029f364fbb3ed1222fdc20a94d97dcc4d8ba0cd0bfa996579dcc6d17a534741fb0a5da303a90579431259150de66b597251@54.147.31.250:30303",
"enode://f0f48a8781629f95ff02606081e6e43e4aebd503f3d07fc931fad7dd5ca1ba52bd849a6f6c3be0e375cf13c9ae04d859c4a9ae3546dc8ed4f10aa5dbb47d4998@34.226.134.117:30303",
"enode://bdcd4786a616a853b8a041f53496d853c68d99d54ff305615cd91c03cd56895e0a7f6e9f35dbf89131044e2114a9a782b792b5661e3aff07faf125a98606a071@43.200.206.40:30303",
"enode://209aaf7ed549cf4a5700fd833da25413f80a1248bd3aa7fe2a87203e3f7b236dd729579e5c8df61c97bf508281bae4969d6de76a7393bcbd04a0af70270333b3@54.216.248.9:30303",
}
// BorMainnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the
// main Bor network.
var BorMainnetBootnodes = []string{
"enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303",
"enode://88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710@159.203.9.164:30303",
"enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303",
"enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303",
}
var KilnBootnodes = []string{