Skip to content

Commit 951fae0

Browse files
author
Leo Chen
committed
[config] add ReceiptLogEpoch
Signed-off-by: Leo Chen <[email protected]>
1 parent 4cf5160 commit 951fae0

File tree

2 files changed

+41
-23
lines changed

2 files changed

+41
-23
lines changed

core/state_processor.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
166166
if msg.To() == nil {
167167
receipt.ContractAddress = crypto.CreateAddress(vmenv.Context.Origin, tx.Nonce())
168168
}
169+
169170
// Set the receipt logs and create a bloom for filtering
170-
receipt.Logs = statedb.GetLogs(tx.Hash())
171+
if config.IsReceiptLog(header.Epoch()) {
172+
receipt.Logs = statedb.GetLogs(tx.Hash())
173+
}
171174
receipt.Bloom = types.CreateBloom(types.Receipts{receipt})
172175

173176
var cxReceipt *types.CXReceipt

internal/params/config.go

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,33 @@ var EpochTBD = big.NewInt(10000000)
2323
var (
2424
// MainnetChainConfig is the chain parameters to run a node on the main network.
2525
MainnetChainConfig = &ChainConfig{
26-
ChainID: MainnetChainID,
27-
CrossTxEpoch: big.NewInt(28),
28-
CrossLinkEpoch: EpochTBD,
29-
EIP155Epoch: big.NewInt(28),
30-
S3Epoch: big.NewInt(28),
26+
ChainID: MainnetChainID,
27+
CrossTxEpoch: big.NewInt(28),
28+
CrossLinkEpoch: EpochTBD,
29+
EIP155Epoch: big.NewInt(28),
30+
S3Epoch: big.NewInt(28),
31+
ReceiptLogEpoch: big.NewInt(101),
3132
}
3233

3334
// TestnetChainConfig contains the chain parameters to run a node on the harmony test network.
3435
TestnetChainConfig = &ChainConfig{
35-
ChainID: TestnetChainID,
36-
CrossTxEpoch: big.NewInt(1),
37-
CrossLinkEpoch: big.NewInt(2),
38-
EIP155Epoch: big.NewInt(0),
39-
S3Epoch: big.NewInt(0),
36+
ChainID: TestnetChainID,
37+
CrossTxEpoch: big.NewInt(1),
38+
CrossLinkEpoch: big.NewInt(2),
39+
EIP155Epoch: big.NewInt(0),
40+
S3Epoch: big.NewInt(0),
41+
ReceiptLogEpoch: big.NewInt(0),
4042
}
4143

4244
// PangaeaChainConfig contains the chain parameters for the Pangaea network.
4345
// All features except for CrossLink are enabled at launch.
4446
PangaeaChainConfig = &ChainConfig{
45-
ChainID: PangaeaChainID,
46-
CrossTxEpoch: big.NewInt(0),
47-
CrossLinkEpoch: EpochTBD,
48-
EIP155Epoch: big.NewInt(0),
49-
S3Epoch: big.NewInt(0),
47+
ChainID: PangaeaChainID,
48+
CrossTxEpoch: big.NewInt(0),
49+
CrossLinkEpoch: EpochTBD,
50+
EIP155Epoch: big.NewInt(0),
51+
S3Epoch: big.NewInt(0),
52+
ReceiptLogEpoch: big.NewInt(0),
5053
}
5154

5255
// AllProtocolChanges ...
@@ -58,6 +61,7 @@ var (
5861
big.NewInt(0), // CrossLinkEpoch
5962
big.NewInt(0), // EIP155Epoch
6063
big.NewInt(0), // S3Epoch
64+
big.NewInt(0), // ReceiptLogEpoch
6165
}
6266

6367
// TestChainConfig ...
@@ -69,6 +73,7 @@ var (
6973
big.NewInt(0), // CrossLinkEpoch
7074
big.NewInt(0), // EIP155Epoch
7175
big.NewInt(0), // S3Epoch
76+
big.NewInt(0), // ReceiptLogEpoch
7277
}
7378

7479
// TestRules ...
@@ -109,15 +114,19 @@ type ChainConfig struct {
109114

110115
// S3 epoch is the first epoch containing S3 mainnet and all ethereum update up to Constantinople
111116
S3Epoch *big.Int `json:"s3-epoch,omitempty"`
117+
118+
// ReceiptLogEpoch is the first epoch support receiptlog
119+
ReceiptLogEpoch *big.Int `json:"receipt-log-epoch,omitempty"`
112120
}
113121

114122
// String implements the fmt.Stringer interface.
115123
func (c *ChainConfig) String() string {
116-
return fmt.Sprintf("{ChainID: %v EIP155: %v CrossTx: %v CrossLink: %v}",
124+
return fmt.Sprintf("{ChainID: %v EIP155: %v CrossTx: %v CrossLink: %v ReceiptLog: %v}",
117125
c.ChainID,
118126
c.EIP155Epoch,
119127
c.CrossTxEpoch,
120128
c.CrossLinkEpoch,
129+
c.ReceiptLogEpoch,
121130
)
122131
}
123132

@@ -151,6 +160,11 @@ func (c *ChainConfig) IsS3(epoch *big.Int) bool {
151160
return isForked(c.S3Epoch, epoch)
152161
}
153162

163+
// IsReceiptLog returns whether epoch is either equal to the ReceiptLog fork epoch or greater.
164+
func (c *ChainConfig) IsReceiptLog(epoch *big.Int) bool {
165+
return isForked(c.ReceiptLogEpoch, epoch)
166+
}
167+
154168
// GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).
155169
//
156170
// The returned GasTable's fields shouldn't, under any circumstances, be changed.
@@ -259,8 +273,8 @@ func (err *ConfigCompatError) Error() string {
259273
// Rules is a one time interface meaning that it shouldn't be used in between transition
260274
// phases.
261275
type Rules struct {
262-
ChainID *big.Int
263-
IsCrossLink, IsEIP155, IsS3 bool
276+
ChainID *big.Int
277+
IsCrossLink, IsEIP155, IsS3, IsReceiptLog bool
264278
}
265279

266280
// Rules ensures c's ChainID is not nil.
@@ -270,9 +284,10 @@ func (c *ChainConfig) Rules(epoch *big.Int) Rules {
270284
chainID = new(big.Int)
271285
}
272286
return Rules{
273-
ChainID: new(big.Int).Set(chainID),
274-
IsCrossLink: c.IsCrossLink(epoch),
275-
IsEIP155: c.IsEIP155(epoch),
276-
IsS3: c.IsS3(epoch),
287+
ChainID: new(big.Int).Set(chainID),
288+
IsCrossLink: c.IsCrossLink(epoch),
289+
IsEIP155: c.IsEIP155(epoch),
290+
IsS3: c.IsS3(epoch),
291+
IsReceiptLog: c.IsReceiptLog(epoch),
277292
}
278293
}

0 commit comments

Comments
 (0)