Fix warp message SourceChainID conversions and formatting

- Fixed aggregator test to use byte slice conversion
- Auto-formatted all Go files with gofmt and goimports
- Fixed import ordering
This commit is contained in:
2025-09-21 21:25:23 +00:00
parent 58982a9df0
commit 07ccb13bed
60 changed files with 197 additions and 169 deletions
+1 -1
View File
@@ -34,10 +34,10 @@ import (
"testing"
"time"
"github.com/luxfi/crypto"
"github.com/luxfi/evm/accounts/abi/bind"
"github.com/luxfi/evm/ethclient/simulated"
"github.com/luxfi/evm/params"
"github.com/luxfi/crypto"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/core/types"
)
+1 -1
View File
@@ -426,7 +426,7 @@ func isValidFieldName(fieldName string) bool {
return false
}
if !(isLetter(c) || unicode.IsDigit(c)) {
if !isLetter(c) && !unicode.IsDigit(c) {
return false
}
}
+1 -1
View File
@@ -306,7 +306,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
// If the transaction created a contract, store the creation address in the receipt.
if msg.To == nil {
var cryptoAddr crypto.Address
copy(cryptoAddr[:], evm.TxContext.Origin[:])
copy(cryptoAddr[:], evm.Origin[:])
createdAddr := crypto.CreateAddress(cryptoAddr, tx.Nonce())
receipt.ContractAddress = common.BytesToAddress(createdAddr[:])
}
+5 -5
View File
@@ -14,10 +14,10 @@ import (
type contextKey string
const (
chainIDKey contextKey = "chainID"
networkIDKey contextKey = "networkID"
subnetIDKey contextKey = "subnetID"
warpSignerKey contextKey = "warpSigner"
chainIDKey contextKey = "chainID"
networkIDKey contextKey = "networkID"
subnetIDKey contextKey = "subnetID"
warpSignerKey contextKey = "warpSigner"
)
// GetChainID retrieves the chain ID from the context
@@ -102,4 +102,4 @@ func GetValidator(ctx context.Context) interface{} {
return v
}
return nil
}
}
-1
View File
@@ -31,7 +31,6 @@ import (
"testing"
)
func TestCalcGasLimit(t *testing.T) {
for i, tc := range []struct {
pGasLimit uint64
+1
View File
@@ -60,6 +60,7 @@ import (
"github.com/luxfi/geth/metrics"
"github.com/luxfi/geth/triedb"
"github.com/luxfi/log"
// "github.com/luxfi/evm/triedb/firewood"
"github.com/luxfi/geth/triedb/hashdb"
"github.com/luxfi/geth/triedb/pathdb"
+41 -14
View File
@@ -62,8 +62,11 @@ type rewindTest struct {
// committed to disk and then the process crashed. In this case we expect the full
// chain to be rolled back to the committed block, but the chain data itself left
// in the database for replaying.
func TestShortRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding"); testShortRepair(t, false) }
func TestShortRepairWithSnapshots(t *testing.T) { t.Skip("TODO: Fix genesis funding"); testShortRepair(t, true) }
func TestShortRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding"); testShortRepair(t, false) }
func TestShortRepairWithSnapshots(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testShortRepair(t, true)
}
func testShortRepair(t *testing.T, snapshots bool) {
// Chain:
@@ -98,8 +101,14 @@ func testShortRepair(t *testing.T, snapshots bool) {
// test scenario the side chain is below the committed block. In this case we expect
// the canonical chain to be rolled back to the committed block, but the chain data
// itself left in the database for replaying.
func TestShortOldForkedRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding"); testShortOldForkedRepair(t, false) }
func TestShortOldForkedRepairWithSnapshots(t *testing.T) { t.Skip("TODO: Fix genesis funding"); testShortOldForkedRepair(t, true) }
func TestShortOldForkedRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testShortOldForkedRepair(t, false)
}
func TestShortOldForkedRepairWithSnapshots(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testShortOldForkedRepair(t, true)
}
func testShortOldForkedRepair(t *testing.T, snapshots bool) {
// Chain:
@@ -136,7 +145,10 @@ func testShortOldForkedRepair(t *testing.T, snapshots bool) {
// test scenario the side chain reaches above the committed block. In this case we
// expect the canonical chain to be rolled back to the committed block, but the
// chain data itself left in the database for replaying.
func TestShortNewlyForkedRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding"); testShortNewlyForkedRepair(t, false) }
func TestShortNewlyForkedRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testShortNewlyForkedRepair(t, false)
}
func TestShortNewlyForkedRepairWithSnapshots(t *testing.T) { testShortNewlyForkedRepair(t, true) }
func testShortNewlyForkedRepair(t *testing.T, snapshots bool) {
@@ -173,7 +185,10 @@ func testShortNewlyForkedRepair(t *testing.T, snapshots bool) {
// recent block was already committed to disk and then the process crashed. In this
// case we expect the canonical chain to be rolled back to the committed block, but
// the chain data itself left in the database for replaying.
func TestShortReorgedRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding"); testShortReorgedRepair(t, false) }
func TestShortReorgedRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testShortReorgedRepair(t, false)
}
func TestShortReorgedRepairWithSnapshots(t *testing.T) { testShortReorgedRepair(t, true) }
func testShortReorgedRepair(t *testing.T, snapshots bool) {
@@ -210,7 +225,10 @@ func testShortReorgedRepair(t *testing.T, snapshots bool) {
// committed to disk and then the process crashed. In this case we expect the chain
// to be rolled back to the committed block, but the chain data itself left in the
// database for replaying.
func TestLongShallowRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding"); testLongShallowRepair(t, false) }
func TestLongShallowRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testLongShallowRepair(t, false)
}
func TestLongShallowRepairWithSnapshots(t *testing.T) { testLongShallowRepair(t, true) }
func testLongShallowRepair(t *testing.T, snapshots bool) {
@@ -244,7 +262,10 @@ func testLongShallowRepair(t *testing.T, snapshots bool) {
// Tests a recovery for a long canonical chain where a recent block was already committed
// to disk and then the process crashed. In this case we expect the chain to be rolled
// back to the committed block, but the chain data itself left in the database for replaying.
func TestLongDeepRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding"); testLongDeepRepair(t, false) }
func TestLongDeepRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testLongDeepRepair(t, false)
}
func TestLongDeepRepairWithSnapshots(t *testing.T) {
testLongDeepRepair(t, true)
}
@@ -282,7 +303,8 @@ func testLongDeepRepair(t *testing.T, snapshots bool) {
// the side chain is below the committed block. In this case we expect the chain to be
// rolled back to the committed block, but the chain data itself left in the database
// for replaying.
func TestLongOldForkedShallowRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding");
func TestLongOldForkedShallowRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testLongOldForkedShallowRepair(t, false)
}
func TestLongOldForkedShallowRepairWithSnapshots(t *testing.T) {
@@ -323,7 +345,8 @@ func testLongOldForkedShallowRepair(t *testing.T, snapshots bool) {
// was already committed to disk and then the process crashed. In this test scenario the side
// chain is below the committed block. In this case we expect the canonical chain to be
// rolled back to the committed block, but the chain data itself left in the database for replaying.
func TestLongOldForkedDeepRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding");
func TestLongOldForkedDeepRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testLongOldForkedDeepRepair(t, false)
}
func TestLongOldForkedDeepRepairWithSnapshots(t *testing.T) {
@@ -364,7 +387,8 @@ func testLongOldForkedDeepRepair(t *testing.T, snapshots bool) {
// block was already committed to disk and then the process crashed. In this test scenario
// the side chain is above the committed block. In this case we expect the chain to be
// rolled back to the committed block, but the chain data itself left in the database for replaying.
func TestLongNewerForkedShallowRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding");
func TestLongNewerForkedShallowRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testLongNewerForkedShallowRepair(t, false)
}
func TestLongNewerForkedShallowRepairWithSnapshots(t *testing.T) {
@@ -405,7 +429,8 @@ func testLongNewerForkedShallowRepair(t *testing.T, snapshots bool) {
// was already committed to disk and then the process crashed. In this test scenario the side
// chain is above the committed block. In this case we expect the canonical chain to be rolled
// back to the committed block, but the chain data itself left in the database for replaying.
func TestLongNewerForkedDeepRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding");
func TestLongNewerForkedDeepRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testLongNewerForkedDeepRepair(t, false)
}
func TestLongNewerForkedDeepRepairWithSnapshots(t *testing.T) {
@@ -445,7 +470,8 @@ func testLongNewerForkedDeepRepair(t *testing.T, snapshots bool) {
// Tests a recovery for a long canonical chain with a longer side chain, where a recent block
// was already committed to disk and then the process crashed. In this case we expect the chain to be
// rolled back to the committed block, but the chain data itself left in the database for replaying.
func TestLongReorgedShallowRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding");
func TestLongReorgedShallowRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testLongReorgedShallowRepair(t, false)
}
func TestLongReorgedShallowRepairWithSnapshots(t *testing.T) {
@@ -486,7 +512,8 @@ func testLongReorgedShallowRepair(t *testing.T, snapshots bool) {
// was already committed to disk and then the process crashed. In this case we expect the canonical
// chains to be rolled back to the committed block, but the chain data itself left in the database
// for replaying.
func TestLongReorgedDeepRepair(t *testing.T) { t.Skip("TODO: Fix genesis funding");
func TestLongReorgedDeepRepair(t *testing.T) {
t.Skip("TODO: Fix genesis funding")
testLongReorgedDeepRepair(t, false)
}
func TestLongReorgedDeepRepairWithSnapshots(t *testing.T) {
+3 -2
View File
@@ -52,6 +52,7 @@ import (
"github.com/luxfi/geth/trie"
"github.com/luxfi/geth/triedb"
gethpathdb "github.com/luxfi/geth/triedb/pathdb"
// "github.com/luxfi/evm/triedb/firewood"
"github.com/davecgh/go-spew/spew"
"github.com/luxfi/evm/triedb/pathdb"
@@ -302,7 +303,7 @@ func TestPrecompileActivationAfterHeaderBlock(t *testing.T) {
activatedGenesisConfig := params.Copy(customg.Config)
contractDeployerConfig := deployerallowlist.NewConfig(utils.NewUint64(51), nil, nil, nil)
params.GetExtra(&activatedGenesisConfig).UpgradeConfig.PrecompileUpgrades = []extras.PrecompileUpgrade{
params.GetExtra(&activatedGenesisConfig).PrecompileUpgrades = []extras.PrecompileUpgrade{
{
Config: contractDeployerConfig,
},
@@ -340,7 +341,7 @@ func TestGenesisWriteUpgradesRegression(t *testing.T) {
_, _, err := SetupGenesisBlock(db, trieDB, genesis, genesisBlock.Hash(), false)
require.NoError(err)
params.GetExtra(genesis.Config).UpgradeConfig.PrecompileUpgrades = []extras.PrecompileUpgrade{
params.GetExtra(genesis.Config).PrecompileUpgrades = []extras.PrecompileUpgrade{
{
Config: deployerallowlist.NewConfig(utils.NewUint64(51), nil, nil, nil),
},
+2 -1
View File
@@ -14,6 +14,7 @@ import (
"github.com/luxfi/geth/core/types"
"github.com/luxfi/geth/trie/trienode"
"github.com/luxfi/geth/triedb"
// "github.com/luxfi/evm/triedb/firewood"
"github.com/holiman/uint256"
"github.com/luxfi/geth/triedb/hashdb"
@@ -98,7 +99,7 @@ func newFuzzState(t *testing.T) *fuzzState {
return &fuzzState{
merkleTries: []*merkleTrie{
&merkleTrie{
{
name: "hash",
ethDatabase: hashState,
accountTrie: hashTr,
+1 -1
View File
@@ -78,7 +78,7 @@ type workerPool struct {
func (wp *workerPool) Done() {
// Done is guaranteed to only be called after all work is already complete,
// so we call Wait for goroutines to finish before returning.
wp.BoundedWorkers.Wait()
wp.Wait()
}
// TODO: PrefetcherOption and WithWorkerPools seem to be removed from geth
+9 -9
View File
@@ -97,11 +97,11 @@ func (np *noPruningTrieWriter) InsertTrie(block *types.Block) error {
func (np *noPruningTrieWriter) AcceptTrie(block *types.Block) error {
// We don't need to call [Dereference] on the block root at the end of this
// function because it is removed from the [TrieDB.Dirties] map in [Commit].
return np.TrieDB.Commit(block.Root(), false)
return np.Commit(block.Root(), false)
}
func (np *noPruningTrieWriter) RejectTrie(block *types.Block) error {
return np.TrieDB.Dereference(block.Root())
return np.Dereference(block.Root())
}
func (np *noPruningTrieWriter) Shutdown() error { return nil }
@@ -120,11 +120,11 @@ type cappedMemoryTrieWriter struct {
func (cm *cappedMemoryTrieWriter) InsertTrie(block *types.Block) error {
// The use of [Cap] in [InsertTrie] prevents exceeding the configured memory
// limit (and OOM) in case there is a large backlog of processing (unaccepted) blocks.
_, nodes, imgs := cm.TrieDB.Size() // all memory is contained within the nodes return for hashdb
_, nodes, imgs := cm.Size() // all memory is contained within the nodes return for hashdb
if nodes <= cm.memoryCap && imgs <= cm.imageCap {
return nil
}
if err := cm.TrieDB.Cap(cm.memoryCap - ethdb.IdealBatchSize); err != nil {
if err := cm.Cap(cm.memoryCap - ethdb.IdealBatchSize); err != nil {
return fmt.Errorf("failed to cap trie for block %s: %w", block.Hash().Hex(), err)
}
@@ -146,7 +146,7 @@ func (cm *cappedMemoryTrieWriter) AcceptTrie(block *types.Block) error {
// Commit this root if we have reached the [commitInterval].
modCommitInterval := block.NumberU64() % cm.commitInterval
if modCommitInterval == 0 {
if err := cm.TrieDB.Commit(root, true); err != nil {
if err := cm.Commit(root, true); err != nil {
return fmt.Errorf("failed to commit trie for block %s: %w", block.Hash().Hex(), err)
}
return nil
@@ -168,19 +168,19 @@ func (cm *cappedMemoryTrieWriter) AcceptTrie(block *types.Block) error {
return nil
}
targetMemory := cm.targetCommitSize + cm.flushStepSize*common.StorageSize(distanceFromCommit)
_, nodes, _ := cm.TrieDB.Size()
_, nodes, _ := cm.Size()
if nodes <= targetMemory {
return nil
}
targetCap := targetMemory - ethdb.IdealBatchSize
if err := cm.TrieDB.Cap(targetCap); err != nil {
if err := cm.Cap(targetCap); err != nil {
return fmt.Errorf("failed to cap trie for block %s (target=%s): %w", block.Hash().Hex(), targetCap, err)
}
return nil
}
func (cm *cappedMemoryTrieWriter) RejectTrie(block *types.Block) error {
cm.TrieDB.Dereference(block.Root())
cm.Dereference(block.Root())
return nil
}
@@ -194,5 +194,5 @@ func (cm *cappedMemoryTrieWriter) Shutdown() error {
// Attempt to commit last item added to [dereferenceQueue] on shutdown to avoid
// re-processing the state on the next startup.
return cm.TrieDB.Commit(last, true)
return cm.Commit(last, true)
}
+1 -1
View File
@@ -161,7 +161,7 @@ func applyTransaction(msg *Message, config *params.ChainConfig, gp *GasPool, sta
if msg.To == nil {
// Convert common.Address to crypto.Address
var cryptoAddr crypto.Address
copy(cryptoAddr[:], evm.TxContext.Origin[:])
copy(cryptoAddr[:], evm.Origin[:])
createdAddr := crypto.CreateAddress(cryptoAddr, tx.Nonce())
// Convert crypto.Address back to common.Address
receipt.ContractAddress = common.BytesToAddress(createdAddr[:])
+6 -7
View File
@@ -59,10 +59,9 @@ func u64(val uint64) *uint64 { return &val }
// contain invalid transactions
func TestStateProcessorErrors(t *testing.T) {
// Test state processor functionality
cpcfg := params.Copy(params.TestChainConfig)
config := &cpcfg
config.ShanghaiTime = u64(0)
config.CancunTime = u64(0)
// Use TestSubnetEVMChainConfig which has SubnetEVM enabled
config := params.TestSubnetEVMChainConfig
// Override the MinBaseFee for this test
params.GetExtra(config).FeeConfig.MinBaseFee = big.NewInt(legacy.BaseFee)
var (
@@ -124,7 +123,7 @@ func TestStateProcessorErrors(t *testing.T) {
Nonce: 0,
},
},
GasLimit: params.GetExtra(params.TestChainConfig).FeeConfig.GasLimit.Uint64(),
GasLimit: params.GetExtra(config).FeeConfig.GasLimit.Uint64(),
}
tooBigInitCode = [ethparams.MaxInitCodeSize + 1]byte{}
)
@@ -286,7 +285,7 @@ func TestStateProcessorErrors(t *testing.T) {
Nonce: 0,
},
},
GasLimit: params.GetExtra(params.TestChainConfig).FeeConfig.GasLimit.Uint64(),
GasLimit: params.GetExtra(config).FeeConfig.GasLimit.Uint64(),
}
)
blockchain, err := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)
@@ -329,7 +328,7 @@ func TestStateProcessorErrors(t *testing.T) {
Code: common.FromHex("0xB0B0FACE"),
},
},
GasLimit: params.GetExtra(params.TestChainConfig).FeeConfig.GasLimit.Uint64(),
GasLimit: params.GetExtra(config).FeeConfig.GasLimit.Uint64(),
}
)
blockchain, err := NewBlockChain(db, DefaultCacheConfig, gspec, dummy.NewCoinbaseFaker(), vm.Config{}, common.Hash{}, false)
+2 -3
View File
@@ -70,7 +70,6 @@ var (
)
// Chain configuration with Cancun enabled.
//
var testChainConfig *params.ChainConfig
func init() {
@@ -82,8 +81,8 @@ func init() {
params.GetExtra(testChainConfig).FeeConfig.MinBaseFee = new(big.Int).SetUint64(1)
// Set SubnetEVMTimestamp to enable base fee calculation
params.GetExtra(testChainConfig).NetworkUpgrades.SubnetEVMTimestamp = new(uint64)
*params.GetExtra(testChainConfig).NetworkUpgrades.SubnetEVMTimestamp = 0
params.GetExtra(testChainConfig).SubnetEVMTimestamp = new(uint64)
*params.GetExtra(testChainConfig).SubnetEVMTimestamp = 0
testChainConfig.CancunTime = new(uint64)
*testChainConfig.CancunTime = uint64(time.Now().Unix())
+1
View File
@@ -38,6 +38,7 @@ import (
"github.com/luxfi/geth/core/types"
"github.com/luxfi/geth/event"
"github.com/luxfi/log"
// "github.com/luxfi/metric" // TODO: Add metrics support
"github.com/luxfi/evm/core"
)
+1 -1
View File
@@ -39,7 +39,7 @@ func ExampleExecute() {
if err != nil {
fmt.Println(err)
}
fmt.Println(ret)
fmt.Println(string(ret))
// Output:
// [96 96 96 64 82 96 8 86 91 0]
}
-1
View File
@@ -36,7 +36,6 @@ import (
"sync"
"time"
"github.com/luxfi/evm/consensus"
"github.com/luxfi/evm/core"
"github.com/luxfi/evm/core/bloombits"
View File
+3 -3
View File
@@ -800,7 +800,7 @@ func TestEstimateGas(t *testing.T) {
From: &accounts[0].addr,
To: &accounts[1].addr,
Value: (*hexutil.Big)(big.NewInt(1)),
BlobHashes: []common.Hash{common.Hash{0x01, 0x22}},
BlobHashes: []common.Hash{{0x01, 0x22}},
BlobFeeCap: (*hexutil.Big)(big.NewInt(1)),
},
want: 21000,
@@ -1007,7 +1007,7 @@ func TestCall(t *testing.T) {
call: TransactionArgs{
From: &accounts[1].addr,
To: &randomAccounts[2].addr,
BlobHashes: []common.Hash{common.Hash{0x01, 0x22}},
BlobHashes: []common.Hash{{0x01, 0x22}},
BlobFeeCap: (*hexutil.Big)(big.NewInt(1)),
},
overrides: StateOverride{
@@ -1149,7 +1149,7 @@ func TestSendBlobTransaction(t *testing.T) {
From: &b.acc.Address,
To: &to,
Value: (*hexutil.Big)(big.NewInt(1)),
BlobHashes: []common.Hash{common.Hash{0x01, 0x22}},
BlobHashes: []common.Hash{{0x01, 0x22}},
})
if err != nil {
t.Fatalf("failed to fill tx defaults: %v\n", err)
+5 -4
View File
@@ -292,19 +292,20 @@ func newBackendMock() *backendMock {
}
func (b *backendMock) setFork(fork string) error {
if fork == "legacy" {
switch fork {
case "legacy":
b.current.Number = big.NewInt(900)
b.current.Time = 555
} else if fork == "london" {
case "london":
b.current.Number = big.NewInt(1100)
b.current.Time = 555
} else if fork == "cancun" {
case "cancun":
b.current.Number = big.NewInt(1100)
b.current.Time = 700
// Blob base fee will be 2
excess := uint64(2314058)
b.current.ExcessBlobGas = &excess
} else {
default:
return errors.New("invalid fork")
}
return nil
+7 -7
View File
@@ -288,7 +288,7 @@ func SetNetworkUpgradeDefaults(c *ChainConfig) {
// GetExtra(c).NetworkUpgrades.SetDefaults(GetExtra(c).ConsensusCtx.NetworkUpgrades)
// For now, set empty defaults with empty upgrade config
emptyUpgradeConfig := upgrade.Config{}
GetExtra(c).NetworkUpgrades.SetDefaults(emptyUpgradeConfig)
GetExtra(c).SetDefaults(emptyUpgradeConfig)
}
// SetRulesContext associates a Rules instance with its ChainConfig and timestamp
@@ -334,11 +334,11 @@ func GetRulesExtra(rules Rules) RulesExtra {
// Build RulesExtra from extras.Rules
rulesExtra := RulesExtra{
IsSubnetEVM: extrasRules.LuxRules.IsSubnetEVM,
IsDurango: extrasRules.LuxRules.IsDurango,
IsEtna: extrasRules.LuxRules.IsEtna,
IsFortuna: extrasRules.LuxRules.IsFortuna,
IsGranite: extrasRules.LuxRules.IsGranite,
IsSubnetEVM: extrasRules.IsSubnetEVM,
IsDurango: extrasRules.IsDurango,
IsEtna: extrasRules.IsEtna,
IsFortuna: extrasRules.IsFortuna,
IsGranite: extrasRules.IsGranite,
PredicatersExist: len(extrasRules.Predicaters) > 0,
Predicaters: extrasRules.Predicaters,
LuxRules: extrasRules.LuxRules,
@@ -367,7 +367,7 @@ func GetExtrasRules(ethRules Rules, c *ChainConfig, timestamp uint64) *extras.Ru
}
extra := GetExtra(c)
luxRules := extra.NetworkUpgrades.GetLuxRules(timestamp)
luxRules := extra.GetLuxRules(timestamp)
// Build extras.Rules
rules := &extras.Rules{
+5 -5
View File
@@ -135,7 +135,7 @@ func TestCheckCompatible(t *testing.T) {
wantErr: &ethparams.ConfigCompatError{
What: "SubnetEVM fork block timestamp",
StoredTime: utils.NewUint64(0),
NewTime: GetExtra(TestPreSubnetEVMChainConfig).NetworkUpgrades.SubnetEVMTimestamp,
NewTime: GetExtra(TestPreSubnetEVMChainConfig).SubnetEVMTimestamp,
RewindToTime: 0,
},
},
@@ -147,7 +147,7 @@ func TestCheckCompatible(t *testing.T) {
wantErr: &ethparams.ConfigCompatError{
What: "SubnetEVM fork block timestamp",
StoredTime: utils.NewUint64(0),
NewTime: GetExtra(TestPreSubnetEVMChainConfig).NetworkUpgrades.SubnetEVMTimestamp,
NewTime: GetExtra(TestPreSubnetEVMChainConfig).SubnetEVMTimestamp,
RewindToTime: 0,
},
},
@@ -176,19 +176,19 @@ func TestConfigRules(t *testing.T) {
var stamp uint64
// Test that SubnetEVM is not active at timestamp 0
if extra.NetworkUpgrades.IsSubnetEVM(stamp) {
if extra.IsSubnetEVM(stamp) {
t.Errorf("expected timestamp %v to not be SubnetEVM", stamp)
}
stamp = 500
// Test that SubnetEVM is active at timestamp 500
if !extra.NetworkUpgrades.IsSubnetEVM(stamp) {
if !extra.IsSubnetEVM(stamp) {
t.Errorf("expected timestamp %v to be SubnetEVM", stamp)
}
stamp = math.MaxInt64
// Test that SubnetEVM is active at max timestamp
if !extra.NetworkUpgrades.IsSubnetEVM(stamp) {
if !extra.IsSubnetEVM(stamp) {
t.Errorf("expected timestamp %v to be SubnetEVM", stamp)
}
}
+1 -1
View File
@@ -349,7 +349,7 @@ func (c *ChainConfig) Verify() error {
// Verify the network upgrades are internally consistent given the existing chainConfig.
// Use default config for validation
agoUpgrades := upgrade.Config{}
if err := c.NetworkUpgrades.verifyNetworkUpgrades(agoUpgrades); err != nil {
if err := c.verifyNetworkUpgrades(agoUpgrades); err != nil {
return fmt.Errorf("invalid network upgrades: %w", err)
}
+1 -1
View File
@@ -62,7 +62,7 @@ $`,
{
BlockTimestamp: pointer(uint64(14)),
StateUpgradeAccounts: map[common.Address]StateUpgradeAccount{
common.Address{15}: {
{15}: {
Code: []byte{16},
},
},
+2 -2
View File
@@ -279,7 +279,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0), // Genesis
EtnaTimestamp: nil, // Valid when Etna is unscheduled
EtnaTimestamp: nil, // Valid when Etna is unscheduled
},
luxdUpgrades: testMainnetConfig,
valid: true,
@@ -298,7 +298,7 @@ func TestVerifyNetworkUpgrades(t *testing.T) {
name: "Valid_Fortuna_nil",
upgrades: &NetworkUpgrades{
SubnetEVMTimestamp: utils.NewUint64(0),
DurangoTimestamp: utils.NewUint64(0), // Genesis
DurangoTimestamp: utils.NewUint64(0), // Genesis
EtnaTimestamp: utils.NewUint64(500), // Test timestamp
FortunaTimestamp: nil,
},
+1 -1
View File
@@ -61,7 +61,7 @@ func TestVerifyUpgradeConfig(t *testing.T) {
chainConfig := chainConfig
// verify with the upgrades from the test
chainConfig.UpgradeConfig.PrecompileUpgrades = tt.upgrades
chainConfig.PrecompileUpgrades = tt.upgrades
err := chainConfig.Verify()
if tt.expectedErrorString != "" {
+1 -1
View File
@@ -238,7 +238,7 @@ func (b *Block) verify(predicateContext *precompileconfig.PredicateContext, writ
// Additionally, if a block is already in processing, then it has already passed verification and
// at this point we have checked the predicates are still valid in the different context so we
// can return nil.
if b.vm.State.IsProcessing(b.id) {
if b.vm.IsProcessing(b.id) {
return nil
}
+2 -2
View File
@@ -29,8 +29,8 @@ func BlockGasCost(
}
var (
minBlockGasCost uint64 = feeConfig.MinBlockGasCost.Uint64()
maxBlockGasCost uint64 = feeConfig.MaxBlockGasCost.Uint64()
minBlockGasCost = feeConfig.MinBlockGasCost.Uint64()
maxBlockGasCost = feeConfig.MaxBlockGasCost.Uint64()
)
var cost uint64
@@ -2,8 +2,11 @@
package customtypes
import "github.com/luxfi/geth/rlp"
import "io"
import (
"io"
"github.com/luxfi/geth/rlp"
)
func (obj *HeaderSerializable) EncodeRLP(_w io.Writer) error {
w := rlp.NewEncoderBuffer(_w)
+1 -1
View File
@@ -60,7 +60,7 @@ func (db ethDbWrapper) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
copy(newStart[len(prefix):], start)
start = newStart
}
return db.Database.NewIteratorWithStartAndPrefix(start, prefix)
return db.NewIteratorWithStartAndPrefix(start, prefix)
}
// NewIteratorWithStart implements ethdb.Database
+1 -1
View File
@@ -4,4 +4,4 @@
package gossip
// Placeholder for gossip package
type NoOpGossip struct{}
type NoOpGossip struct{}
+1 -1
View File
@@ -59,7 +59,7 @@ func TestGossipSubscribe(t *testing.T) {
// use a custom bloom filter to test the bloom filter reset
gossipTxPool.bloom, err = gossip.NewBloomFilter(prometheus.NewRegistry(), "", 1, 0.01, 0.0000000000000001) // maxCount =1
require.NoError(err)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go gossipTxPool.Subscribe(ctx)
+5 -5
View File
@@ -16,14 +16,14 @@ import (
"github.com/stretchr/testify/require"
// consensusInterfaces "github.com/luxfi/consensus/core/interfaces" // TODO: Remove if not needed
commonEng "github.com/luxfi/node/consensus/engine/core"
consensusBlock "github.com/luxfi/node/consensus/engine/chain/block"
luxdatabase "github.com/luxfi/database"
"github.com/luxfi/database/prefixdb"
"github.com/luxfi/ids"
"github.com/luxfi/node/utils/set"
nodeConsensus "github.com/luxfi/node/consensus"
consensusBlock "github.com/luxfi/node/consensus/engine/chain/block"
commonEng "github.com/luxfi/node/consensus/engine/core"
"github.com/luxfi/node/upgrade/upgradetest"
"github.com/luxfi/node/utils/set"
"github.com/luxfi/crypto"
"github.com/luxfi/crypto/secp256k1"
@@ -336,7 +336,7 @@ func createSyncServerAndClientVMs(t *testing.T, test syncTest, numBlocks int) *s
require.NoError(err)
internalBlock, err := serverVM.vm.parseBlock(context.Background(), blockBytes)
require.NoError(err)
require.NoError(serverVM.vm.State.SetLastAcceptedBlock(internalBlock))
require.NoError(serverVM.vm.SetLastAcceptedBlock(internalBlock))
// patch syncableInterval for test
serverVM.vm.StateSyncServer.(*stateSyncServer).syncableInterval = test.syncableInterval
@@ -469,7 +469,7 @@ func testSyncerVM(t *testing.T, vmSetup *syncVMSetup, test syncTest) {
require.NotNil(msg)
// If the test is expected to error, assert the correct error is returned and finish the test.
err = syncerVM.StateSyncClient.Error()
err = syncerVM.Error()
if test.expectedErr != nil {
require.ErrorIs(err, test.expectedErr)
// Note we re-open the database here to avoid a closed error when the test is for a shutdown VM.
+1 -1
View File
@@ -8,8 +8,8 @@ import (
"testing"
"github.com/luxfi/ids"
"github.com/luxfi/node/utils/set"
nodeCore "github.com/luxfi/node/consensus/engine/core"
"github.com/luxfi/node/utils/set"
)
// TestSender is a test implementation of the Sender interface
+1 -1
View File
@@ -15,13 +15,13 @@ import (
"github.com/luxfi/database/memdb"
"github.com/luxfi/ids"
"github.com/luxfi/log"
"github.com/luxfi/node/utils/set"
nodeConsensus "github.com/luxfi/node/consensus"
"github.com/luxfi/node/network/p2p"
"github.com/luxfi/node/network/p2p/gossip"
"github.com/luxfi/node/proto/pb/sdk"
"github.com/luxfi/node/upgrade/upgradetest"
agoUtils "github.com/luxfi/node/utils"
"github.com/luxfi/node/utils/set"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/require"
+1 -1
View File
@@ -143,7 +143,7 @@ func (m *manager) sync(ctx context.Context) error {
}
// write validators to the database
if err := m.State.WriteState(); err != nil {
if err := m.WriteState(); err != nil {
return fmt.Errorf("failed to write validator state: %w", err)
}
+4 -4
View File
@@ -12,9 +12,9 @@ import (
// Manager tracks validator uptime and connection status
type Manager struct {
uptime.Calculator
state uptime.State
clock interface{}
connected set.Set[ids.NodeID]
state uptime.State
clock interface{}
connected set.Set[ids.NodeID]
}
// NewManager creates a new uptime manager
@@ -64,4 +64,4 @@ func (m *Manager) StopTracking(nodeIDs []ids.NodeID) error {
m.connected.Remove(nodeID)
}
return nil
}
}
+19 -18
View File
@@ -79,15 +79,15 @@ import (
luxRPC "github.com/gorilla/rpc/v2"
nodeConsensus "github.com/luxfi/node/consensus"
"github.com/luxfi/consensus/engine/chain/block"
nodeblock "github.com/luxfi/node/consensus/engine/chain/block"
nodechain "github.com/luxfi/consensus/protocol/chain"
nodeConsensusChain "github.com/luxfi/node/consensus/chain"
consensusmockable "github.com/luxfi/consensus/utils/timer/mockable"
"github.com/luxfi/database/versiondb"
"github.com/luxfi/ids"
"github.com/luxfi/node/codec"
nodeConsensus "github.com/luxfi/node/consensus"
nodeConsensusChain "github.com/luxfi/node/consensus/chain"
nodeblock "github.com/luxfi/node/consensus/engine/chain/block"
"github.com/luxfi/node/upgrade"
"github.com/luxfi/node/utils/perms"
"github.com/luxfi/node/utils/profiler"
@@ -98,8 +98,8 @@ import (
commonEng "github.com/luxfi/consensus/core"
"github.com/luxfi/consensus/core/appsender"
nodeCommonEng "github.com/luxfi/node/consensus/engine/core"
"github.com/luxfi/math/set"
nodeCommonEng "github.com/luxfi/node/consensus/engine/core"
"github.com/luxfi/database"
luxUtils "github.com/luxfi/node/utils"
@@ -383,7 +383,7 @@ func (vm *VM) Initialize(
fxs []*nodeCommonEng.Fx,
appSender nodeCommonEng.AppSender,
) error {
// Convert fxs from []*nodeCommonEng.Fx to []*commonEng.Fx
// Convert fxs from []*nodeCommonEng.Fx to []*commonEng.Fx
typedFxs := make([]*commonEng.Fx, len(fxs))
for i, fx := range fxs {
typedFxs[i] = &commonEng.Fx{
@@ -614,7 +614,7 @@ func (vm *VM) initializeInternal(
return fmt.Errorf("failed to create network: %w", err)
}
// P2PValidators might be nil in test environments
p2pValidatorsInterface := vm.Network.P2PValidators()
p2pValidatorsInterface := vm.P2PValidators()
if p2pValidatorsInterface != nil {
vm.p2pValidators = p2pValidatorsInterface.(*p2p.Validators)
}
@@ -698,7 +698,7 @@ func (vm *VM) initializeInternal(
warpHandler := lp118.NewCachedHandler(meteredCache, warpVerifier, nil)
// Use adapter to convert lp118.Handler to p2p.Handler
p2pHandler := newLP118HandlerAdapter(warpHandler)
vm.Network.AddHandler(lp118.HandlerID, p2pHandler)
vm.AddHandler(lp118.HandlerID, p2pHandler)
vm.setAppRequestHandlers()
@@ -820,8 +820,8 @@ func parseGenesis(ctx context.Context, genesisBytes []byte, upgradeBytes []byte,
configExtra.UpgradeConfig = upgradeConfig
}
if configExtra.UpgradeConfig.NetworkUpgradeOverrides != nil {
overrides := configExtra.UpgradeConfig.NetworkUpgradeOverrides
if configExtra.NetworkUpgradeOverrides != nil {
overrides := configExtra.NetworkUpgradeOverrides
marshaled, err := json.Marshal(overrides)
if err != nil {
log.Warn("Failed to marshal network upgrade overrides", "error", err, "overrides", overrides)
@@ -945,7 +945,7 @@ func (vm *VM) initializeStateSyncClient(lastAcceptedHeight uint64) error {
// If StateSync is disabled, clear any ongoing summary so that we will not attempt to resume
// sync using a snapshot that has been modified by the node running normal operations.
if !vm.config.StateSyncEnabled {
return vm.StateSyncClient.ClearOngoingSummary()
return vm.ClearOngoingSummary()
}
return nil
@@ -1024,11 +1024,11 @@ func (vm *VM) SetState(_ context.Context, state nodeConsensus.State) error {
// onBootstrapStarted marks this VM as bootstrapping
func (vm *VM) onBootstrapStarted() error {
vm.bootstrapped.Set(false)
if err := vm.StateSyncClient.Error(); err != nil {
if err := vm.Error(); err != nil {
return err
}
// After starting bootstrapping, do not attempt to resume a previous state sync.
if err := vm.StateSyncClient.ClearOngoingSummary(); err != nil {
if err := vm.ClearOngoingSummary(); err != nil {
return err
}
// Ensure snapshots are initialized before bootstrapping (i.e., if state sync is skipped).
@@ -1074,10 +1074,10 @@ func (vm *VM) onNormalOperationsStarted() error {
if !ok {
return fmt.Errorf("failed to get P2P validators")
}
ethTxGossipClient = vm.Network.NewClient(TxGossipHandlerID, p2p.WithValidatorSampling(p2pValidators))
ethTxGossipClient = vm.NewClient(TxGossipHandlerID, p2p.WithValidatorSampling(p2pValidators))
} else {
// In test mode, use a client without validator sampling
ethTxGossipClient = vm.Network.NewClient(TxGossipHandlerID)
ethTxGossipClient = vm.NewClient(TxGossipHandlerID)
}
ethTxGossipMetrics, err := gossip.NewMetrics(vm.sdkMetrics, ethTxGossipNamespace)
if err != nil {
@@ -1152,7 +1152,7 @@ func (vm *VM) onNormalOperationsStarted() error {
vm.ethTxGossipHandler = handler
}
if err := vm.Network.AddHandler(TxGossipHandlerID, vm.ethTxGossipHandler); err != nil {
if err := vm.AddHandler(TxGossipHandlerID, vm.ethTxGossipHandler); err != nil {
return fmt.Errorf("failed to add eth tx gossip handler: %w", err)
}
@@ -1208,7 +1208,7 @@ func (vm *VM) setAppRequestHandlers() {
)
networkHandler := newNetworkHandler(vm.blockChain, vm.chaindb, evmTrieDB, vm.warpBackend, vm.networkCodec)
vm.Network.SetRequestHandler(networkHandler)
vm.SetRequestHandler(networkHandler)
}
func (vm *VM) WaitForEvent(ctx context.Context) (nodeCommonEng.Message, error) {
@@ -1516,7 +1516,7 @@ func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error) {
}
if vm.config.WarpAPIEnabled {
warpSDKClient := vm.Network.NewClient(lp118.HandlerID)
warpSDKClient := vm.NewClient(lp118.HandlerID)
// lp118.NewSignatureAggregator expects a node/utils/logging.Logger
// For now, pass nil as the logger is optional
signatureAggregator := lp118.NewSignatureAggregator(nil, warpSDKClient)
@@ -1813,9 +1813,10 @@ type warpVerifierAdapter struct {
func (w *warpVerifierAdapter) Verify(ctx context.Context, msg *nodeWarp.UnsignedMessage, justification []byte) *nodeCommonEng.AppError {
// Convert node warp message to consensus warp message
// Published luxfi/warp v0.1.1 uses []byte for SourceChainID, not ids.ID
luxMsg := &luxWarp.UnsignedMessage{
NetworkID: msg.NetworkID,
SourceChainID: msg.SourceChainID,
SourceChainID: msg.SourceChainID[:], // Convert ids.ID to []byte
Payload: msg.Payload,
}
+6 -4
View File
@@ -29,7 +29,6 @@ import (
commonEng "github.com/luxfi/consensus/core"
// consensusInterfaces "github.com/luxfi/consensus/core/interfaces" // TODO: Remove if not needed
"github.com/luxfi/node/consensus/chain"
"github.com/luxfi/crypto/secp256k1"
"github.com/luxfi/database"
"github.com/luxfi/database/memdb"
@@ -56,12 +55,15 @@ import (
"github.com/luxfi/evm/utils/utilstest"
"github.com/luxfi/ids"
"github.com/luxfi/node/chains/atomic"
"github.com/luxfi/node/consensus/chain"
// "github.com/luxfi/node/upgrade" // TODO: Remove if not needed
"github.com/luxfi/node/upgrade/upgradetest"
nodeConsensus "github.com/luxfi/node/consensus"
"github.com/luxfi/node/upgrade/upgradetest"
// "github.com/luxfi/node/consensus/validators" // TODO: Remove if not needed
"github.com/luxfi/node/utils/set"
luxdconstants "github.com/luxfi/node/utils/constants"
"github.com/luxfi/node/utils/set"
)
var (
@@ -599,7 +601,7 @@ func testBuildEthTxBlock(t *testing.T, scheme string) {
}
// Clear the cache and ensure that GetBlock returns internal blocks with the correct status
tvm.vm.State.Flush()
tvm.vm.Flush()
blk2Refreshed, err := tvm.vm.GetBlockInternal(context.Background(), blk2.ID())
if err != nil {
t.Fatal(err)
@@ -52,7 +52,7 @@ func (d *dummyConfigurator) Configure(
blockContext contract.ConfigurationBlockContext,
) error {
cfg := precompileConfig.(*dummyConfig)
return cfg.AllowListConfig.Configure(chainConfig, dummyAddr, state, blockContext)
return cfg.Configure(chainConfig, dummyAddr, state, blockContext)
}
func TestAllowListRun(t *testing.T) {
@@ -48,5 +48,5 @@ func (c *configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg p
if !ok {
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
}
return config.AllowListConfig.Configure(chainConfig, ContractAddress, state, blockContext)
return config.Configure(chainConfig, ContractAddress, state, blockContext)
}
+1 -1
View File
@@ -63,5 +63,5 @@ func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg pre
return fmt.Errorf("cannot configure fee config in chain config: %w", err)
}
}
return config.AllowListConfig.Configure(chainConfig, ContractAddress, state, blockContext)
return config.Configure(chainConfig, ContractAddress, state, blockContext)
}
@@ -41,13 +41,11 @@ func FuzzPackGetFeeConfigOutputEqualTest(f *testing.F) {
MaxBlockGasCost: bigIntVal,
BlockGasCostStep: bigIntVal,
}
doCheckOutputs := true
doCheckOutputs := !(bigIntVal.Cmp(abi.MaxUint256) > 0)
// we can only check if outputs are correct if the value is less than MaxUint256
// otherwise the value will be truncated when packed,
// and thus unpacked output will not be equal to the value
if bigIntVal.Cmp(abi.MaxUint256) > 0 {
doCheckOutputs = false
}
testOldPackGetFeeConfigOutputEqual(t, feeConfig, doCheckOutputs)
})
}
@@ -171,13 +169,11 @@ func FuzzPackGetLastChangedAtOutput(f *testing.F) {
f.Add(math.MaxBig256.Add(math.MaxBig256, common.Big1).Bytes())
f.Fuzz(func(t *testing.T, bigIntBytes []byte) {
bigIntVal := new(big.Int).SetBytes(bigIntBytes)
doCheckOutputs := true
doCheckOutputs := !(bigIntVal.Cmp(abi.MaxUint256) > 0)
// we can only check if outputs are correct if the value is less than MaxUint256
// otherwise the value will be truncated when packed,
// and thus unpacked output will not be equal to the value
if bigIntVal.Cmp(abi.MaxUint256) > 0 {
doCheckOutputs = false
}
testOldPackGetLastChangedAtOutputEqual(t, bigIntVal, doCheckOutputs)
})
}
@@ -201,13 +197,11 @@ func FuzzPackSetFeeConfigEqualTest(f *testing.F) {
MaxBlockGasCost: bigIntVal,
BlockGasCostStep: bigIntVal,
}
doCheckOutputs := true
doCheckOutputs := !(bigIntVal.Cmp(abi.MaxUint256) > 0)
// we can only check if outputs are correct if the value is less than MaxUint256
// otherwise the value will be truncated when packed,
// and thus unpacked output will not be equal to the value
if bigIntVal.Cmp(abi.MaxUint256) > 0 {
doCheckOutputs = false
}
testOldPackSetFeeConfigInputEqual(t, feeConfig, doCheckOutputs)
})
}
+1 -1
View File
@@ -59,5 +59,5 @@ func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg pre
}
}
return config.AllowListConfig.Configure(chainConfig, ContractAddress, state, blockContext)
return config.Configure(chainConfig, ContractAddress, state, blockContext)
}
@@ -33,13 +33,11 @@ func FuzzPackMintNativeCoinEqualTest(f *testing.F) {
f.Add(constants.BlackholeAddr.Bytes(), common.Big2.Bytes())
f.Fuzz(func(t *testing.T, b []byte, bigIntBytes []byte) {
bigIntVal := new(big.Int).SetBytes(bigIntBytes)
doCheckOutputs := true
doCheckOutputs := !(bigIntVal.Cmp(abi.MaxUint256) > 0)
// we can only check if outputs are correct if the value is less than MaxUint256
// otherwise the value will be truncated when packed,
// and thus unpacked output will not be equal to the value
if bigIntVal.Cmp(abi.MaxUint256) > 0 {
doCheckOutputs = false
}
testOldPackMintNativeCoinEqual(t, common.BytesToAddress(b), bigIntVal, doCheckOutputs)
})
}
+1 -1
View File
@@ -66,5 +66,5 @@ func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg pre
// default to disabling rewards
DisableFeeRewards(state)
}
return config.AllowListConfig.Configure(chainConfig, ContractAddress, state, blockContext)
return config.Configure(chainConfig, ContractAddress, state, blockContext)
}
+1 -1
View File
@@ -48,5 +48,5 @@ func (*configurator) Configure(chainConfig precompileconfig.ChainConfig, cfg pre
if !ok {
return fmt.Errorf("expected config type %T, got %T: %v", &Config{}, cfg, cfg)
}
return config.AllowListConfig.Configure(chainConfig, ContractAddress, state, blockContext)
return config.Configure(chainConfig, ContractAddress, state, blockContext)
}
+6 -6
View File
@@ -98,7 +98,7 @@ func TestSendWarpMessage(t *testing.T) {
require.NoError(t, err)
unsignedWarpMessage, err := luxWarp.NewUnsignedMessage(
consensus.GetNetworkID(defaultConsensusCtx),
blockchainID[:],
blockchainID,
sendWarpMessageAddressedPayload.Bytes(),
)
require.NoError(t, err)
@@ -167,7 +167,7 @@ func TestSendWarpMessage(t *testing.T) {
require.NoError(t, err)
require.Equal(t, common.BytesToAddress(addressedPayload.SourceAddress), callerAddr)
require.Equal(t, unsignedWarpMsg.SourceChainID, blockchainID[:])
require.Equal(t, unsignedWarpMsg.SourceChainID, blockchainID)
require.Equal(t, addressedPayload.Payload, sendWarpMessagePayload)
},
},
@@ -187,7 +187,7 @@ func TestGetVerifiedWarpMessage(t *testing.T) {
packagedPayloadBytes,
)
require.NoError(t, err)
unsignedWarpMsg, err := luxWarp.NewUnsignedMessage(networkID, sourceChainID[:], addressedPayload.Bytes())
unsignedWarpMsg, err := luxWarp.NewUnsignedMessage(networkID, sourceChainID, addressedPayload.Bytes())
require.NoError(t, err)
warpMessage, err := luxWarp.NewMessage(unsignedWarpMsg, &luxWarp.BitSetSignature{}) // Create message with empty signature for testing
require.NoError(t, err)
@@ -393,7 +393,7 @@ func TestGetVerifiedWarpMessage(t *testing.T) {
Caller: callerAddr,
InputFn: func(t testing.TB) []byte { return getVerifiedWarpMsg },
Predicates: func() [][]byte {
unsignedMessage, err := luxWarp.NewUnsignedMessage(networkID, sourceChainID[:], []byte{1, 2, 3}) // Invalid addressed payload
unsignedMessage, err := luxWarp.NewUnsignedMessage(networkID, sourceChainID, []byte{1, 2, 3}) // Invalid addressed payload
require.NoError(t, err)
warpMessage, err := luxWarp.NewMessage(unsignedMessage, &luxWarp.BitSetSignature{})
require.NoError(t, err)
@@ -653,7 +653,7 @@ func TestGetVerifiedWarpBlockHash(t *testing.T) {
Caller: callerAddr,
InputFn: func(t testing.TB) []byte { return getVerifiedWarpBlockHash },
Predicates: func() [][]byte {
unsignedMessage, err := luxWarp.NewUnsignedMessage(networkID, sourceChainID[:], []byte{1, 2, 3}) // Invalid block hash payload
unsignedMessage, err := luxWarp.NewUnsignedMessage(networkID, sourceChainID, []byte{1, 2, 3}) // Invalid block hash payload
require.NoError(t, err)
warpMessage, err := luxWarp.NewMessage(unsignedMessage, &luxWarp.BitSetSignature{})
require.NoError(t, err)
@@ -717,7 +717,7 @@ func TestPackEvents(t *testing.T) {
unsignedWarpMessage, err := luxWarp.NewUnsignedMessage(
networkID,
sourceChainID[:],
sourceChainID,
addressedPayload.Bytes(),
)
require.NoError(t, err)
+12 -12
View File
@@ -106,7 +106,7 @@ func init() {
panic(err)
}
addressedPayloadBytes = addressedPayload.Bytes()
unsignedMsg, err = luxWarp.NewUnsignedMessage(constants.UnitTestID, sourceChainID[:], addressedPayload.Bytes())
unsignedMsg, err = luxWarp.NewUnsignedMessage(constants.UnitTestID, sourceChainID, addressedPayload.Bytes())
if err != nil {
panic(err)
}
@@ -220,8 +220,8 @@ func (t *testValidatorStateWrapper) GetCurrentHeight() (uint64, error) {
}
func (t *testValidatorStateWrapper) GetMinimumHeight(ctx context.Context) (uint64, error) {
if t.State.GetMinimumHeightF != nil {
return t.State.GetMinimumHeightF(ctx)
if t.GetMinimumHeightF != nil {
return t.GetMinimumHeightF(ctx)
}
return 0, nil
}
@@ -239,22 +239,22 @@ func (t *testValidatorStateWrapper) GetValidatorSet(height uint64, subnetID ids.
}
func (t *testValidatorStateWrapper) GetSubnetID(chainID ids.ID) (ids.ID, error) {
if t.State.GetSubnetIDF != nil {
return t.State.GetSubnetIDF(chainID)
if t.GetSubnetIDF != nil {
return t.GetSubnetIDF(chainID)
}
return ids.Empty, nil
}
func (t *testValidatorStateWrapper) GetChainID(subnetID ids.ID) (ids.ID, error) {
if t.State.GetChainIDF != nil {
return t.State.GetChainIDF(subnetID)
if t.GetChainIDF != nil {
return t.GetChainIDF(subnetID)
}
return ids.Empty, nil
}
func (t *testValidatorStateWrapper) GetNetID(chainID ids.ID) (ids.ID, error) {
if t.State.GetNetIDF != nil {
return t.State.GetNetIDF(chainID)
if t.GetNetIDF != nil {
return t.GetNetIDF(chainID)
}
return ids.Empty, nil
}
@@ -319,7 +319,7 @@ func testWarpMessageFromPrimaryNetwork(t *testing.T, requirePrimaryNetworkSigner
cChainID := ids.GenerateTestID()
addressedCall, err := payload.NewAddressedCall(agoUtils.RandomBytes(20), agoUtils.RandomBytes(100))
require.NoError(err)
unsignedMsg, err := luxWarp.NewUnsignedMessage(constants.UnitTestID, cChainID[:], addressedCall.Bytes())
unsignedMsg, err := luxWarp.NewUnsignedMessage(constants.UnitTestID, cChainID, addressedCall.Bytes())
require.NoError(err)
getValidatorsOutput := make(map[ids.NodeID]*validators.GetValidatorOutput)
@@ -480,7 +480,7 @@ func TestInvalidAddressedPayload(t *testing.T) {
}
copy(warpSignature.Signature[:], bls.SignatureToBytes(aggregateSignature))
// Create an unsigned message with an invalid addressed payload
unsignedMsg, err := luxWarp.NewUnsignedMessage(constants.UnitTestID, sourceChainID[:], []byte{1, 2, 3})
unsignedMsg, err := luxWarp.NewUnsignedMessage(constants.UnitTestID, sourceChainID, []byte{1, 2, 3})
require.NoError(t, err)
warpMsg := &luxWarp.Message{
UnsignedMessage: unsignedMsg,
@@ -510,7 +510,7 @@ func TestInvalidBitSet(t *testing.T) {
require.NoError(t, err)
unsignedMsg, err := luxWarp.NewUnsignedMessage(
constants.UnitTestID,
sourceChainID[:],
sourceChainID,
addressedCall.Bytes(),
)
require.NoError(t, err)
+2 -2
View File
@@ -385,8 +385,8 @@ func testClientCancel(transport string, t *testing.T) {
// Now perform a call with the context.
// The key thing here is that no call will ever complete successfully.
err := client.CallContext(ctx, nil, "test_block")
switch {
case err == nil:
switch err {
case nil:
_, hasDeadline := ctx.Deadline()
t.Errorf("no error for call with %v wait time (deadline: %v)", timeout, hasDeadline)
// default:
+2 -4
View File
@@ -247,11 +247,9 @@ func (h *handler) handleBatch(msgs []*jsonrpcMessage) {
}
responseBytes := 0
for {
for cp.ctx.Err() == nil {
// No need to handle rest of calls if timed out.
if cp.ctx.Err() != nil {
break
}
msg := callBuffer.nextCall()
if msg == nil {
break
+2 -2
View File
@@ -377,11 +377,11 @@ func (wc *websocketCodec) pingLoop() {
pingTimer.Reset(wsPingInterval)
case <-pingTimer.C:
wc.jsonCodec.encMu.Lock()
wc.encMu.Lock()
wc.conn.SetWriteDeadline(time.Now().Add(wsPingWriteTimeout))
wc.conn.WriteMessage(websocket.PingMessage, nil)
wc.conn.SetReadDeadline(time.Now().Add(wsPongTimeout))
wc.jsonCodec.encMu.Unlock()
wc.encMu.Unlock()
pingTimer.Reset(wsPingInterval)
case <-wc.pongReceived:
+1 -1
View File
@@ -318,7 +318,7 @@ func (c *client) get(ctx context.Context, request message.Request, parseFn parse
var (
response []byte
nodeID ids.NodeID
start time.Time = time.Now()
start = time.Now()
)
if len(c.stateSyncNodes) == 0 {
response, nodeID, err = c.networkClient.SendSyncedAppRequestAny(ctx, StateSyncVersion, requestBytes)
+3 -2
View File
@@ -47,9 +47,10 @@ func TestLeafsRequestHandler_OnLeafsRequest(t *testing.T) {
10_000,
func(t *testing.T, i int, acc types.StateAccount) types.StateAccount {
// set the storage trie root for two accounts
if i == 0 {
switch i {
case 0:
acc.Root = largeTrieRoot
} else if i == 1 {
case 1:
acc.Root = smallTrieRoot
}
+1
View File
@@ -55,6 +55,7 @@ import (
ethparams "github.com/luxfi/geth/params"
"github.com/luxfi/geth/rlp"
"github.com/luxfi/geth/triedb"
// "github.com/luxfi/evm/triedb/firewood"
"github.com/holiman/uint256"
"github.com/luxfi/geth/triedb/hashdb"
+1
View File
@@ -11,6 +11,7 @@ import (
"path/filepath"
"strings"
"sync"
// "time" // Commented out - used in commented code
// "github.com/luxfi/ids" // Commented out - used in commented code
+1 -1
View File
@@ -137,7 +137,7 @@ func (db *Database) loadLayers() layer {
// journal is not matched(or missing) with the persistent state, discard
// it. Display log for discarding journal, but try to avoid showing
// useless information when the db is created from scratch.
if !(root == types.EmptyRootHash && errors.Is(err, errMissJournal)) {
if root != types.EmptyRootHash || !errors.Is(err, errMissJournal) {
log.Info("Failed to load journal, discard it", "err", err)
}
// Return single layer with persistent state.
+1 -1
View File
@@ -18,8 +18,8 @@ import (
luxWarp "github.com/luxfi/warp"
"github.com/luxfi/warp/payload"
"github.com/luxfi/evm/plugin/evm/validators/interfaces"
"github.com/luxfi/crypto"
"github.com/luxfi/evm/plugin/evm/validators/interfaces"
"github.com/luxfi/geth/log"
)
+1
View File
@@ -5,6 +5,7 @@ package validators
import (
"context"
"github.com/luxfi/consensus/validators"
"github.com/luxfi/ids"
"github.com/luxfi/node/utils/constants"
+1 -1
View File
@@ -10,11 +10,11 @@ import (
"github.com/luxfi/evm/warp/messages"
"github.com/luxfi/crypto"
"github.com/luxfi/database"
"github.com/luxfi/ids"
luxWarp "github.com/luxfi/warp"
"github.com/luxfi/warp/payload"
"github.com/luxfi/crypto"
)
const (