Merge pull request #10190 from filecoin-project/fix/eth-block-unclehash
fix: ethtypes: Correct 'no uncles' hash in NewEthBlock
This commit is contained in:
commit
a5043f45d3
@ -22,6 +22,7 @@ import (
|
|||||||
builtintypes "github.com/filecoin-project/go-state-types/builtin"
|
builtintypes "github.com/filecoin-project/go-state-types/builtin"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
"github.com/filecoin-project/lotus/lib/must"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -157,15 +158,17 @@ type EthBlock struct {
|
|||||||
var (
|
var (
|
||||||
EmptyEthBloom = [256]byte{}
|
EmptyEthBloom = [256]byte{}
|
||||||
EmptyEthHash = EthHash{}
|
EmptyEthHash = EthHash{}
|
||||||
|
EmptyUncleHash = must.One(ParseEthHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347")) // Keccak-256 of an RLP of an empty array
|
||||||
|
EmptyRootHash = must.One(ParseEthHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")) // Keccak-256 hash of the RLP of null
|
||||||
EmptyEthInt = EthUint64(0)
|
EmptyEthInt = EthUint64(0)
|
||||||
EmptyEthNonce = [8]byte{0, 0, 0, 0, 0, 0, 0, 0}
|
EmptyEthNonce = [8]byte{0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewEthBlock() EthBlock {
|
func NewEthBlock(hasTransactions bool) EthBlock {
|
||||||
return EthBlock{
|
b := EthBlock{
|
||||||
Sha3Uncles: EmptyEthHash,
|
Sha3Uncles: EmptyUncleHash, // Sha3Uncles set to a hardcoded value which is used by some clients to determine if has no uncles.
|
||||||
StateRoot: EmptyEthHash,
|
StateRoot: EmptyEthHash,
|
||||||
TransactionsRoot: EmptyEthHash,
|
TransactionsRoot: EmptyRootHash, // TransactionsRoot set to a hardcoded value which is used by some clients to determine if has no transactions.
|
||||||
ReceiptsRoot: EmptyEthHash,
|
ReceiptsRoot: EmptyEthHash,
|
||||||
Difficulty: EmptyEthInt,
|
Difficulty: EmptyEthInt,
|
||||||
LogsBloom: EmptyEthBloom[:],
|
LogsBloom: EmptyEthBloom[:],
|
||||||
@ -176,6 +179,11 @@ func NewEthBlock() EthBlock {
|
|||||||
Uncles: []EthHash{},
|
Uncles: []EthHash{},
|
||||||
Transactions: []interface{}{},
|
Transactions: []interface{}{},
|
||||||
}
|
}
|
||||||
|
if hasTransactions {
|
||||||
|
b.TransactionsRoot = EmptyEthHash
|
||||||
|
}
|
||||||
|
|
||||||
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
type EthCall struct {
|
type EthCall struct {
|
||||||
|
9
lib/must/must.go
Normal file
9
lib/must/must.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package must
|
||||||
|
|
||||||
|
func One[R any](r R, err error) R {
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
@ -1598,7 +1598,7 @@ func newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types.TipSet, fullTx
|
|||||||
return ethtypes.EthBlock{}, xerrors.Errorf("error loading messages for tipset: %v: %w", ts, err)
|
return ethtypes.EthBlock{}, xerrors.Errorf("error loading messages for tipset: %v: %w", ts, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
block := ethtypes.NewEthBlock()
|
block := ethtypes.NewEthBlock(len(msgs) > 0)
|
||||||
|
|
||||||
// this seems to be a very expensive way to get gasUsed of the block. may need to find an efficient way to do it
|
// this seems to be a very expensive way to get gasUsed of the block. may need to find an efficient way to do it
|
||||||
gasUsed := int64(0)
|
gasUsed := int64(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user