@@ -21,11 +21,18 @@ import (
21
21
"github.com/iotexproject/iotex-core/action"
22
22
"github.com/iotexproject/iotex-core/action/protocol"
23
23
"github.com/iotexproject/iotex-core/action/protocol/rewarding"
24
+ "github.com/iotexproject/iotex-core/blockchain/genesis"
24
25
"github.com/iotexproject/iotex-core/pkg/log"
25
26
)
26
27
27
- // ErrInconsistentNonce is the error that the nonce is different from executor's nonce
28
- var ErrInconsistentNonce = errors .New ("Nonce is not identical to executor nonce" )
28
+ var (
29
+ // TODO: whenever ActionGasLimit is removed from genesis, we need to hard code it to 5M to make it compatible with
30
+ // the mainnet.
31
+ preAleutianActionGasLimit = genesis .Default .ActionGasLimit
32
+
33
+ // ErrInconsistentNonce is the error that the nonce is different from executor's nonce
34
+ ErrInconsistentNonce = errors .New ("Nonce is not identical to executor nonce" )
35
+ )
29
36
30
37
// CanTransfer checks whether the from account has enough balance
31
38
func CanTransfer (db vm.StateDB , fromHash common.Address , balance * big.Int ) bool {
@@ -65,16 +72,12 @@ func NewHeightChange(pacific, aleutian uint64) HeightChange {
65
72
}
66
73
67
74
// NewParams creates a new context for use in the EVM.
68
- func NewParams (raCtx protocol.RunActionsCtx , execution * action.Execution , stateDB * StateDBAdapter ) (* Params , error ) {
69
- // If we don't have an explicit author (i.e. not mining), extract from the header
70
- /*
71
- var beneficiary common.Address
72
- if author == nil {
73
- beneficiary, _ = chain.Engine().Author(header) // Ignore error, we're past header validation
74
- } else {
75
- beneficiary = *author
76
- }
77
- */
75
+ func NewParams (
76
+ raCtx protocol.RunActionsCtx ,
77
+ execution * action.Execution ,
78
+ stateDB * StateDBAdapter ,
79
+ hc HeightChange ,
80
+ ) (* Params , error ) {
78
81
executorAddr := common .BytesToAddress (raCtx .Caller .Bytes ())
79
82
var contractAddrPointer * common.Address
80
83
if execution .Contract () != action .EmptyAddress {
@@ -85,20 +88,19 @@ func NewParams(raCtx protocol.RunActionsCtx, execution *action.Execution, stateD
85
88
contractAddr := common .BytesToAddress (contract .Bytes ())
86
89
contractAddrPointer = & contractAddr
87
90
}
88
- producer := common .BytesToAddress (raCtx .Producer .Bytes ())
89
91
90
92
gasLimit := execution .GasLimit ()
91
93
// Reset gas limit to the system wide action gas limit cap if it's greater than it
92
- if gasLimit > raCtx . ActionGasLimit {
93
- gasLimit = raCtx . ActionGasLimit
94
+ if raCtx . BlockHeight < hc . AleutianHeight && gasLimit > preAleutianActionGasLimit {
95
+ gasLimit = preAleutianActionGasLimit
94
96
}
95
97
96
98
context := vm.Context {
97
99
CanTransfer : CanTransfer ,
98
100
Transfer : MakeTransfer ,
99
101
GetHash : GetHashFn (stateDB ),
100
102
Origin : executorAddr ,
101
- Coinbase : producer ,
103
+ Coinbase : common . BytesToAddress ( raCtx . Producer . Bytes ()) ,
102
104
BlockNumber : new (big.Int ).SetUint64 (raCtx .BlockHeight ),
103
105
Time : new (big.Int ).SetInt64 (raCtx .BlockTimeStamp .Unix ()),
104
106
Difficulty : new (big.Int ).SetUint64 (uint64 (50 )),
@@ -112,7 +114,7 @@ func NewParams(raCtx protocol.RunActionsCtx, execution *action.Execution, stateD
112
114
raCtx .Caller .String (),
113
115
execution .Amount (),
114
116
contractAddrPointer ,
115
- execution . GasLimit () ,
117
+ gasLimit ,
116
118
execution .Data (),
117
119
}, nil
118
120
}
@@ -157,7 +159,7 @@ func ExecuteContract(
157
159
) ([]byte , * action.Receipt , error ) {
158
160
raCtx := protocol .MustGetRunActionsCtx (ctx )
159
161
stateDB := NewStateDBAdapter (cm , sm , & hc , raCtx .BlockHeight , execution .Hash ())
160
- ps , err := NewParams (raCtx , execution , stateDB )
162
+ ps , err := NewParams (raCtx , execution , stateDB , hc )
161
163
if err != nil {
162
164
return nil , nil , err
163
165
}
0 commit comments