erigon-pulse/params/eip_ctx.go

55 lines
1.3 KiB
Go
Raw Normal View History

package params
import (
"context"
"math/big"
)
type configKey int
const (
IsHomesteadEnabled configKey = iota
IsEIP150Enabled
IsEIP155Enabled
IsEIP158Enabled
IsByzantiumEnabled
IsConstantinopleEnabled
IsPetersburgEnabled
BlockNumber
WithHistoryHighest
)
Aleut support (Eip1559) (#1704) * Where I am at * Refactoring of transaction types * More refactoring * Use Homested signer in rpc daemon * Unified signer * Continue unified signer * A bit more * Fixes and down the rabbit hole... * More tx pool fixes * More refactoring fixes * More fixes' * more fixes * More fixes * More compile fixes * More RLP hand-writing * Finish RLP encoding/decoding of transactions * Fixes to header encoding, start on protocol packets * Transaction decoding * Use DecodeTransaction function * Decoding BlockBodyPacket * Encode and decode for pool txs * Start fixing tests * Introduce SigningHash * Fixes to SignHash * RLP encoding fixes * Fixes for encoding/decoding * More test fixes * Fix more tests * More test fixes * More test fixes * Fix core tests * More fixes for signer * Fix for tx * Fixes to string encoding/size * Fix eip2930 test * Fix rest of ./tests * More fixes * Fix compilation * More test fixes * More test fixes * Test fixes * More fixes * Reuse EncodingSize in EncodeRLP for accessList * Rearrange things in dynamic fee tx * Add MarshalBinary * More fixes * Make V,R,S non-pointers * More NPE fixes * More fixes * Receipt fixes * Fix core/types * Fix ./eth * More compile fixes for tests * More test fixes * More test fixes * Try to see lint errors better * Try to see lint errors better * Fix lint * Debugging eip1559 test * Fix TestEIP1559Transition test * Fix NewBlockPacket encoding/decoding * Fix calculation of TxHash * Fix perf problem with senders * Update aleut config values * Try adding static peers * Add staticpeers to defaul flags * Change aleut networkID * Fix test Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2021-04-22 17:11:37 +00:00
func (c *ChainConfig) WithEIPsFlags(ctx context.Context, blockNum uint64) context.Context {
ctx = context.WithValue(ctx, IsHomesteadEnabled, c.IsHomestead(blockNum))
ctx = context.WithValue(ctx, IsEIP150Enabled, c.IsEIP150(blockNum))
ctx = context.WithValue(ctx, IsEIP155Enabled, c.IsEIP155(blockNum))
ctx = context.WithValue(ctx, IsEIP158Enabled, c.IsEIP158(blockNum))
ctx = context.WithValue(ctx, IsByzantiumEnabled, c.IsByzantium(blockNum))
ctx = context.WithValue(ctx, IsConstantinopleEnabled, c.IsConstantinople(blockNum))
ctx = context.WithValue(ctx, IsPetersburgEnabled, c.IsPetersburg(blockNum))
ctx = context.WithValue(ctx, BlockNumber, blockNum)
return ctx
}
func GetForkFlag(ctx context.Context, name configKey) bool {
b := ctx.Value(name)
if b == nil {
return false
}
if valB, ok := b.(bool); ok {
return valB
}
return false
}
func GetBlockNumber(ctx context.Context) *big.Int {
b := ctx.Value(BlockNumber)
if b == nil {
return nil
}
if valB, ok := b.(*big.Int); ok {
return valB
}
return nil
}